Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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>()
Expand Down Expand Up @@ -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(
Expand Down