mirror of
https://github.com/bitwarden/android.git
synced 2026-11-19 17:40:12 -06:00
BIT-2231: Disable components of the AccountSecurityScreen for TDE (#1276)
This commit is contained in:
committed by
Álison Fernandes
parent
52561215fe
commit
dc2a0d10b9
+56
@@ -1511,6 +1511,62 @@ class AccountSecurityScreenTest : BaseComposeTest() {
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `change master password row should be displayed according to state`() {
|
||||
val rowText = "Change master password"
|
||||
composeTestRule.onNodeWithText(rowText).performScrollTo().assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update { it.copy(isUnlockWithPasswordEnabled = false) }
|
||||
|
||||
composeTestRule.onNodeWithText(rowText).assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `lock now row should be displayed according to state`() {
|
||||
val rowText = "Lock now"
|
||||
composeTestRule.onNodeWithText(rowText).performScrollTo().assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
isUnlockWithBiometricsEnabled = true,
|
||||
isUnlockWithPasswordEnabled = false,
|
||||
isUnlockWithPinEnabled = false,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText(rowText).performScrollTo().assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
isUnlockWithBiometricsEnabled = false,
|
||||
isUnlockWithPasswordEnabled = true,
|
||||
isUnlockWithPinEnabled = false,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText(rowText).performScrollTo().assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
isUnlockWithBiometricsEnabled = false,
|
||||
isUnlockWithPasswordEnabled = false,
|
||||
isUnlockWithPinEnabled = true,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText(rowText).performScrollTo().assertIsDisplayed()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
isUnlockWithBiometricsEnabled = false,
|
||||
isUnlockWithPasswordEnabled = false,
|
||||
isUnlockWithPinEnabled = false,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText(rowText).assertDoesNotExist()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DEFAULT_STATE = AccountSecurityState(
|
||||
dialog = null,
|
||||
|
||||
+54
@@ -329,6 +329,35 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on UnlockWithBiometricToggle false should call clearBiometricsKey, reset the vaultTimeoutAction, and update the state`() =
|
||||
runTest {
|
||||
val initialState = DEFAULT_STATE.copy(
|
||||
isUnlockWithPasswordEnabled = false,
|
||||
isUnlockWithBiometricsEnabled = true,
|
||||
)
|
||||
every { settingsRepository.isUnlockWithBiometricsEnabled } returns true
|
||||
every { settingsRepository.clearBiometricsKey() } just runs
|
||||
every { settingsRepository.vaultTimeoutAction = VaultTimeoutAction.LOGOUT } just runs
|
||||
val viewModel = createViewModel(initialState)
|
||||
assertEquals(initialState, viewModel.stateFlow.value)
|
||||
|
||||
viewModel.trySendAction(AccountSecurityAction.UnlockWithBiometricToggle(false))
|
||||
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
isUnlockWithBiometricsEnabled = false,
|
||||
vaultTimeoutAction = VaultTimeoutAction.LOGOUT,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
verify(exactly = 1) {
|
||||
settingsRepository.clearBiometricsKey()
|
||||
settingsRepository.vaultTimeoutAction = VaultTimeoutAction.LOGOUT
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on UnlockWithBiometricToggle true and setupBiometricsKey error should call update the state accordingly`() =
|
||||
@@ -408,6 +437,31 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on UnlockWithPinToggle Disabled should set pin unlock to false, reset the vaultTimeoutAction, and clear the PIN in settings`() {
|
||||
val initialState = DEFAULT_STATE.copy(
|
||||
isUnlockWithPasswordEnabled = false,
|
||||
isUnlockWithPinEnabled = true,
|
||||
)
|
||||
every { settingsRepository.clearUnlockPin() } just runs
|
||||
every { settingsRepository.vaultTimeoutAction = VaultTimeoutAction.LOGOUT } just runs
|
||||
val viewModel = createViewModel(initialState = initialState)
|
||||
viewModel.trySendAction(
|
||||
AccountSecurityAction.UnlockWithPinToggle.Disabled,
|
||||
)
|
||||
assertEquals(
|
||||
initialState.copy(
|
||||
vaultTimeoutAction = VaultTimeoutAction.LOGOUT,
|
||||
isUnlockWithPinEnabled = false,
|
||||
),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
verify {
|
||||
settingsRepository.clearUnlockPin()
|
||||
settingsRepository.vaultTimeoutAction = VaultTimeoutAction.LOGOUT
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on UnlockWithPinToggle PendingEnabled should set pin unlock to true`() {
|
||||
val initialState = DEFAULT_STATE.copy(
|
||||
|
||||
Reference in New Issue
Block a user