Add the setPassword API (#1110)

This commit is contained in:
David Perez
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent f0a988c010
commit 932bc3957f
5 changed files with 91 additions and 0 deletions
@@ -9,6 +9,7 @@ import com.x8bit.bitwarden.data.auth.datasource.network.model.RegisterRequestJso
import com.x8bit.bitwarden.data.auth.datasource.network.model.RegisterResponseJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.ResendEmailRequestJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.ResetPasswordRequestJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.SetPasswordRequestJson
import com.x8bit.bitwarden.data.platform.base.BaseServiceTest
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
@@ -258,6 +259,29 @@ class AccountsServiceTest : BaseServiceTest() {
assertTrue(result.isSuccess)
}
@Test
fun `setPassword with empty response is success`() = runTest {
val response = MockResponse().setBody("")
server.enqueue(response)
val result = service.setPassword(
body = SetPasswordRequestJson(
passwordHash = "passwordHash",
passwordHint = "passwordHint",
organizationIdentifier = "organizationId",
kdfIterations = 7,
kdfMemory = 1,
kdfParallelism = 2,
kdfType = null,
key = "encryptedUserKey",
keys = RegisterRequestJson.Keys(
publicKey = "public",
encryptedPrivateKey = "private",
),
),
)
assertTrue(result.isSuccess)
}
companion object {
private const val EMAIL = "email"
private val registerRequestBody = RegisterRequestJson(