BIT-2170: Fix biometric bypass (#1324)

This commit is contained in:
Caleb Derosier
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent 4880d0b89d
commit f3f35511a4
12 changed files with 449 additions and 137 deletions
@@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import org.junit.Before
import org.junit.Test
import javax.crypto.Cipher
class VaultUnlockScreenTest : BaseComposeTest() {
@@ -51,7 +52,7 @@ class VaultUnlockScreenTest : BaseComposeTest() {
every { eventFlow } returns mutableEventFlow
every { stateFlow } returns mutableStateFlow
}
private val captureBiometricsSuccess = slot<() -> Unit>()
private val captureBiometricsSuccess = slot<(cipher: Cipher?) -> Unit>()
private val captureBiometricsLockOut = slot<() -> Unit>()
private val biometricsManager: BiometricsManager = mockk {
every { isBiometricsSupported } returns true
@@ -61,6 +62,7 @@ class VaultUnlockScreenTest : BaseComposeTest() {
onCancel = any(),
onLockOut = capture(captureBiometricsLockOut),
onError = any(),
cipher = CIPHER,
)
} just runs
}
@@ -76,18 +78,37 @@ class VaultUnlockScreenTest : BaseComposeTest() {
}
@Test
fun `on PromptForBiometrics should call launchUri on intentManager`() {
mutableEventFlow.tryEmit(VaultUnlockEvent.PromptForBiometrics)
verify {
fun `on PromptForBiometrics should call promptBiometrics on biometricsManager`() {
mutableEventFlow.tryEmit(VaultUnlockEvent.PromptForBiometrics(CIPHER))
verify(exactly = 1) {
biometricsManager.promptBiometrics(
onSuccess = any(),
onCancel = any(),
onError = any(),
onLockOut = any(),
cipher = any(),
)
}
}
@Test
fun `on biometrics authentication success should send BiometricsUnlockSuccess`() {
mutableEventFlow.tryEmit(VaultUnlockEvent.PromptForBiometrics(CIPHER))
captureBiometricsSuccess.captured(CIPHER)
verify(exactly = 1) {
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
}
}
@Test
fun `on biometrics authentication lockout should send BiometricsLockOut`() {
mutableEventFlow.tryEmit(VaultUnlockEvent.PromptForBiometrics(CIPHER))
captureBiometricsLockOut.captured()
verify(exactly = 1) {
viewModel.trySendAction(VaultUnlockAction.BiometricsLockOut)
}
}
@Test
fun `account icon click should show the account switcher`() {
composeTestRule.assertSwitcherIsNotDisplayed(
@@ -408,32 +429,17 @@ class VaultUnlockScreenTest : BaseComposeTest() {
}
}
@Suppress("MaxLineLength")
@Test
fun `unlock with biometrics click should send BiometricsUnlockClick on biometrics authentication success`() {
fun `unlock with biometrics click should send BiometricsUnlockClick`() {
composeTestRule
.onNodeWithText("Use biometrics to unlock")
.performScrollTo()
.performClick()
captureBiometricsSuccess.captured()
verify(exactly = 1) {
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
}
}
@Suppress("MaxLineLength")
@Test
fun `unlock with biometrics click should send BiometricsLockOut on biometrics authentication lock out`() {
composeTestRule
.onNodeWithText("Use biometrics to unlock")
.performScrollTo()
.performClick()
captureBiometricsLockOut.captured()
verify(exactly = 1) {
viewModel.trySendAction(VaultUnlockAction.BiometricsLockOut)
}
}
@Test
fun `account button should update according to state`() {
mutableStateFlow.update { it.copy(showAccountMenu = true) }
@@ -490,6 +496,7 @@ private val ACCOUNT_SUMMARIES = listOf(
LOCKED_ACCOUNT_SUMMARY,
)
private val CIPHER = mockk<Cipher>()
private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
accountSummaries = ACCOUNT_SUMMARIES,
avatarColorString = "0000FF",
@@ -502,5 +509,6 @@ private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
isBiometricsValid = true,
isBiometricEnabled = true,
showAccountMenu = true,
userId = ACTIVE_ACCOUNT_SUMMARY.userId,
vaultUnlockType = VaultUnlockType.MASTER_PASSWORD,
)
@@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import javax.crypto.Cipher
@Suppress("LargeClass")
class VaultUnlockViewModelTest : BaseViewModelTest() {
@@ -52,7 +53,19 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
every { lockVault(any()) } just runs
}
private val encryptionManager: BiometricsEncryptionManager = mockk {
every { isBiometricIntegrityValid(userId = DEFAULT_USER_STATE.activeUserId) } returns true
every { getOrCreateCipher(USER_ID) } returns CIPHER
every {
isBiometricIntegrityValid(
userId = DEFAULT_USER_STATE.activeUserId,
cipher = CIPHER,
)
} returns true
every {
isBiometricIntegrityValid(
userId = DEFAULT_USER_STATE.activeUserId,
cipher = null,
)
} returns false
}
@Test
@@ -64,7 +77,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
val viewModel = createViewModel(state = initialState)
viewModel.eventFlow.test {
assertEquals(VaultUnlockEvent.PromptForBiometrics, awaitItem())
assertEquals(VaultUnlockEvent.PromptForBiometrics(CIPHER), awaitItem())
}
}
@@ -72,6 +85,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
fun `initial state should be correct when not set`() {
val viewModel = createViewModel()
assertEquals(DEFAULT_STATE, viewModel.stateFlow.value)
verify { encryptionManager.getOrCreateCipher(USER_ID) }
}
@Test
@@ -283,6 +297,32 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
)
}
@Test
fun `on BiometricsUnlockClick should emit PromptForBiometrics when cipher is non-null`() =
runTest {
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
assertEquals(VaultUnlockEvent.PromptForBiometrics(CIPHER), awaitItem())
}
verify { encryptionManager.getOrCreateCipher(USER_ID) }
}
@Test
fun `on BiometricsUnlockClick should disable isBiometricsValid when cipher is null`() {
val initialState = DEFAULT_STATE.copy(isBiometricsValid = true)
val viewModel = createViewModel(state = initialState)
every { encryptionManager.getOrCreateCipher(USER_ID) } returns null
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
assertEquals(
initialState.copy(isBiometricsValid = false),
viewModel.stateFlow.value,
)
verify { encryptionManager.getOrCreateCipher(USER_ID) }
}
@Test
fun `on AddAccountClick should set hasPendingAccountAddition to true on the AuthRepository`() {
val viewModel = createViewModel()
@@ -649,7 +689,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength")
@Test
fun `on BiometricsUnlockClick should display error dialog on unlockVaultWithBiometrics AuthenticationError`() {
fun `on BiometricsUnlockSuccess should display error dialog on unlockVaultWithBiometrics AuthenticationError`() {
val initialState = DEFAULT_STATE.copy(isBiometricEnabled = true)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
@@ -659,7 +699,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
vaultRepository.unlockVaultWithBiometrics()
} returns VaultUnlockResult.AuthenticationError
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
assertEquals(
initialState.copy(
@@ -676,7 +716,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength")
@Test
fun `on BiometricsUnlockClick should display error dialog on unlockVaultWithBiometrics GenericError`() {
fun `on BiometricsUnlockSuccess should display error dialog on unlockVaultWithBiometrics GenericError`() {
val initialState = DEFAULT_STATE.copy(isBiometricEnabled = true)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
@@ -686,7 +726,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
vaultRepository.unlockVaultWithBiometrics()
} returns VaultUnlockResult.GenericError
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
assertEquals(
initialState.copy(
@@ -703,7 +743,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
@Suppress("MaxLineLength")
@Test
fun `on BiometricsUnlockClick should display error dialog on unlockVaultWithBiometrics InvalidStateError`() {
fun `on BiometricsUnlockSuccess should display error dialog on unlockVaultWithBiometrics InvalidStateError`() {
val initialState = DEFAULT_STATE.copy(isBiometricEnabled = true)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
@@ -713,7 +753,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
vaultRepository.unlockVaultWithBiometrics()
} returns VaultUnlockResult.InvalidStateError
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
assertEquals(
initialState.copy(
@@ -729,7 +769,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
}
@Test
fun `on BiometricsUnlockClick should clear dialog on unlockVaultWithBiometrics success`() {
fun `on BiometricsUnlockSuccess should clear dialog on unlockVaultWithBiometrics success`() {
val initialState = DEFAULT_STATE.copy(isBiometricEnabled = true)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
@@ -739,7 +779,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
vaultRepository.unlockVaultWithBiometrics()
} returns VaultUnlockResult.Success
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
assertEquals(
initialState.copy(dialog = null),
@@ -751,7 +791,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
}
@Test
fun `on BiometricsUnlockClick should clear dialog when user has changed`() {
fun `on BiometricsUnlockSuccess should clear dialog when user has changed`() {
val initialState = DEFAULT_STATE.copy(isBiometricEnabled = true)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
@@ -762,7 +802,7 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
vaultRepository.unlockVaultWithBiometrics()
} coAnswers { resultFlow.first() }
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockClick)
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(CIPHER))
assertEquals(
initialState.copy(dialog = VaultUnlockState.VaultUnlockDialog.Loading),
@@ -782,6 +822,31 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
}
}
@Test
fun `on BiometricsUnlockSuccess should set isBiometricsValid to false with null cipher`() {
val initialState = DEFAULT_STATE.copy(
isBiometricEnabled = true,
isBiometricsValid = true,
)
mutableUserStateFlow.value = DEFAULT_USER_STATE.copy(
accounts = listOf(DEFAULT_ACCOUNT.copy(isBiometricsEnabled = true)),
)
val viewModel = createViewModel(state = initialState)
coEvery {
vaultRepository.unlockVaultWithBiometrics()
} returns VaultUnlockResult.Success
viewModel.trySendAction(VaultUnlockAction.BiometricsUnlockSuccess(cipher = null))
assertEquals(
initialState.copy(
dialog = null,
isBiometricsValid = false,
),
viewModel.stateFlow.value,
)
}
private fun createViewModel(
state: VaultUnlockState? = null,
unlockType: UnlockType = UnlockType.STANDARD,
@@ -800,6 +865,8 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
)
}
private val CIPHER = mockk<Cipher>()
private const val USER_ID: String = "activeUserId"
private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
accountSummaries = listOf(
AccountSummary(
@@ -823,6 +890,7 @@ private val DEFAULT_STATE: VaultUnlockState = VaultUnlockState(
isBiometricsValid = true,
isBiometricEnabled = false,
showAccountMenu = true,
userId = USER_ID,
vaultUnlockType = VaultUnlockType.MASTER_PASSWORD,
)
@@ -835,7 +903,7 @@ private val TRUSTED_DEVICE: UserState.TrustedDevice = UserState.TrustedDevice(
)
private val DEFAULT_ACCOUNT = UserState.Account(
userId = "activeUserId",
userId = USER_ID,
name = "Active User",
email = "active@bitwarden.com",
environment = Environment.Us,
@@ -851,6 +919,6 @@ private val DEFAULT_ACCOUNT = UserState.Account(
)
private val DEFAULT_USER_STATE = UserState(
activeUserId = "activeUserId",
activeUserId = USER_ID,
accounts = listOf(DEFAULT_ACCOUNT),
)
@@ -37,6 +37,7 @@ import kotlinx.coroutines.flow.update
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import javax.crypto.Cipher
@Suppress("LargeClass")
class AccountSecurityScreenTest : BaseComposeTest() {
@@ -50,7 +51,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
every { startActivity(any()) } just runs
every { startApplicationDetailsSettingsActivity() } just runs
}
private val captureBiometricsSuccess = slot<() -> Unit>()
private val captureBiometricsSuccess = slot<(cipher: Cipher?) -> Unit>()
private val captureBiometricsCancel = slot<() -> Unit>()
private val captureBiometricsLockOut = slot<() -> Unit>()
private val captureBiometricsError = slot<() -> Unit>()
@@ -62,6 +63,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
onCancel = capture(captureBiometricsCancel),
onLockOut = capture(captureBiometricsLockOut),
onError = capture(captureBiometricsError),
cipher = CIPHER,
)
} just runs
}
@@ -108,8 +110,9 @@ class AccountSecurityScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(AccountSecurityAction.PendingLoginRequestsClick) }
}
@Suppress("MaxLineLength")
@Test
fun `on unlock with biometrics toggle should send UnlockWithBiometricToggle on success`() {
fun `on unlock with biometrics toggle should send EnableBiometricsClick when isUnlockWithBiometricsEnabled is false`() {
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
@@ -118,17 +121,24 @@ class AccountSecurityScreenTest : BaseComposeTest() {
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AccountSecurityAction.EnableBiometricsClick)
}
}
@Test
fun `on unlock with biometrics toggle should send UnlockWithBiometricToggle`() {
mutableStateFlow.update { it.copy(isUnlockWithBiometricsEnabled = true) }
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOn()
captureBiometricsSuccess.captured()
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AccountSecurityAction.UnlockWithBiometricToggle(true))
viewModel.trySendAction(AccountSecurityAction.UnlockWithBiometricToggle(false))
}
}
@@ -138,10 +148,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.performClick()
mutableEventFlow.tryEmit(AccountSecurityEvent.ShowBiometricsPrompt(CIPHER))
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
@@ -162,10 +169,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.performClick()
mutableEventFlow.tryEmit(AccountSecurityEvent.ShowBiometricsPrompt(CIPHER))
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
@@ -186,10 +190,7 @@ class AccountSecurityScreenTest : BaseComposeTest() {
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.performClick()
mutableEventFlow.tryEmit(AccountSecurityEvent.ShowBiometricsPrompt(CIPHER))
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
@@ -204,6 +205,27 @@ class AccountSecurityScreenTest : BaseComposeTest() {
}
}
@Test
fun `on unlock with biometrics toggle should send UnlockWithBiometricToggle on success`() {
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
mutableEventFlow.tryEmit(AccountSecurityEvent.ShowBiometricsPrompt(CIPHER))
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOn()
captureBiometricsSuccess.captured(CIPHER)
composeTestRule
.onNodeWithText("Unlock with Biometrics")
.performScrollTo()
.assertIsOff()
verify(exactly = 1) {
viewModel.trySendAction(AccountSecurityAction.UnlockWithBiometricToggle(true))
}
}
@Test
fun `on unlock with biometrics should be toggled on or off according to state`() {
composeTestRule.onNodeWithText("Unlock with Biometrics").assertIsOff()
@@ -1359,12 +1381,15 @@ class AccountSecurityScreenTest : BaseComposeTest() {
}
}
private val CIPHER = mockk<Cipher>()
private const val USER_ID: String = "activeUserId"
private val DEFAULT_STATE = AccountSecurityState(
dialog = null,
fingerprintPhrase = "fingerprint-placeholder".asText(),
isUnlockWithBiometricsEnabled = false,
isUnlockWithPasswordEnabled = true,
isUnlockWithPinEnabled = false,
userId = USER_ID,
vaultTimeout = VaultTimeout.ThirtyMinutes,
vaultTimeoutAction = VaultTimeoutAction.LOCK,
vaultTimeoutPolicyMinutes = null,
@@ -7,6 +7,7 @@ import com.x8bit.bitwarden.data.auth.repository.AuthRepository
import com.x8bit.bitwarden.data.auth.repository.model.PolicyInformation
import com.x8bit.bitwarden.data.auth.repository.model.UserFingerprintResult
import com.x8bit.bitwarden.data.auth.repository.model.UserState
import com.x8bit.bitwarden.data.platform.manager.BiometricsEncryptionManager
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository
import com.x8bit.bitwarden.data.platform.repository.SettingsRepository
@@ -36,6 +37,7 @@ import kotlinx.serialization.json.encodeToJsonElement
import kotlinx.serialization.json.jsonObject
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import javax.crypto.Cipher
class AccountSecurityViewModelTest : BaseViewModelTest() {
@@ -53,6 +55,9 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
coEvery { getUserFingerprint() } returns UserFingerprintResult.Success(FINGERPRINT)
}
private val mutableActivePolicyFlow = bufferedMutableSharedFlow<List<SyncResponseJson.Policy>>()
private val biometricsEncryptionManager: BiometricsEncryptionManager = mockk {
every { createCipher(DEFAULT_USER_STATE.activeUserId) } returns CIPHER
}
private val policyManager: PolicyManager = mockk {
every {
getActivePoliciesFlow(type = PolicyTypeJson.MAXIMUM_VAULT_TIMEOUT)
@@ -69,11 +74,27 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
@Test
fun `initial state should be correct when saved state is not set`() {
every { settingsRepository.isUnlockWithPinEnabled } returns true
every {
biometricsEncryptionManager.getOrCreateCipher(DEFAULT_USER_STATE.activeUserId)
} returns CIPHER
every {
biometricsEncryptionManager.isBiometricIntegrityValid(
userId = DEFAULT_USER_STATE.activeUserId,
cipher = CIPHER,
)
} returns true
val viewModel = createViewModel(initialState = null)
assertEquals(
DEFAULT_STATE.copy(isUnlockWithPinEnabled = true),
viewModel.stateFlow.value,
)
verify {
biometricsEncryptionManager.getOrCreateCipher(DEFAULT_USER_STATE.activeUserId)
biometricsEncryptionManager.isBiometricIntegrityValid(
userId = DEFAULT_USER_STATE.activeUserId,
cipher = CIPHER,
)
}
coVerify { settingsRepository.getUserFingerprint() }
}
@@ -306,6 +327,19 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
}
}
@Test
fun `on EnableBiometricsClick should emit ShowBiometricsPrompt`() = runTest {
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(AccountSecurityAction.EnableBiometricsClick)
assertEquals(
AccountSecurityEvent.ShowBiometricsPrompt(CIPHER),
awaitItem(),
)
}
}
@Test
fun `on UnlockWithBiometricToggle false should call clearBiometricsKey and update the state`() =
runTest {
@@ -547,12 +581,14 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
vaultRepository: VaultRepository = this.vaultRepository,
environmentRepository: EnvironmentRepository = this.fakeEnvironmentRepository,
settingsRepository: SettingsRepository = this.settingsRepository,
biometricsEncryptionManager: BiometricsEncryptionManager = this.biometricsEncryptionManager,
policyManager: PolicyManager = this.policyManager,
): AccountSecurityViewModel = AccountSecurityViewModel(
authRepository = authRepository,
vaultRepository = vaultRepository,
settingsRepository = settingsRepository,
environmentRepository = environmentRepository,
biometricsEncryptionManager = biometricsEncryptionManager,
policyManager = policyManager,
savedStateHandle = SavedStateHandle().apply {
set("state", initialState)
@@ -560,20 +596,9 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
)
}
private val CIPHER = mockk<Cipher>()
private const val FINGERPRINT: String = "fingerprint"
private val DEFAULT_STATE: AccountSecurityState = AccountSecurityState(
dialog = null,
fingerprintPhrase = FINGERPRINT.asText(),
isUnlockWithBiometricsEnabled = false,
isUnlockWithPasswordEnabled = true,
isUnlockWithPinEnabled = false,
vaultTimeout = VaultTimeout.ThirtyMinutes,
vaultTimeoutAction = VaultTimeoutAction.LOCK,
vaultTimeoutPolicyMinutes = null,
vaultTimeoutPolicyAction = null,
)
private val DEFAULT_USER_STATE = UserState(
activeUserId = "activeUserId",
accounts = listOf(
@@ -594,3 +619,16 @@ private val DEFAULT_USER_STATE = UserState(
),
),
)
private val DEFAULT_STATE: AccountSecurityState = AccountSecurityState(
dialog = null,
fingerprintPhrase = FINGERPRINT.asText(),
isUnlockWithBiometricsEnabled = false,
isUnlockWithPasswordEnabled = true,
isUnlockWithPinEnabled = false,
userId = DEFAULT_USER_STATE.activeUserId,
vaultTimeout = VaultTimeout.ThirtyMinutes,
vaultTimeoutAction = VaultTimeoutAction.LOCK,
vaultTimeoutPolicyMinutes = null,
vaultTimeoutPolicyAction = null,
)