mirror of
https://github.com/bitwarden/android.git
synced 2025-02-16 11:59:57 +03:00
PM-10954: Update the key connector APIs to use the correct url and responses (#3781)
This commit is contained in:
parent
a15b84a5bf
commit
82fd7f01f8
7 changed files with 13 additions and 5 deletions
|
@ -28,6 +28,7 @@ sealed class GetTokenResponseJson {
|
|||
* this token will be cached and used for future auth requests.
|
||||
* @property masterPasswordPolicyOptions The options available for a user's master password.
|
||||
* @property userDecryptionOptions The options available to a user for decryption.
|
||||
* @property keyConnectorUrl URL to the user's key connector.
|
||||
*/
|
||||
@Serializable
|
||||
data class Success(
|
||||
|
@ -75,6 +76,9 @@ sealed class GetTokenResponseJson {
|
|||
|
||||
@SerialName("UserDecryptionOptions")
|
||||
val userDecryptionOptions: UserDecryptionOptionsJson?,
|
||||
|
||||
@SerialName("KeyConnectorUrl")
|
||||
val keyConnectorUrl: String?,
|
||||
) : GetTokenResponseJson()
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
|
|||
*/
|
||||
@Serializable
|
||||
data class KeyConnectorMasterKeyResponseJson(
|
||||
@SerialName("Key") val masterKey: String,
|
||||
@SerialName("key") val masterKey: String,
|
||||
)
|
||||
|
|
|
@ -119,14 +119,14 @@ class AccountsServiceImpl(
|
|||
override suspend fun getMasterKeyFromKeyConnector(
|
||||
url: String,
|
||||
): Result<KeyConnectorMasterKeyResponseJson> =
|
||||
authenticatedKeyConnectorApi.getMasterKeyFromKeyConnector(url = url)
|
||||
authenticatedKeyConnectorApi.getMasterKeyFromKeyConnector(url = "$url/user-keys")
|
||||
|
||||
override suspend fun storeMasterKeyToKeyConnector(
|
||||
url: String,
|
||||
masterKey: String,
|
||||
): Result<Unit> =
|
||||
authenticatedKeyConnectorApi.storeMasterKeyToKeyConnector(
|
||||
url = url,
|
||||
url = "$url/user-keys",
|
||||
body = KeyConnectorMasterKeyRequestJson(masterKey = masterKey),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ class AccountsServiceTest : BaseServiceTest() {
|
|||
@Test
|
||||
fun `getMasterKeyFromKeyConnector with empty response is success`() = runTest {
|
||||
val masterKey = "masterKey"
|
||||
val response = MockResponse().setBody("""{ "Key": "$masterKey" }""")
|
||||
val response = MockResponse().setBody("""{ "key": "$masterKey" }""")
|
||||
server.enqueue(response)
|
||||
val result = service.getMasterKeyFromKeyConnector(url = "$url/test")
|
||||
assertEquals(
|
||||
|
|
|
@ -491,7 +491,8 @@ private const val LOGIN_SUCCESS_JSON = """
|
|||
"KeyConnectorOption": {
|
||||
"KeyConnectorUrl": "keyConnectorUrl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"KeyConnectorUrl": "keyConnectorUrl"
|
||||
}
|
||||
"""
|
||||
|
||||
|
@ -531,6 +532,7 @@ private val LOGIN_SUCCESS = GetTokenResponseJson.Success(
|
|||
keyConnectorUrl = "keyConnectorUrl",
|
||||
),
|
||||
),
|
||||
keyConnectorUrl = "keyConnectorUrl",
|
||||
)
|
||||
|
||||
private const val INVALID_LOGIN_JSON = """
|
||||
|
|
|
@ -5504,6 +5504,7 @@ class AuthRepositoryTest {
|
|||
twoFactorToken = null,
|
||||
masterPasswordPolicyOptions = null,
|
||||
userDecryptionOptions = null,
|
||||
keyConnectorUrl = null,
|
||||
)
|
||||
private val PROFILE_1 = AccountJson.Profile(
|
||||
userId = USER_ID_1,
|
||||
|
|
|
@ -113,6 +113,7 @@ private val GET_TOKEN_RESPONSE_SUCCESS = GetTokenResponseJson.Success(
|
|||
twoFactorToken = null,
|
||||
masterPasswordPolicyOptions = null,
|
||||
userDecryptionOptions = null,
|
||||
keyConnectorUrl = null,
|
||||
)
|
||||
private val USER_DECRYPTION_OPTIONS = UserDecryptionOptionsJson(
|
||||
hasMasterPassword = false,
|
||||
|
|
Loading…
Add table
Reference in a new issue