Update the Bitwarden SDK (#1271)

This commit is contained in:
David Perez 2024-04-15 14:02:38 -05:00 committed by Álison Fernandes
parent 2523239557
commit cec70a9c64
6 changed files with 19 additions and 1 deletions

View file

@ -52,6 +52,7 @@ interface AuthSdkSource {
*/ */
suspend fun makeRegisterTdeKeysAndUnlockVault( suspend fun makeRegisterTdeKeysAndUnlockVault(
userId: String, userId: String,
email: String,
orgPublicKey: String, orgPublicKey: String,
rememberDevice: Boolean, rememberDevice: Boolean,
): Result<RegisterTdeKeyResponse> ): Result<RegisterTdeKeyResponse>

View file

@ -78,12 +78,14 @@ class AuthSdkSourceImpl(
override suspend fun makeRegisterTdeKeysAndUnlockVault( override suspend fun makeRegisterTdeKeysAndUnlockVault(
userId: String, userId: String,
email: String,
orgPublicKey: String, orgPublicKey: String,
rememberDevice: Boolean, rememberDevice: Boolean,
): Result<RegisterTdeKeyResponse> = runCatching { ): Result<RegisterTdeKeyResponse> = runCatching {
getClient(userId = userId) getClient(userId = userId)
.auth() .auth()
.makeRegisterTdeKeys( .makeRegisterTdeKeys(
email = email,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = rememberDevice, rememberDevice = rememberDevice,
) )

View file

@ -367,6 +367,7 @@ class AuthRepositoryImpl(
.flatMap { organizationKeys -> .flatMap { organizationKeys ->
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = userId, userId = userId,
email = account.profile.email,
orgPublicKey = organizationKeys.publicKey, orgPublicKey = organizationKeys.publicKey,
rememberDevice = authDiskSource.shouldTrustDevice, rememberDevice = authDiskSource.shouldTrustDevice,
) )

View file

@ -163,12 +163,14 @@ class AuthSdkSourceTest {
fun `makeRegisterTdeKeysAndUnlockVault should call SDK and return a Result with the correct data`() = fun `makeRegisterTdeKeysAndUnlockVault should call SDK and return a Result with the correct data`() =
runBlocking { runBlocking {
val userId = "userId" val userId = "userId"
val email = "email"
val orgPublicKey = "orgPublicKey" val orgPublicKey = "orgPublicKey"
val rememberDevice = true val rememberDevice = true
val expectedResult = mockk<RegisterTdeKeyResponse>() val expectedResult = mockk<RegisterTdeKeyResponse>()
coEvery { sdkClientManager.getOrCreateClient(userId = userId) } returns client coEvery { sdkClientManager.getOrCreateClient(userId = userId) } returns client
coEvery { coEvery {
clientAuth.makeRegisterTdeKeys( clientAuth.makeRegisterTdeKeys(
email = email,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = rememberDevice, rememberDevice = rememberDevice,
) )
@ -176,12 +178,14 @@ class AuthSdkSourceTest {
val result = authSkdSource.makeRegisterTdeKeysAndUnlockVault( val result = authSkdSource.makeRegisterTdeKeysAndUnlockVault(
userId = userId, userId = userId,
email = email,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = rememberDevice, rememberDevice = rememberDevice,
) )
assertEquals(expectedResult.asSuccess(), result) assertEquals(expectedResult.asSuccess(), result)
coVerify(exactly = 1) { coVerify(exactly = 1) {
clientAuth.makeRegisterTdeKeys( clientAuth.makeRegisterTdeKeys(
email = email,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = rememberDevice, rememberDevice = rememberDevice,
) )

View file

@ -823,6 +823,7 @@ class AuthRepositoryTest {
coEvery { coEvery {
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -836,6 +837,7 @@ class AuthRepositoryTest {
organizationService.getOrganizationKeys(orgId) organizationService.getOrganizationKeys(orgId)
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -877,6 +879,7 @@ class AuthRepositoryTest {
coEvery { coEvery {
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -896,6 +899,7 @@ class AuthRepositoryTest {
organizationService.getOrganizationKeys(orgId) organizationService.getOrganizationKeys(orgId)
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -941,6 +945,7 @@ class AuthRepositoryTest {
coEvery { coEvery {
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -968,6 +973,7 @@ class AuthRepositoryTest {
organizationService.getOrganizationKeys(orgId) organizationService.getOrganizationKeys(orgId)
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -1021,6 +1027,7 @@ class AuthRepositoryTest {
coEvery { coEvery {
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -1050,6 +1057,7 @@ class AuthRepositoryTest {
organizationService.getOrganizationKeys(orgId) organizationService.getOrganizationKeys(orgId)
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -1104,6 +1112,7 @@ class AuthRepositoryTest {
coEvery { coEvery {
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )
@ -1139,6 +1148,7 @@ class AuthRepositoryTest {
organizationService.getOrganizationKeys(orgId) organizationService.getOrganizationKeys(orgId)
authSdkSource.makeRegisterTdeKeysAndUnlockVault( authSdkSource.makeRegisterTdeKeysAndUnlockVault(
userId = USER_ID_1, userId = USER_ID_1,
email = EMAIL,
orgPublicKey = orgPublicKey, orgPublicKey = orgPublicKey,
rememberDevice = shouldTrustDevice, rememberDevice = shouldTrustDevice,
) )

View file

@ -23,7 +23,7 @@ androidxSplash = "1.1.0-rc01"
androidXAppCompat = "1.6.1" androidXAppCompat = "1.6.1"
androdixAutofill = "1.1.0" androdixAutofill = "1.1.0"
androidxWork = "2.9.0" androidxWork = "2.9.0"
bitwardenSdk = "0.4.0-20240412.113052-206" bitwardenSdk = "0.4.0-20240415.150112-210"
crashlytics = "2.9.9" crashlytics = "2.9.9"
detekt = "1.23.6" detekt = "1.23.6"
firebaseBom = "32.8.1" firebaseBom = "32.8.1"