Update tests for clearData in AuthDiskSource and SettingsDiskSource (#1282)

This commit is contained in:
David Perez 2024-04-17 14:35:40 -05:00 committed by Álison Fernandes
parent e58710b3e8
commit f6f2746b25
2 changed files with 27 additions and 6 deletions

View file

@ -182,17 +182,24 @@ class AuthDiskSourceTest {
fun `clearData should clear all necessary data for the given user`() {
val userId = "userId"
val pendingAuthRequestJson = PendingAuthRequestJson(
requestId = "12345",
requestPrivateKey = "67890",
)
authDiskSource.storePendingAuthRequest(
userId = userId,
pendingAuthRequest = PendingAuthRequestJson(
requestId = "12345",
requestPrivateKey = "67890",
),
pendingAuthRequest = pendingAuthRequestJson,
)
val deviceKey = "deviceKey"
authDiskSource.storeDeviceKey(userId = userId, deviceKey = deviceKey)
authDiskSource.storeUserBiometricUnlockKey(
userId = userId,
biometricsKey = "1234-9876-0192",
)
authDiskSource.storePinProtectedUserKey(
userId = userId,
pinProtectedUserKey = "pinProtectedUserKey",
)
authDiskSource.storeLastActiveTimeMillis(
userId = userId,
lastActiveTimeMillis = 123456789L,
@ -226,10 +233,18 @@ class AuthDiskSourceTest {
refreshToken = "refreshToken",
),
)
authDiskSource.storeEncryptedPin(userId = userId, encryptedPin = "encryptedPin")
authDiskSource.storeMasterPasswordHash(userId = userId, passwordHash = "passwordHash")
authDiskSource.clearData(userId = userId)
// We do not clear these even when you call clear storage
assertEquals(pendingAuthRequestJson, authDiskSource.getPendingAuthRequest(userId = userId))
assertEquals(deviceKey, authDiskSource.getDeviceKey(userId = userId))
// These should be cleared
assertNull(authDiskSource.getUserBiometricUnlockKey(userId = userId))
assertNull(authDiskSource.getPinProtectedUserKey(userId = userId))
assertNull(authDiskSource.getLastActiveTimeMillis(userId = userId))
assertNull(authDiskSource.getInvalidUnlockAttempts(userId = userId))
assertNull(authDiskSource.getUserKey(userId = userId))
@ -239,6 +254,8 @@ class AuthDiskSourceTest {
assertNull(authDiskSource.getOrganizations(userId = userId))
assertNull(authDiskSource.getPolicies(userId = userId))
assertNull(authDiskSource.getAccountTokens(userId = userId))
assertNull(authDiskSource.getEncryptedPin(userId = userId))
assertNull(authDiskSource.getMasterPasswordHash(userId = userId))
}
@Test

View file

@ -139,6 +139,7 @@ class SettingsDiskSourceTest {
userId = userId,
isScreenCaptureAllowed = true,
)
settingsDiskSource.storeClearClipboardFrequencySeconds(userId = userId, frequency = 5)
val systemBioIntegrityState = "system_biometrics_integrity_state"
settingsDiskSource.storeAccountBiometricIntegrityValidity(
userId = userId,
@ -148,6 +149,10 @@ class SettingsDiskSourceTest {
settingsDiskSource.clearData(userId = userId)
// We do not clear these even when you call clear storage
assertEquals(true, settingsDiskSource.getScreenCaptureAllowed(userId = userId))
// These should be cleared
assertNull(settingsDiskSource.getVaultTimeoutInMinutes(userId = userId))
assertNull(settingsDiskSource.getVaultTimeoutAction(userId = userId))
assertNull(settingsDiskSource.getDefaultUriMatchType(userId = userId))
@ -158,8 +163,7 @@ class SettingsDiskSourceTest {
assertNull(settingsDiskSource.getBlockedAutofillUris(userId = userId))
assertNull(settingsDiskSource.getApprovePasswordlessLoginsEnabled(userId = userId))
assertNull(settingsDiskSource.getLastSyncTime(userId = userId))
// We don't actually clear this setting, so it's still here
assertEquals(true, settingsDiskSource.getScreenCaptureAllowed(userId = userId))
assertNull(settingsDiskSource.getClearClipboardFrequencySeconds(userId = userId))
assertNull(
settingsDiskSource.getAccountBiometricIntegrityValidity(
userId = userId,