mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-10066 don't prompt for MP if the user does not have one (#3633)
Some checks failed
Crowdin Push / Crowdin Push (push) Waiting to run
Scan / Check PR run (push) Failing after 0s
Scan / SAST scan (push) Has been skipped
Scan / Quality scan (push) Has been skipped
Test / Check PR run (push) Failing after 0s
Test / Test (push) Has been skipped
Some checks failed
Crowdin Push / Crowdin Push (push) Waiting to run
Scan / Check PR run (push) Failing after 0s
Scan / SAST scan (push) Has been skipped
Scan / Quality scan (push) Has been skipped
Test / Check PR run (push) Failing after 0s
Test / Test (push) Has been skipped
This commit is contained in:
parent
abeb60e237
commit
f110687e76
3 changed files with 85 additions and 8 deletions
|
@ -337,7 +337,8 @@ private fun CipherView.toDisplayItem(
|
|||
optionsTestTag = "CipherOptionsButton",
|
||||
isAutofill = isAutofill,
|
||||
isFido2Creation = isFido2Creation,
|
||||
shouldShowMasterPasswordReprompt = reprompt == CipherRepromptType.PASSWORD,
|
||||
shouldShowMasterPasswordReprompt = (reprompt == CipherRepromptType.PASSWORD) &&
|
||||
hasMasterPassword,
|
||||
)
|
||||
|
||||
private fun CipherView.toSecondSubtitle(fido2CredentialRpId: String?): String? =
|
||||
|
|
|
@ -532,6 +532,81 @@ class VaultItemListingDataExtensionsTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `toViewState should transform a list of CipherViews into a ViewState with correct value for repromt`() {
|
||||
mockkStatic(CipherView::subtitle)
|
||||
mockkStatic(Uri::class)
|
||||
val uriMock = mockk<Uri>()
|
||||
every { any<CipherView>().subtitle } returns null
|
||||
every { Uri.parse(any()) } returns uriMock
|
||||
every { uriMock.host } returns "www.mockuri.com"
|
||||
|
||||
val cipherViewList = listOf(
|
||||
createMockCipherView(
|
||||
number = 1,
|
||||
isDeleted = false,
|
||||
cipherType = CipherType.LOGIN,
|
||||
folderId = "mockId-1",
|
||||
fido2Credentials = createMockSdkFido2CredentialList(number = 1),
|
||||
)
|
||||
.copy(reprompt = CipherRepromptType.PASSWORD),
|
||||
)
|
||||
val fido2CredentialAutofillViews = listOf(
|
||||
createMockFido2CredentialAutofillView(
|
||||
cipherId = "mockId-1",
|
||||
number = 1,
|
||||
),
|
||||
)
|
||||
|
||||
val result = VaultData(
|
||||
cipherViewList = cipherViewList,
|
||||
collectionViewList = listOf(),
|
||||
folderViewList = listOf(),
|
||||
sendViewList = listOf(),
|
||||
).toViewState(
|
||||
itemListingType = VaultItemListingState.ItemListingType.Vault.Folder("mockId-1"),
|
||||
vaultFilterType = VaultFilterType.AllVaults,
|
||||
hasMasterPassword = false,
|
||||
baseIconUrl = Environment.Us.environmentUrlData.baseIconUrl,
|
||||
isIconLoadingDisabled = false,
|
||||
autofillSelectionData = AutofillSelectionData(
|
||||
type = AutofillSelectionData.Type.LOGIN,
|
||||
uri = null,
|
||||
),
|
||||
fido2CreationData = null,
|
||||
fido2CredentialAutofillViews = fido2CredentialAutofillViews,
|
||||
isPremiumUser = true,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
VaultItemListingState.ViewState.Content(
|
||||
displayCollectionList = emptyList(),
|
||||
displayItemList = listOf(
|
||||
createMockDisplayItemForCipher(
|
||||
number = 1,
|
||||
cipherType = CipherType.LOGIN,
|
||||
subtitle = null,
|
||||
requiresPasswordReprompt = false,
|
||||
)
|
||||
.copy(
|
||||
secondSubtitle = "mockRpId-1",
|
||||
secondSubtitleTestTag = "PasskeySite",
|
||||
subtitleTestTag = "PasskeyName",
|
||||
iconData = IconData.Network(
|
||||
uri = "https://vault.bitwarden.com/icons/www.mockuri.com/icon.png",
|
||||
fallbackIconRes = R.drawable.ic_login_item_passkey,
|
||||
),
|
||||
isAutofill = true,
|
||||
shouldShowMasterPasswordReprompt = false,
|
||||
),
|
||||
),
|
||||
displayFolderList = emptyList(),
|
||||
),
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `toViewState should transform an empty list of CipherViews into a NoItems ViewState with the appropriate data`() {
|
||||
|
|
|
@ -16,6 +16,7 @@ fun createMockDisplayItemForCipher(
|
|||
number: Int,
|
||||
cipherType: CipherType = CipherType.LOGIN,
|
||||
subtitle: String? = "mockUsername-$number",
|
||||
requiresPasswordReprompt: Boolean = true,
|
||||
): VaultItemListingState.DisplayItem =
|
||||
when (cipherType) {
|
||||
CipherType.LOGIN -> {
|
||||
|
@ -47,14 +48,14 @@ fun createMockDisplayItemForCipher(
|
|||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = "mockId-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopyUsernameClick(
|
||||
username = "mockUsername-$number",
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopyPasswordClick(
|
||||
password = "mockPassword-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
cipherId = "mockId-$number",
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopyTotpClick(
|
||||
|
@ -98,7 +99,7 @@ fun createMockDisplayItemForCipher(
|
|||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = "mockId-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopyNoteClick(
|
||||
notes = "mockNotes-$number",
|
||||
|
@ -138,16 +139,16 @@ fun createMockDisplayItemForCipher(
|
|||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = "mockId-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopyNumberClick(
|
||||
number = "mockNumber-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
ListingItemOverflowAction.VaultAction.CopySecurityCodeClick(
|
||||
securityCode = "mockCode-$number",
|
||||
cipherId = "mockId-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
),
|
||||
optionsTestTag = "CipherOptionsButton",
|
||||
|
@ -184,7 +185,7 @@ fun createMockDisplayItemForCipher(
|
|||
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"),
|
||||
ListingItemOverflowAction.VaultAction.EditClick(
|
||||
cipherId = "mockId-$number",
|
||||
requiresPasswordReprompt = true,
|
||||
requiresPasswordReprompt = requiresPasswordReprompt,
|
||||
),
|
||||
),
|
||||
optionsTestTag = "CipherOptionsButton",
|
||||
|
|
Loading…
Reference in a new issue