mirror of
https://github.com/bitwarden/android.git
synced 2025-12-11 04:39:19 -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>,
|
ciphers: List<Cipher>,
|
||||||
): Result<String>
|
): 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.
|
* 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(
|
override suspend fun registerFido2Credential(
|
||||||
request: RegisterFido2CredentialRequest,
|
request: RegisterFido2CredentialRequest,
|
||||||
fido2CredentialStore: Fido2CredentialStore,
|
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")
|
@Suppress("MaxLineLength")
|
||||||
@Test
|
@Test
|
||||||
fun `registerFido2Credential should return attestation response when registration completes`() =
|
fun `registerFido2Credential should return attestation response when registration completes`() =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user