From fc36f95ab73db638f5a41b7dd1ca0601fa5e8edb Mon Sep 17 00:00:00 2001 From: Ramsey Smith <142836716+ramsey-livefront@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:44:11 -0600 Subject: [PATCH] Added key to sync response model and cipher sdk object (#201) --- .../data/vault/datasource/network/model/SyncResponseJson.kt | 3 +++ .../data/vault/repository/util/VaultSdkCipherExtensions.kt | 2 +- .../vault/datasource/network/model/SyncResponseCipherUtil.kt | 1 + .../data/vault/datasource/network/service/SyncServiceTest.kt | 3 ++- .../bitwarden/data/vault/datasource/sdk/VaultSdkCipherUtil.kt | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseJson.kt b/app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseJson.kt index f1cd6798b..487817cf0 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseJson.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseJson.kt @@ -587,6 +587,9 @@ data class SyncResponseJson( @SerialName("card") val card: Card?, + + @SerialName("key") + val key: String?, ) { /** * Represents an attachment in the vault response. diff --git a/app/src/main/java/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt index 18164141a..56ff1f915 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCipherExtensions.kt @@ -40,7 +40,7 @@ fun SyncResponseJson.Cipher.toEncryptedSdkCipher(): Cipher = organizationId = organizationId, folderId = folderId, collectionIds = collectionIds.orEmpty(), - key = null, + key = key, name = name.orEmpty(), notes = notes, type = type.toSdkCipherType(), diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseCipherUtil.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseCipherUtil.kt index 60a85904f..839d89b75 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseCipherUtil.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/model/SyncResponseCipherUtil.kt @@ -29,6 +29,7 @@ fun createMockCipher(number: Int): SyncResponseJson.Cipher = shouldEdit = false, shouldOrganizationUseTotp = false, shouldViewPassword = false, + key = "mockKey-$number", ) /** diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/service/SyncServiceTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/service/SyncServiceTest.kt index 004f9ee8d..910be6ddf 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/service/SyncServiceTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/network/service/SyncServiceTest.kt @@ -299,7 +299,8 @@ private const val SYNC_SUCCESS_JSON = """ "expYear": "mockExpirationYear-1", "cardholderName": "mockCardholderName-1", "brand": "mockBrand-1" - } + }, + "key": "mockKey-1" } ], "domains": { diff --git a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkCipherUtil.kt b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkCipherUtil.kt index 06041c82f..8eaba496b 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkCipherUtil.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/vault/datasource/sdk/VaultSdkCipherUtil.kt @@ -26,7 +26,7 @@ fun createMockSdkCipher(number: Int): Cipher = organizationId = "mockOrganizationId-$number", folderId = "mockFolderId-$number", collectionIds = listOf("mockCollectionId-$number"), - key = null, + key = "mockKey-$number", name = "mockName-$number", notes = "mockNotes-$number", type = CipherType.LOGIN,