[PM-25522] Add importCxf function to VaultSdkSource (#5841)

This commit is contained in:
Patrick Honkonen 2025-09-05 14:56:01 -04:00 committed by GitHub
parent fe79ea4822
commit a298b85374
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 46 additions and 0 deletions

View File

@ -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.
*

View File

@ -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,

View File

@ -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`() =