@@ -1035,7 +1035,6 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1035
1035
try await subject. unlockVaultWithNeverlockKey ( )
1036
1036
}
1037
1037
XCTAssertFalse ( vaultTimeoutService. unlockVaultHadUserInteraction)
1038
- XCTAssertFalse ( biometricsRepository. didConfigureBiometricIntegrity)
1039
1038
}
1040
1039
1041
1040
/// `test_unlockVaultWithDeviceKey` attempts to unlock the vault using the device key from the keychain.
@@ -1064,38 +1063,6 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1064
1063
XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1065
1064
}
1066
1065
1067
- /// `test_unlockVaultWithDeviceKey` attempts to unlock the vault using the device key from the keychain.
1068
- func test_unlockVaultWithDeviceKey_successWithBiometricsEnabled( ) async throws {
1069
- let active = Account . fixtureWithTDE ( )
1070
- stateService. activeAccount = active
1071
- keychainService. mockStorage = [
1072
- keychainService. formattedKey (
1073
- for: KeychainItem . deviceKey (
1074
- userId: active. profile. userId
1075
- )
1076
- ) :
1077
- " pasta " ,
1078
- ]
1079
-
1080
- biometricsRepository. biometricUnlockStatus = . success(
1081
- . available( . faceID, enabled: true , hasValidIntegrity: false )
1082
- )
1083
-
1084
- stateService. accountEncryptionKeys = [
1085
- active. profile. userId: . init(
1086
- encryptedPrivateKey: " secret " ,
1087
- encryptedUserKey: " recipe "
1088
- ) ,
1089
- ]
1090
- clientService. mockCrypto. getUserEncryptionKeyResult = . success( " sauce " )
1091
- clientService. mockCrypto. initializeUserCryptoResult = . success( ( ) )
1092
- await assertAsyncDoesNotThrow {
1093
- try await subject. unlockVaultWithDeviceKey ( )
1094
- }
1095
- XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1096
- XCTAssertTrue ( biometricsRepository. didConfigureBiometricIntegrity)
1097
- }
1098
-
1099
1066
/// `test_unlockVaultWithDeviceKey` attempts to unlock the vault using the device key from the keychain.
1100
1067
func test_unlockVaultWithDeviceKey_error( ) async throws {
1101
1068
let active = Account . fixture ( )
@@ -1189,7 +1156,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1189
1156
stateService. timeoutAction [ " 1 " ] = . lock
1190
1157
stateService. userHasMasterPassword [ " 1 " ] = false
1191
1158
biometricsRepository. biometricUnlockStatus = . success(
1192
- . available( . faceID, enabled: true , hasValidIntegrity : true )
1159
+ . available( . faceID, enabled: true )
1193
1160
)
1194
1161
1195
1162
var timeoutAction = try await subject. sessionTimeoutAction ( )
@@ -1339,43 +1306,9 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1339
1306
XCTAssertEqual ( authService. hashPasswordPassword, " password " )
1340
1307
XCTAssertEqual ( stateService. accountVolatileData [ " 1 " ] ? . pinProtectedUserKey, " ENCRYPTED_USER_KEY " )
1341
1308
XCTAssertEqual ( stateService. masterPasswordHashes [ " 1 " ] , " hashed " )
1342
- XCTAssertFalse ( biometricsRepository. didConfigureBiometricIntegrity)
1343
1309
XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1344
1310
}
1345
1311
1346
- /// `unlockVaultWithPassword(password:)` configures biometric integrity refreshes.
1347
- func test_unlockVault_integrityRefresh( ) async throws {
1348
- stateService. activeAccount = . fixture( )
1349
- stateService. accountEncryptionKeys = [
1350
- " 1 " : AccountEncryptionKeys (
1351
- encryptedPrivateKey: " PRIVATE_KEY " ,
1352
- encryptedUserKey: " USER_KEY "
1353
- ) ,
1354
- ]
1355
- biometricsRepository. biometricUnlockStatus = . success(
1356
- . available( . faceID, enabled: true , hasValidIntegrity: false )
1357
- )
1358
-
1359
- await assertAsyncDoesNotThrow {
1360
- try await subject. unlockVaultWithPassword ( password: " password " )
1361
- }
1362
-
1363
- XCTAssertEqual (
1364
- clientService. mockCrypto. initializeUserCryptoRequest,
1365
- InitUserCryptoRequest (
1366
- kdfParams: . pbkdf2( iterations: UInt32 ( Constants . pbkdf2Iterations) ) ,
1367
-
1368
- privateKey: " PRIVATE_KEY " ,
1369
- method: . password( password: " password " , userKey: " USER_KEY " )
1370
- )
1371
- )
1372
- XCTAssertFalse ( vaultTimeoutService. isLocked ( userId: " 1 " ) )
1373
- XCTAssertTrue ( organizationService. initializeOrganizationCryptoCalled)
1374
- XCTAssertEqual ( authService. hashPasswordPassword, " password " )
1375
- XCTAssertEqual ( stateService. masterPasswordHashes [ " 1 " ] , " hashed " )
1376
- XCTAssertTrue ( biometricsRepository. didConfigureBiometricIntegrity)
1377
- }
1378
-
1379
1312
/// `unlockVaultWithBiometrics()` throws an error if the vault is unable to be unlocked.
1380
1313
func test_unlockVaultWithBiometrics_error_cryptoFail( ) async {
1381
1314
stateService. accountEncryptionKeys = [
@@ -1505,43 +1438,6 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1505
1438
)
1506
1439
XCTAssertFalse ( keyConnectorService. convertNewUserToKeyConnectorCalled)
1507
1440
XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1508
- XCTAssertFalse ( biometricsRepository. didConfigureBiometricIntegrity)
1509
- }
1510
-
1511
- /// `unlockVaultWithKeyConnectorKey()` unlocks the user's vault with their key connector key.
1512
- func test_unlockVaultWithKeyConnectorKeyWithBiometricsEnabled( ) async {
1513
- clientService. mockCrypto. initializeUserCryptoResult = . success( ( ) )
1514
- keyConnectorService. getMasterKeyFromKeyConnectorResult = . success( " key " )
1515
- stateService. accountEncryptionKeys = [
1516
- " 1 " : AccountEncryptionKeys (
1517
- encryptedPrivateKey: " private " ,
1518
- encryptedUserKey: " user "
1519
- ) ,
1520
- ]
1521
- stateService. activeAccount = . fixture( )
1522
- biometricsRepository. biometricUnlockStatus = . success(
1523
- . available( . faceID, enabled: true , hasValidIntegrity: false )
1524
- )
1525
-
1526
- await assertAsyncDoesNotThrow {
1527
- try await subject. unlockVaultWithKeyConnectorKey (
1528
- keyConnectorURL: URL ( string: " https://example.com " ) !,
1529
- orgIdentifier: " org-id "
1530
- )
1531
- }
1532
-
1533
- XCTAssertEqual (
1534
- clientService. mockCrypto. initializeUserCryptoRequest,
1535
- InitUserCryptoRequest (
1536
- kdfParams: KdfConfig ( ) . sdkKdf,
1537
-
1538
- privateKey: " private " ,
1539
- method: . keyConnector( masterKey: " key " , userKey: " user " )
1540
- )
1541
- )
1542
- XCTAssertFalse ( keyConnectorService. convertNewUserToKeyConnectorCalled)
1543
- XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1544
- XCTAssertTrue ( biometricsRepository. didConfigureBiometricIntegrity)
1545
1441
}
1546
1442
1547
1443
/// `unlockVaultWithKeyConnectorKey()` converts a new user to use key connector and unlocks the
@@ -1748,37 +1644,6 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
1748
1644
)
1749
1645
XCTAssertFalse ( vaultTimeoutService. isLocked ( userId: " 1 " ) )
1750
1646
XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1751
- XCTAssertFalse ( biometricsRepository. didConfigureBiometricIntegrity)
1752
- }
1753
-
1754
- /// `unlockVaultWithPIN(_:)` unlocks the vault with the user's PIN and configures biometric
1755
- /// integrity if needed.
1756
- func test_unlockVaultWithPIN_configuresBiometrics( ) async throws {
1757
- let account = Account . fixture ( )
1758
- stateService. activeAccount = account
1759
- stateService. accountEncryptionKeys = [
1760
- " 1 " : AccountEncryptionKeys ( encryptedPrivateKey: " PRIVATE_KEY " , encryptedUserKey: " USER_KEY " ) ,
1761
- ]
1762
- stateService. encryptedPinByUserId [ account. profile. userId] = " 123 "
1763
- stateService. pinProtectedUserKeyValue [ account. profile. userId] = " 123 "
1764
- biometricsRepository. biometricUnlockStatus = . success(
1765
- . available( . faceID, enabled: true , hasValidIntegrity: false )
1766
- )
1767
-
1768
- try await subject. unlockVaultWithPIN ( pin: " 123 " )
1769
-
1770
- XCTAssertEqual (
1771
- clientService. mockCrypto. initializeUserCryptoRequest,
1772
- InitUserCryptoRequest (
1773
- kdfParams: . pbkdf2( iterations: UInt32 ( Constants . pbkdf2Iterations) ) ,
1774
-
1775
- privateKey: " PRIVATE_KEY " ,
1776
- method: . pin( pin: " 123 " , pinProtectedUserKey: " 123 " )
1777
- )
1778
- )
1779
- XCTAssertFalse ( vaultTimeoutService. isLocked ( userId: " 1 " ) )
1780
- XCTAssertTrue ( vaultTimeoutService. unlockVaultHadUserInteraction)
1781
- XCTAssertTrue ( biometricsRepository. didConfigureBiometricIntegrity)
1782
1647
}
1783
1648
1784
1649
/// `unlockVaultWithPIN(_:)` throws an error if there's no pin.
0 commit comments