BITAU-176 Filter out deleted ciphers from syncAccounts call (#4078)

This commit is contained in:
Andrew Haisting 2024-10-14 15:19:07 -05:00 committed by GitHub
parent 8eab74d458
commit 2b87cdac9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -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

View file

@ -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(