mirror of
https://github.com/bitwarden/android.git
synced 2026-03-12 05:04:17 -05:00
PM-31734: Add archived item filtering for passkeys (#6482)
This commit is contained in:
@@ -7,16 +7,19 @@ import com.bitwarden.vault.CopyableCipherFields
|
||||
import com.bitwarden.vault.LoginListView
|
||||
|
||||
/**
|
||||
* Returns true when the cipher is not deleted and contains at least one FIDO 2 credential.
|
||||
* Returns true when the cipher is not archived, not deleted and contains at least one FIDO 2
|
||||
* credential.
|
||||
*/
|
||||
val CipherListView.isActiveWithFido2Credentials: Boolean
|
||||
get() = deletedDate == null && login?.hasFido2 ?: false
|
||||
get() = archivedDate == null && deletedDate == null && login?.hasFido2 ?: false
|
||||
|
||||
/**
|
||||
* Returns true when the cipher type is not deleted and contains a copyable password.
|
||||
* Returns true when the cipher type is not archived, not deleted and contains a copyable password.
|
||||
*/
|
||||
val CipherListView.isActiveWithCopyablePassword: Boolean
|
||||
get() = deletedDate == null && copyableFields.contains(CopyableCipherFields.LOGIN_PASSWORD)
|
||||
get() = archivedDate == null &&
|
||||
deletedDate == null &&
|
||||
copyableFields.contains(CopyableCipherFields.LOGIN_PASSWORD)
|
||||
|
||||
/**
|
||||
* Returns the [LoginListView] if the cipher is of type [CipherListViewType.Login], otherwise null.
|
||||
|
||||
@@ -48,13 +48,17 @@ fun CipherView.toAutofillCipherProvider(): AutofillCipherProvider =
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when the cipher is not deleted and contains at least one FIDO 2 credential.
|
||||
* Returns true when the cipher is not archived, not deleted and contains at least one FIDO 2
|
||||
* credential.
|
||||
*/
|
||||
val CipherView.isActiveWithFido2Credentials: Boolean
|
||||
get() = deletedDate == null && !(login?.fido2Credentials.isNullOrEmpty())
|
||||
get() = archivedDate == null &&
|
||||
deletedDate == null &&
|
||||
!(login?.fido2Credentials.isNullOrEmpty())
|
||||
|
||||
/**
|
||||
* Returns true when the cipher is not deleted and contains at least one Password credential.
|
||||
* Returns true when the cipher is not archived, not deleted and contains at least one Password
|
||||
* credential.
|
||||
*/
|
||||
val CipherView.isActiveWithPasswordCredentials: Boolean
|
||||
get() = deletedDate == null && !(login?.password.isNullOrEmpty())
|
||||
get() = archivedDate == null && deletedDate == null && !(login?.password.isNullOrEmpty())
|
||||
|
||||
@@ -62,7 +62,48 @@ class CipherListViewExtensionsTest {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return true when Fido2 credentials are present and cipher is not deleted`() {
|
||||
fun `isActiveWithCopyablePassword should return true when copyable fields contains LOGIN_PASSWORD and cipher is not deleted or archived`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(v1 = createMockLoginListView(number = 1)),
|
||||
)
|
||||
assertTrue(cipherListView.isActiveWithCopyablePassword)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `isActiveWithCopyablePassword should return false copyable fields does not contain LOGIN_PASSWORD`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
copyableFields = emptyList(),
|
||||
type = CipherListViewType.Login(v1 = createMockLoginListView(number = 1)),
|
||||
)
|
||||
assertFalse(cipherListView.isActiveWithCopyablePassword)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithCopyablePassword should return false when cipher is archived`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(v1 = createMockLoginListView(number = 1)),
|
||||
isArchived = true,
|
||||
)
|
||||
assertFalse(cipherListView.isActiveWithCopyablePassword)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithCopyablePassword should return false when cipher is deleted`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(v1 = createMockLoginListView(number = 1)),
|
||||
isDeleted = true,
|
||||
)
|
||||
assertFalse(cipherListView.isActiveWithCopyablePassword)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return true when Fido2 credentials are present and cipher is not deleted or archived`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(
|
||||
@@ -90,6 +131,21 @@ class CipherListViewExtensionsTest {
|
||||
assertFalse(cipherListView.isActiveWithFido2Credentials)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return false when cipher is archived`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
number = 1,
|
||||
type = CipherListViewType.Login(
|
||||
createMockLoginListView(
|
||||
number = 1,
|
||||
hasFido2 = true,
|
||||
),
|
||||
),
|
||||
isArchived = true,
|
||||
)
|
||||
assertFalse(cipherListView.isActiveWithFido2Credentials)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return false when cipher is deleted`() {
|
||||
val cipherListView = createMockCipherListView(
|
||||
|
||||
@@ -142,7 +142,7 @@ class CipherViewExtensionsTest {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return true when type is login, deleted date is null, and fido2 credentials are not null`() {
|
||||
fun `isActiveWithFido2Credentials should return true when type is login, deleted and archived date is null, and fido2 credentials are not null`() {
|
||||
assertTrue(
|
||||
createMockCipherView(
|
||||
number = 1,
|
||||
@@ -152,6 +152,13 @@ class CipherViewExtensionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return false when archive date is not null`() {
|
||||
assertFalse(
|
||||
createMockCipherView(number = 1, isArchived = true).isActiveWithFido2Credentials,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithFido2Credentials should return false when deleted date is not null`() {
|
||||
assertFalse(
|
||||
@@ -187,7 +194,7 @@ class CipherViewExtensionsTest {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `isActiveWithPasswordCredentials should return true when type is login, deleted date is null, and password credentials are not empty`() {
|
||||
fun `isActiveWithPasswordCredentials should return true when type is login, deleted and archived date is null, and password credentials are not empty`() {
|
||||
assertTrue(
|
||||
createMockCipherView(
|
||||
number = 1,
|
||||
@@ -197,6 +204,13 @@ class CipherViewExtensionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithPasswordCredentials should return false when archive date is not null`() {
|
||||
assertFalse(
|
||||
createMockCipherView(number = 1, isArchived = true).isActiveWithPasswordCredentials,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isActiveWithPasswordCredentials should return false when deleted date is not null`() {
|
||||
assertFalse(
|
||||
|
||||
Reference in New Issue
Block a user