generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-11979: Allow PIN unlock to configure biometric integrity if needed (…
- Loading branch information
1 parent
261bb86
commit 121a26d
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1742,6 +1742,37 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo | |
) | ||
XCTAssertFalse(vaultTimeoutService.isLocked(userId: "1")) | ||
XCTAssertTrue(vaultTimeoutService.unlockVaultHadUserInteraction) | ||
XCTAssertFalse(biometricsRepository.didConfigureBiometricIntegrity) | ||
} | ||
|
||
/// `unlockVaultWithPIN(_:)` unlocks the vault with the user's PIN and configures biometric | ||
/// integrity if needed. | ||
func test_unlockVaultWithPIN_configuresBiometrics() async throws { | ||
let account = Account.fixture() | ||
stateService.activeAccount = account | ||
stateService.accountEncryptionKeys = [ | ||
"1": AccountEncryptionKeys(encryptedPrivateKey: "PRIVATE_KEY", encryptedUserKey: "USER_KEY"), | ||
] | ||
stateService.encryptedPinByUserId[account.profile.userId] = "123" | ||
stateService.pinProtectedUserKeyValue[account.profile.userId] = "123" | ||
biometricsRepository.biometricUnlockStatus = .success( | ||
.available(.faceID, enabled: true, hasValidIntegrity: false) | ||
) | ||
|
||
try await subject.unlockVaultWithPIN(pin: "123") | ||
|
||
XCTAssertEqual( | ||
clientService.mockCrypto.initializeUserCryptoRequest, | ||
InitUserCryptoRequest( | ||
kdfParams: .pbkdf2(iterations: UInt32(Constants.pbkdf2Iterations)), | ||
email: "[email protected]", | ||
privateKey: "PRIVATE_KEY", | ||
method: .pin(pin: "123", pinProtectedUserKey: "123") | ||
) | ||
) | ||
XCTAssertFalse(vaultTimeoutService.isLocked(userId: "1")) | ||
XCTAssertTrue(vaultTimeoutService.unlockVaultHadUserInteraction) | ||
XCTAssertTrue(biometricsRepository.didConfigureBiometricIntegrity) | ||
} | ||
|
||
/// `unlockVaultWithPIN(_:)` throws an error if there's no pin. | ||
|