mirror of
https://github.com/bitwarden/android.git
synced 2026-10-22 02:53:19 -05:00
[PM-41952] fix: [Defect] Android - If a Passkey is attached to a Cipher that has a… [bug-factory poc]
Automated fix from the AI-49 bug factory. Proof: ./gradlew :app:testStandardDebugUnitTest --tests "com.x8bit.bitwarden.ui.vault.feature.exportitems.reviewexport.ReviewExportViewModelTest" must fail on base and pass with the fix.
This commit is contained in:
2 files changed
+63
-1
No files matched your search
+1
-1
@@ -245,9 +245,9 @@ class ReviewExportViewModel @Inject constructor(
|
||||
?.filter { it.isActive }
|
||||
.orEmpty()
|
||||
.forEach {
|
||||
if (it.isActiveWithFido2Credentials) passkeyItemCount++
|
||||
when {
|
||||
it.isActiveWithCopyablePassword -> passwordItemCount++
|
||||
it.isActiveWithFido2Credentials -> passkeyItemCount++
|
||||
it.type is CipherListViewType.Identity -> identityItemCount++
|
||||
it.card != null -> cardItemCount++
|
||||
it.type is CipherListViewType.SecureNote -> secureNoteItemCount++
|
||||
|
||||
+62
@@ -25,6 +25,7 @@ import com.x8bit.bitwarden.data.platform.manager.model.SpecialCircumstance
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockCardListView
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockCipherListView
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockDecryptCipherListResult
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockLoginListView
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkPolicy
|
||||
import com.x8bit.bitwarden.data.vault.repository.VaultRepository
|
||||
import io.mockk.awaits
|
||||
@@ -101,6 +102,67 @@ class ReviewExportViewModelTest : BaseViewModelTest() {
|
||||
assertEquals(expectedState, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `State should count login with both password and passkey in passwords and passkeys`() =
|
||||
runTest {
|
||||
decryptCipherListResultFlow.value = DataState.Loaded(
|
||||
data = DecryptCipherListResult(
|
||||
successes = listOf(
|
||||
createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(
|
||||
createMockLoginListView(number = 1, hasFido2 = true),
|
||||
),
|
||||
),
|
||||
),
|
||||
failures = emptyList(),
|
||||
),
|
||||
)
|
||||
val expectedState = DEFAULT_STATE.copy(
|
||||
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
|
||||
itemTypeCounts = DEFAULT_CONTENT_VIEW_STATE.itemTypeCounts.copy(
|
||||
passwordCount = 1,
|
||||
passkeyCount = 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
val viewModel = createViewModel()
|
||||
viewModel.stateFlow.test {
|
||||
assertEquals(expectedState, awaitItem())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `State should count passkey-only login only in passkeys`() = runTest {
|
||||
decryptCipherListResultFlow.value = DataState.Loaded(
|
||||
data = DecryptCipherListResult(
|
||||
successes = listOf(
|
||||
createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(
|
||||
createMockLoginListView(number = 1, hasFido2 = true),
|
||||
),
|
||||
copyableFields = emptyList(),
|
||||
),
|
||||
),
|
||||
failures = emptyList(),
|
||||
),
|
||||
)
|
||||
val expectedState = DEFAULT_STATE.copy(
|
||||
viewState = DEFAULT_CONTENT_VIEW_STATE.copy(
|
||||
itemTypeCounts = DEFAULT_CONTENT_VIEW_STATE.itemTypeCounts.copy(
|
||||
passwordCount = 0,
|
||||
passkeyCount = 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
val viewModel = createViewModel()
|
||||
viewModel.stateFlow.test {
|
||||
assertEquals(expectedState, awaitItem())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in new issue
Block a user