mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
[PM-12604] Fix showing the biometric prompt when not needed adding account (#3962)
This commit is contained in:
parent
4f34f6da21
commit
0f009943b5
2 changed files with 31 additions and 1 deletions
|
@ -310,6 +310,8 @@ class VaultUnlockViewModel @Inject constructor(
|
|||
|
||||
// If the Vault is already unlocked, do nothing.
|
||||
if (userState.activeAccount.isVaultUnlocked) return
|
||||
// If the user state has changed to add a new account, do nothing.
|
||||
if (userState.hasPendingAccountAddition) return
|
||||
|
||||
mutableStateFlow.update {
|
||||
val accountSummaries = userState.toAccountSummaries()
|
||||
|
|
|
@ -460,7 +460,35 @@ class VaultUnlockViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(VaultUnlockEvent.PromptForBiometrics(CIPHER), awaitItem())
|
||||
expectNoEvents()
|
||||
}
|
||||
verify {
|
||||
// The initial state causes this to be called as well as the change.
|
||||
verify(exactly = 2) {
|
||||
encryptionManager.getOrCreateCipher(USER_ID)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `switching accounts should not prompt for biometrics if new account has biometrics enabled`() =
|
||||
runTest {
|
||||
val account = DEFAULT_ACCOUNT.copy(
|
||||
isVaultUnlocked = false,
|
||||
isBiometricsEnabled = true,
|
||||
)
|
||||
val initialState = DEFAULT_STATE.copy(isBiometricsValid = true)
|
||||
val viewModel = createViewModel(state = initialState)
|
||||
mutableUserStateFlow.update {
|
||||
it?.copy(
|
||||
activeUserId = account.userId,
|
||||
accounts = listOf(account),
|
||||
hasPendingAccountAddition = true,
|
||||
)
|
||||
}
|
||||
|
||||
viewModel.eventFlow.test {
|
||||
expectNoEvents()
|
||||
}
|
||||
// Only the call for the initial state should be called.
|
||||
verify(exactly = 1) {
|
||||
encryptionManager.getOrCreateCipher(USER_ID)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue