diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v0/user/client/ClientApiV0Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v0/user/client/ClientApiV0Test.kt index dd3280dde52..574ef891390 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v0/user/client/ClientApiV0Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v0/user/client/ClientApiV0Test.kt @@ -24,9 +24,9 @@ import com.wire.kalium.mocks.responses.ClientResponseJson import com.wire.kalium.mocks.responses.RegisterClientRequestJson import com.wire.kalium.mocks.responses.RegisterTokenJson import com.wire.kalium.mocks.responses.UpdateClientRequestJson -import com.wire.kalium.network.api.base.authenticated.client.ClientApi import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO import com.wire.kalium.network.api.authenticated.client.UpdateClientCapabilitiesRequest +import com.wire.kalium.network.api.base.authenticated.client.ClientApi import com.wire.kalium.network.api.v0.authenticated.ClientApiV0 import com.wire.kalium.network.exceptions.KaliumException import com.wire.kalium.network.utils.NetworkResponse @@ -58,7 +58,26 @@ internal class ClientApiV0Test : ApiTest() { val clientApi: ClientApi = ClientApiV0(networkClient) val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData) assertTrue(response.isSuccessful()) - assertEquals(response.value, VALID_REGISTER_CLIENT_RESPONSE.serializableData) + assertEquals(VALID_REGISTER_CLIENT_RESPONSE.serializableData, response.value) + } + + @Test + fun givenAValidRegisterClientRequest_whenCallingTheRegisterClientEndpointWithOldFormat_theRequestShouldBeConfiguredCorrectly() = + runTest { + val networkClient = mockAuthenticatedNetworkClient( + VALID_REGISTER_CLIENT_OLD_RESPONSE.rawJson, + statusCode = HttpStatusCode.Created, + assertion = { + assertPost() + assertJson() + assertNoQueryParams() + assertPathEqual(PATH_CLIENTS) + } + ) + val clientApi: ClientApi = ClientApiV0(networkClient) + val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData) + assertTrue(response.isSuccessful()) + assertEquals(VALID_REGISTER_CLIENT_OLD_RESPONSE.serializableData, response.value) } @Test @@ -93,6 +112,7 @@ internal class ClientApiV0Test : ApiTest() { assertTrue(response.isSuccessful()) } + @Test fun givenAValidUpdateClientCapabilitiesRequest_whenCallingTheUpdateClientEndpoint_theRequestShouldBeConfiguredCorrectly() = runTest { @@ -172,6 +192,7 @@ internal class ClientApiV0Test : ApiTest() { const val PATH_CLIENTS = "/clients" val REGISTER_CLIENT_REQUEST = RegisterClientRequestJson.valid val VALID_REGISTER_CLIENT_RESPONSE = ClientResponseJson.valid + val VALID_REGISTER_CLIENT_OLD_RESPONSE = ClientResponseJson.validCapabilitiesObject val UPDATE_CLIENT_REQUEST = UpdateClientRequestJson.valid val ERROR_RESPONSE = ErrorResponseJson.valid.serializableData val VALID_PUSH_TOKEN_REQUEST = RegisterTokenJson.validPushTokenRequest