mirror of
https://github.com/bitwarden/android.git
synced 2026-11-09 10:34:18 -06:00
Update SDK to 3.0.0-8427-16db8e99 (#7284)
Co-authored-by: bw-ghapp[bot] <178206702+bw-ghapp[bot]@users.noreply.github.com> Co-authored-by: Andre Rosado <arosado@bitwarden.com>
This commit is contained in:
co-authored by
bw-ghapp[bot] <178206702+bw-ghapp[bot]@users.noreply.github.com>
Andre Rosado
parent
9887838c5a
commit
f5a96ebfd8
@@ -450,10 +450,10 @@ interface VaultSdkSource {
|
||||
/**
|
||||
* 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.
|
||||
* @return Result of the import. If successful, a list of [EncryptionContext]s for the ciphers
|
||||
* deciphered from the CXF payload.
|
||||
*/
|
||||
suspend fun importCxf(userId: String, payload: String): Result<List<Cipher>>
|
||||
suspend fun importCxf(userId: String, payload: String): Result<List<EncryptionContext>>
|
||||
|
||||
/**
|
||||
* Register a new FIDO 2 credential to a cipher.
|
||||
|
||||
+1
-1
@@ -565,7 +565,7 @@ class VaultSdkSourceImpl(
|
||||
override suspend fun importCxf(
|
||||
userId: String,
|
||||
payload: String,
|
||||
): Result<List<Cipher>> = runCatchingWithLogs {
|
||||
): Result<List<EncryptionContext>> = runCatchingWithLogs {
|
||||
getClient(userId = userId)
|
||||
.exporters()
|
||||
.importCxf(payload = payload)
|
||||
|
||||
+5
-6
@@ -9,8 +9,8 @@ import com.bitwarden.cxf.parser.CredentialExchangePayloadParser
|
||||
import com.bitwarden.network.model.ImportCiphersJsonRequest
|
||||
import com.bitwarden.network.model.ImportCiphersResponseJson
|
||||
import com.bitwarden.network.service.CiphersService
|
||||
import com.bitwarden.vault.Cipher
|
||||
import com.bitwarden.vault.CipherType
|
||||
import com.bitwarden.vault.EncryptionContext
|
||||
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
|
||||
import com.x8bit.bitwarden.data.platform.manager.util.hasRestrictItemTypes
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.VaultSdkSource
|
||||
@@ -63,7 +63,7 @@ class CredentialExchangeImportManagerImpl(
|
||||
|
||||
// Filter out card ciphers if RESTRICT_ITEM_TYPES policy is active
|
||||
val filteredCipherList = if (policyManager.hasRestrictItemTypes()) {
|
||||
allCiphers.filter { cipher -> cipher.type != CipherType.CARD }
|
||||
allCiphers.filter { context -> context.cipher.type != CipherType.CARD }
|
||||
} else {
|
||||
allCiphers
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class CredentialExchangeImportManagerImpl(
|
||||
return ImportCxfPayloadResult.NoItems
|
||||
}
|
||||
|
||||
return uploadCiphers(userId = userId, ciphers = filteredCipherList)
|
||||
return uploadCiphers(ciphers = filteredCipherList)
|
||||
.map { syncVault(it) }
|
||||
.fold(
|
||||
onSuccess = { it },
|
||||
@@ -81,11 +81,10 @@ class CredentialExchangeImportManagerImpl(
|
||||
}
|
||||
|
||||
private suspend fun uploadCiphers(
|
||||
userId: String,
|
||||
ciphers: List<Cipher>,
|
||||
ciphers: List<EncryptionContext>,
|
||||
): Result<ImportCxfPayloadResult.Success> {
|
||||
val request = ImportCiphersJsonRequest(
|
||||
ciphers = ciphers.map { it.toEncryptedNetworkCipher(encryptedFor = userId) },
|
||||
ciphers = ciphers.map { it.toEncryptedNetworkCipher() },
|
||||
folders = emptyList(),
|
||||
folderRelationships = emptyList(),
|
||||
)
|
||||
|
||||
+2
-1
@@ -63,6 +63,7 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.Fido2CredentialSearch
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.InitializeCryptoResult
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.RegisterFido2CredentialRequest
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockCipherView
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockEncryptionContext
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkCipher
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkFolder
|
||||
import io.mockk.coEvery
|
||||
@@ -1312,7 +1313,7 @@ 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 expected = listOf(createMockEncryptionContext(number = 1))
|
||||
val cxf = "cxf"
|
||||
|
||||
coEvery {
|
||||
|
||||
+36
-20
@@ -10,9 +10,10 @@ import com.bitwarden.network.model.ImportCiphersJsonRequest
|
||||
import com.bitwarden.network.model.ImportCiphersResponseJson
|
||||
import com.bitwarden.network.service.CiphersService
|
||||
import com.bitwarden.policies.PolicyType
|
||||
import com.bitwarden.vault.Cipher
|
||||
import com.bitwarden.vault.EncryptionContext
|
||||
import com.x8bit.bitwarden.data.platform.manager.PolicyManager
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.VaultSdkSource
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockEncryptionContext
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockPolicyView
|
||||
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSdkCipher
|
||||
import com.x8bit.bitwarden.data.vault.manager.model.ImportCxfPayloadResult
|
||||
@@ -227,7 +228,7 @@ class CredentialExchangeImportManagerTest {
|
||||
userId = DEFAULT_USER_ID,
|
||||
payload = DEFAULT_ACCOUNT_JSON,
|
||||
)
|
||||
} returns emptyList<Cipher>().asSuccess()
|
||||
} returns emptyList<EncryptionContext>().asSuccess()
|
||||
coEvery {
|
||||
ciphersService.importCiphers(any())
|
||||
} just awaits
|
||||
@@ -253,8 +254,8 @@ class CredentialExchangeImportManagerTest {
|
||||
accountsJsonList = listOf(DEFAULT_ACCOUNT_JSON, DEFAULT_ACCOUNT_JSON_2),
|
||||
)
|
||||
|
||||
val cipher1 = createMockSdkCipher(number = 1)
|
||||
val cipher2 = createMockSdkCipher(number = 2)
|
||||
val cipher1 = createMockEncryptionContext(number = 1)
|
||||
val cipher2 = createMockEncryptionContext(number = 2)
|
||||
coEvery {
|
||||
vaultSdkSource.importCxf(
|
||||
userId = DEFAULT_USER_ID,
|
||||
@@ -303,7 +304,7 @@ class CredentialExchangeImportManagerTest {
|
||||
userId = DEFAULT_USER_ID,
|
||||
payload = DEFAULT_ACCOUNT_JSON,
|
||||
)
|
||||
} returns listOf(createMockSdkCipher(number = 1)).asSuccess()
|
||||
} returns listOf(createMockEncryptionContext(number = 1)).asSuccess()
|
||||
|
||||
val exception = RuntimeException("SDK import failed on second account")
|
||||
coEvery {
|
||||
@@ -346,9 +347,12 @@ class CredentialExchangeImportManagerTest {
|
||||
),
|
||||
)
|
||||
|
||||
val loginCipher = createMockSdkCipher(number = 1)
|
||||
val cardCipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
val loginCipher = createMockEncryptionContext(number = 1)
|
||||
val cardCipher = createMockEncryptionContext(
|
||||
number = 2,
|
||||
cipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
),
|
||||
)
|
||||
val mixedCipherList = listOf(loginCipher, cardCipher)
|
||||
|
||||
@@ -387,9 +391,12 @@ class CredentialExchangeImportManagerTest {
|
||||
policyManager.getActivePolicies(PolicyType.RESTRICTED_ITEM_TYPES)
|
||||
} returns emptyList()
|
||||
|
||||
val loginCipher = createMockSdkCipher(number = 1)
|
||||
val cardCipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
val loginCipher = createMockEncryptionContext(number = 1)
|
||||
val cardCipher = createMockEncryptionContext(
|
||||
number = 2,
|
||||
cipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
),
|
||||
)
|
||||
val mixedCipherList = listOf(loginCipher, cardCipher)
|
||||
|
||||
@@ -435,9 +442,12 @@ class CredentialExchangeImportManagerTest {
|
||||
),
|
||||
)
|
||||
|
||||
val loginCipher = createMockSdkCipher(number = 1)
|
||||
val cardCipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
val loginCipher = createMockEncryptionContext(number = 1)
|
||||
val cardCipher = createMockEncryptionContext(
|
||||
number = 2,
|
||||
cipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
),
|
||||
)
|
||||
val mixedCipherList = listOf(loginCipher, cardCipher)
|
||||
|
||||
@@ -483,11 +493,17 @@ class CredentialExchangeImportManagerTest {
|
||||
),
|
||||
)
|
||||
|
||||
val cardCipher1 = createMockSdkCipher(number = 1).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
val cardCipher1 = createMockEncryptionContext(
|
||||
number = 1,
|
||||
cipher = createMockSdkCipher(number = 1).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
),
|
||||
)
|
||||
val cardCipher2 = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
val cardCipher2 = createMockEncryptionContext(
|
||||
number = 2,
|
||||
cipher = createMockSdkCipher(number = 2).copy(
|
||||
type = com.bitwarden.vault.CipherType.CARD,
|
||||
),
|
||||
)
|
||||
val allCardsList = listOf(cardCipher1, cardCipher2)
|
||||
|
||||
@@ -514,8 +530,8 @@ class CredentialExchangeImportManagerTest {
|
||||
|
||||
private const val DEFAULT_USER_ID = "mockId-1"
|
||||
private const val DEFAULT_PAYLOAD = "mockPayload-1"
|
||||
private val DEFAULT_CIPHER: Cipher = createMockSdkCipher(number = 1)
|
||||
private val DEFAULT_CIPHER_LIST: List<Cipher> = listOf(DEFAULT_CIPHER)
|
||||
private val DEFAULT_CIPHER: EncryptionContext = createMockEncryptionContext(number = 1)
|
||||
private val DEFAULT_CIPHER_LIST: List<EncryptionContext> = listOf(DEFAULT_CIPHER)
|
||||
|
||||
private val DEFAULT_ACCOUNT_JSON = """
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ androidxRoom = "2.8.4"
|
||||
androidxSecurityCrypto = "1.1.0"
|
||||
androidxSplash = "1.2.0"
|
||||
androidxWork = "2.11.2"
|
||||
bitwardenSdk = "3.0.0-8379-cc7daf10"
|
||||
bitwardenSdk = "3.0.0-8427-16db8e99"
|
||||
crashlytics = "3.0.7"
|
||||
detekt = "1.23.8"
|
||||
firebaseBom = "34.15.0"
|
||||
|
||||
Reference in New Issue
Block a user