PM-10954: Update the key connector APIs to use the correct url and responses (#3781)

This commit is contained in:
David Perez 2024-08-19 15:12:09 -05:00 committed by GitHub
parent a15b84a5bf
commit 82fd7f01f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 13 additions and 5 deletions

View file

@ -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()
/**

View file

@ -8,5 +8,5 @@ import kotlinx.serialization.Serializable
*/
@Serializable
data class KeyConnectorMasterKeyResponseJson(
@SerialName("Key") val masterKey: String,
@SerialName("key") val masterKey: String,
)

View file

@ -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),
)
}

View file

@ -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(

View file

@ -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 = """

View file

@ -5504,6 +5504,7 @@ class AuthRepositoryTest {
twoFactorToken = null,
masterPasswordPolicyOptions = null,
userDecryptionOptions = null,
keyConnectorUrl = null,
)
private val PROFILE_1 = AccountJson.Profile(
userId = USER_ID_1,

View file

@ -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,