mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-12631: Handle password re-prompt for accessibility autofill (#3965)
This commit is contained in:
parent
6908111377
commit
caa0c613a5
2 changed files with 64 additions and 1 deletions
|
@ -1122,8 +1122,19 @@ class VaultItemListingViewModel @Inject constructor(
|
|||
when (data) {
|
||||
is MasterPasswordRepromptData.Autofill -> {
|
||||
// Complete the autofill selection flow
|
||||
val autofillSelectionData = state.autofillSelectionData ?: return
|
||||
val cipherView = getCipherViewOrNull(cipherId = data.cipherId) ?: return
|
||||
autofillSelectionManager.emitAutofillSelection(cipherView = cipherView)
|
||||
when (autofillSelectionData.framework) {
|
||||
AutofillSelectionData.Framework.ACCESSIBILITY -> {
|
||||
accessibilitySelectionManager.emitAccessibilitySelection(
|
||||
cipherView = cipherView,
|
||||
)
|
||||
}
|
||||
|
||||
AutofillSelectionData.Framework.AUTOFILL -> {
|
||||
autofillSelectionManager.emitAutofillSelection(cipherView = cipherView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is MasterPasswordRepromptData.OverflowItem -> {
|
||||
|
|
|
@ -794,6 +794,15 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
|
|||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
specialCircumstanceManager.specialCircumstance =
|
||||
SpecialCircumstance.AutofillSelection(
|
||||
autofillSelectionData = AutofillSelectionData(
|
||||
type = AutofillSelectionData.Type.LOGIN,
|
||||
framework = AutofillSelectionData.Framework.AUTOFILL,
|
||||
uri = "https://www.test.com",
|
||||
),
|
||||
shouldFinishWhenComplete = true,
|
||||
)
|
||||
val viewModel = createVaultItemListingViewModel()
|
||||
coEvery {
|
||||
authRepository.validatePassword(password = password)
|
||||
|
@ -815,6 +824,49 @@ class VaultItemListingViewModelTest : BaseViewModelTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `MasterPasswordRepromptSubmit for a request Success with a valid password for accessibility autofill should post to the AccessibilitySelectionManager`() =
|
||||
runTest {
|
||||
setupMockUri()
|
||||
val cipherView = createMockCipherView(number = 1)
|
||||
val cipherId = "mockId-1"
|
||||
val password = "password"
|
||||
mutableVaultDataStateFlow.value = DataState.Loaded(
|
||||
data = VaultData(
|
||||
cipherViewList = listOf(cipherView),
|
||||
folderViewList = emptyList(),
|
||||
collectionViewList = emptyList(),
|
||||
sendViewList = emptyList(),
|
||||
),
|
||||
)
|
||||
specialCircumstanceManager.specialCircumstance =
|
||||
SpecialCircumstance.AutofillSelection(
|
||||
autofillSelectionData = AutofillSelectionData(
|
||||
type = AutofillSelectionData.Type.LOGIN,
|
||||
framework = AutofillSelectionData.Framework.ACCESSIBILITY,
|
||||
uri = "https://www.test.com",
|
||||
),
|
||||
shouldFinishWhenComplete = true,
|
||||
)
|
||||
val viewModel = createVaultItemListingViewModel()
|
||||
coEvery {
|
||||
authRepository.validatePassword(password = password)
|
||||
} returns ValidatePasswordResult.Success(isValid = true)
|
||||
|
||||
accessibilitySelectionManager.accessibilitySelectionFlow.test {
|
||||
viewModel.trySendAction(
|
||||
VaultItemListingsAction.MasterPasswordRepromptSubmit(
|
||||
password = password,
|
||||
masterPasswordRepromptData = MasterPasswordRepromptData.Autofill(
|
||||
cipherId = cipherId,
|
||||
),
|
||||
),
|
||||
)
|
||||
assertEquals(cipherView, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `MasterPasswordRepromptSubmit for a request Success with a valid password for overflow actions should process the action`() =
|
||||
|
|
Loading…
Reference in a new issue