PM-10917: Fix crash caused when adding an item from a collection (#3809)

This commit is contained in:
David Perez 2024-08-22 13:48:46 -05:00 committed by GitHub
parent eb2ba8e598
commit b56a21b6e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -37,8 +37,8 @@ fun VaultItemListingState.ItemListingType.Vault.toVaultItemCipherType(): VaultIt
is VaultItemListingState.ItemListingType.Vault.Identity -> VaultItemCipherType.IDENTITY
is VaultItemListingState.ItemListingType.Vault.SecureNote -> VaultItemCipherType.SECURE_NOTE
is VaultItemListingState.ItemListingType.Vault.Login -> VaultItemCipherType.LOGIN
is VaultItemListingState.ItemListingType.Vault.Collection -> VaultItemCipherType.LOGIN
is VaultItemListingState.ItemListingType.Vault.Trash,
is VaultItemListingState.ItemListingType.Vault.Collection,
is VaultItemListingState.ItemListingType.Vault.Folder,
-> throw IllegalStateException("Cannot create vault item from this VaultItemListingState!")
}

View file

@ -118,6 +118,7 @@ class VaultItemListingStateExtensionsTest {
VaultItemListingState.ItemListingType.Vault.Identity,
VaultItemListingState.ItemListingType.Vault.SecureNote,
VaultItemListingState.ItemListingType.Vault.Login,
VaultItemListingState.ItemListingType.Vault.Collection(collectionId = "mockId"),
)
val result = itemListingTypes.map { it.toVaultItemCipherType() }
@ -128,6 +129,7 @@ class VaultItemListingStateExtensionsTest {
VaultItemCipherType.IDENTITY,
VaultItemCipherType.SECURE_NOTE,
VaultItemCipherType.LOGIN,
VaultItemCipherType.LOGIN,
),
result,
)
@ -137,9 +139,6 @@ class VaultItemListingStateExtensionsTest {
fun `toVaultItemCipherType should throw an exception for unsupported ItemListingTypes`() {
val itemListingTypes = listOf(
VaultItemListingState.ItemListingType.Vault.Trash,
VaultItemListingState.ItemListingType.Vault.Collection(
collectionId = "mockId",
),
VaultItemListingState.ItemListingType.Vault.Folder(
folderId = "mockId",
),