@@ -1742,6 +1742,37 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1742
1742
)
1743
1743
XCTAssertFalse ( vaultTimeoutService. isLocked ( userId: " 1 " ) )
1744
1744
XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1745
+ XCTAssertFalse ( biometricsRepository. didConfigureBiometricIntegrity)
1746
+ }
1747
+
1748
+ /// `unlockVaultWithPIN(_:)` unlocks the vault with the user's PIN and configures biometric
1749
+ /// integrity if needed.
1750
+ func test_unlockVaultWithPIN_configuresBiometrics( ) async throws {
1751
+ let account = Account . fixture ( )
1752
+ stateService. activeAccount = account
1753
+ stateService. accountEncryptionKeys = [
1754
+ " 1 " : AccountEncryptionKeys ( encryptedPrivateKey: " PRIVATE_KEY " , encryptedUserKey: " USER_KEY " ) ,
1755
+ ]
1756
+ stateService. encryptedPinByUserId [ account. profile. userId] = " 123 "
1757
+ stateService. pinProtectedUserKeyValue [ account. profile. userId] = " 123 "
1758
+ biometricsRepository. biometricUnlockStatus = . success(
1759
+ . available( . faceID, enabled: true , hasValidIntegrity: false )
1760
+ )
1761
+
1762
+ try await subject. unlockVaultWithPIN ( pin: " 123 " )
1763
+
1764
+ XCTAssertEqual (
1765
+ clientService. mockCrypto. initializeUserCryptoRequest,
1766
+ InitUserCryptoRequest (
1767
+ kdfParams: . pbkdf2( iterations: UInt32 ( Constants . pbkdf2Iterations) ) ,
1768
+
1769
+ privateKey: " PRIVATE_KEY " ,
1770
+ method: . pin( pin: " 123 " , pinProtectedUserKey: " 123 " )
1771
+ )
1772
+ )
1773
+ XCTAssertFalse ( vaultTimeoutService. isLocked ( userId: " 1 " ) )
1774
+ XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1775
+ XCTAssertTrue ( biometricsRepository. didConfigureBiometricIntegrity)
1745
1776
}
1746
1777
1747
1778
/// `unlockVaultWithPIN(_:)` throws an error if there's no pin.
0 commit comments