mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 08:35:05 -06:00
[PM-25522] Add importCxf function to VaultSdkSource (#5841)
This commit is contained in:
parent
fe79ea4822
commit
a298b85374
@ -438,6 +438,14 @@ interface VaultSdkSource {
|
||||
ciphers: List<Cipher>,
|
||||
): Result<String>
|
||||
|
||||
/**
|
||||
* Imports the given CXF formatted [payload] into the users vault.
|
||||
*
|
||||
* @return Result of the import. If successful, a list of [Cipher]s deciphered from the CXF
|
||||
* payload.
|
||||
*/
|
||||
suspend fun importCxf(userId: String, payload: String): Result<List<Cipher>>
|
||||
|
||||
/**
|
||||
* Register a new FIDO 2 credential to a cipher.
|
||||
*
|
||||
|
||||
@ -505,6 +505,15 @@ class VaultSdkSourceImpl(
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun importCxf(
|
||||
userId: String,
|
||||
payload: String,
|
||||
): Result<List<Cipher>> = runCatchingWithLogs {
|
||||
getClient(userId = userId)
|
||||
.exporters()
|
||||
.importCxf(payload = payload)
|
||||
}
|
||||
|
||||
override suspend fun registerFido2Credential(
|
||||
request: RegisterFido2CredentialRequest,
|
||||
fido2CredentialStore: Fido2CredentialStore,
|
||||
|
||||
@ -1167,6 +1167,35 @@ class VaultSdkSourceTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `importCxf should call SDK and return a Result with the correct data`() = runTest {
|
||||
val userId = "userId"
|
||||
val expected = listOf(createMockSdkCipher(number = 1))
|
||||
val cxf = "cxf"
|
||||
|
||||
coEvery {
|
||||
clientExporters.importCxf(
|
||||
payload = cxf,
|
||||
)
|
||||
} returns expected
|
||||
|
||||
val result = vaultSdkSource.importCxf(
|
||||
userId = userId,
|
||||
payload = cxf,
|
||||
)
|
||||
|
||||
coVerify {
|
||||
clientExporters.importCxf(
|
||||
payload = cxf,
|
||||
)
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
expected.asSuccess(),
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `registerFido2Credential should return attestation response when registration completes`() =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user