mirror of
https://github.com/bitwarden/android.git
synced 2026-05-21 03:21:29 -05:00
Bug: Fix CipherType crash (#6922)
This commit is contained in:
@@ -739,9 +739,8 @@ fun CipherTypeJson.toSdkCipherType(): CipherType =
|
||||
CipherTypeJson.IDENTITY -> CipherType.IDENTITY
|
||||
CipherTypeJson.SSH_KEY -> CipherType.SSH_KEY
|
||||
CipherTypeJson.BANK_ACCOUNT -> CipherType.BANK_ACCOUNT
|
||||
CipherTypeJson.DRIVERS_LICENSE,
|
||||
CipherTypeJson.PASSPORT,
|
||||
-> throw IllegalArgumentException("SDK mapping not yet available for $this")
|
||||
CipherTypeJson.DRIVERS_LICENSE -> CipherType.DRIVERS_LICENSE
|
||||
CipherTypeJson.PASSPORT -> CipherType.PASSPORT
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkSshKey
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkUri
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.assertNull
|
||||
@@ -357,21 +356,20 @@ class VaultSdkCipherExtensionsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `toSdkCipherType should throw for DRIVERS_LICENSE since SDK mapping is not yet available`() {
|
||||
val error = assertThrows(IllegalArgumentException::class.java) {
|
||||
CipherTypeJson.DRIVERS_LICENSE.toSdkCipherType()
|
||||
}
|
||||
assertEquals("SDK mapping not yet available for DRIVERS_LICENSE", error.message)
|
||||
fun `toSdkCipherType should map LICENSE to the SDK LICENSE type`() {
|
||||
assertEquals(
|
||||
CipherType.DRIVERS_LICENSE,
|
||||
CipherTypeJson.DRIVERS_LICENSE.toSdkCipherType(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toSdkCipherType should throw for PASSPORT since SDK mapping is not yet available`() {
|
||||
val error = assertThrows(IllegalArgumentException::class.java) {
|
||||
CipherTypeJson.PASSPORT.toSdkCipherType()
|
||||
}
|
||||
assertEquals("SDK mapping not yet available for PASSPORT", error.message)
|
||||
fun `toSdkCipherType should map PASSPORT to the SDK PASSPORT type`() {
|
||||
assertEquals(
|
||||
CipherType.PASSPORT,
|
||||
CipherTypeJson.PASSPORT.toSdkCipherType(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user