mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +03:00
BITAU-176 Filter out deleted ciphers from syncAccounts call (#4078)
This commit is contained in:
parent
8eab74d458
commit
2b87cdac9e
2 changed files with 12 additions and 3 deletions
|
@ -95,8 +95,8 @@ class AuthenticatorBridgeRepositoryImpl(
|
|||
val totpUris = vaultDiskSource
|
||||
.getCiphers(userId)
|
||||
.first()
|
||||
// Filter out any ciphers without a totp item:
|
||||
.filter { it.login?.totp != null }
|
||||
// Filter out any ciphers without a totp item and also deleted ciphers:
|
||||
.filter { it.login?.totp != null && it.deletedDate == null }
|
||||
.mapNotNull {
|
||||
// Decrypt each cipher and take just totp codes:
|
||||
vaultSdkSource
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.junit.jupiter.api.Assertions.assertNull
|
|||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
class AuthenticatorBridgeRepositoryTest {
|
||||
|
||||
|
@ -183,7 +184,7 @@ class AuthenticatorBridgeRepositoryTest {
|
|||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `syncAccounts when vault is locked for both users should unlock and re-lock vault for both users`() =
|
||||
fun `syncAccounts when vault is locked for both users should unlock and re-lock vault for both users and filter out deleted ciphers`() =
|
||||
runTest {
|
||||
every { vaultRepository.isVaultUnlocked(USER_1_ID) } returns false
|
||||
coEvery {
|
||||
|
@ -382,10 +383,17 @@ private val USER_STATE = UserState(
|
|||
|
||||
private val USER_1_TOTP_CIPHER = mockk<SyncResponseJson.Cipher> {
|
||||
every { login?.totp } returns "encryptedTotp1"
|
||||
every { deletedDate } returns null
|
||||
}
|
||||
|
||||
private val USER_1_DELETED_TOTP_CIPHER = mockk<SyncResponseJson.Cipher> {
|
||||
every { login?.totp } returns "encryptedTotp1Deleted"
|
||||
every { deletedDate } returns ZonedDateTime.now()
|
||||
}
|
||||
|
||||
private val USER_2_TOTP_CIPHER = mockk<SyncResponseJson.Cipher> {
|
||||
every { login?.totp } returns "encryptedTotp2"
|
||||
every { deletedDate } returns null
|
||||
}
|
||||
|
||||
private val USER_1_ENCRYPTED_SDK_TOTP_CIPHER = mockk<Cipher>()
|
||||
|
@ -419,6 +427,7 @@ private val USER_2_SHARED_ACCOUNT = SharedAccountData.Account(
|
|||
|
||||
private val USER_1_CIPHERS = listOf(
|
||||
USER_1_TOTP_CIPHER,
|
||||
USER_1_DELETED_TOTP_CIPHER,
|
||||
)
|
||||
|
||||
private val USER_2_CIPHERS = listOf(
|
||||
|
|
Loading…
Reference in a new issue