mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 12:30:00 +03:00
BIT-945 Continue with registration if HIBP call fails (#158)
This commit is contained in:
parent
bb2b0e8cd1
commit
8295a47e3d
2 changed files with 24 additions and 10 deletions
|
@ -157,14 +157,11 @@ class AuthRepositoryImpl @Inject constructor(
|
||||||
if (shouldCheckDataBreaches) {
|
if (shouldCheckDataBreaches) {
|
||||||
haveIBeenPwnedService
|
haveIBeenPwnedService
|
||||||
.hasPasswordBeenBreached(password = masterPassword)
|
.hasPasswordBeenBreached(password = masterPassword)
|
||||||
.fold(
|
.onSuccess { foundDataBreaches ->
|
||||||
onFailure = { return RegisterResult.Error(null) },
|
if (foundDataBreaches) {
|
||||||
onSuccess = { foundDataBreaches ->
|
return RegisterResult.DataBreachFound
|
||||||
if (foundDataBreaches) {
|
}
|
||||||
return RegisterResult.DataBreachFound
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
val kdf = Kdf.Pbkdf2(DEFAULT_KDF_ITERATIONS.toUInt())
|
val kdf = Kdf.Pbkdf2(DEFAULT_KDF_ITERATIONS.toUInt())
|
||||||
return authSdkSource
|
return authSdkSource
|
||||||
|
|
|
@ -235,10 +235,27 @@ class AuthRepositoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `register check data breaches error should return Error`() = runTest {
|
fun `register check data breaches error should still return register success`() = runTest {
|
||||||
coEvery {
|
coEvery {
|
||||||
haveIBeenPwnedService.hasPasswordBeenBreached(PASSWORD)
|
haveIBeenPwnedService.hasPasswordBeenBreached(PASSWORD)
|
||||||
} returns Result.failure(Throwable())
|
} returns Result.failure(Throwable())
|
||||||
|
coEvery {
|
||||||
|
accountsService.register(
|
||||||
|
body = RegisterRequestJson(
|
||||||
|
email = EMAIL,
|
||||||
|
masterPasswordHash = PASSWORD_HASH,
|
||||||
|
masterPasswordHint = null,
|
||||||
|
captchaResponse = null,
|
||||||
|
key = ENCRYPTED_USER_KEY,
|
||||||
|
keys = RegisterRequestJson.Keys(
|
||||||
|
publicKey = PUBLIC_KEY,
|
||||||
|
encryptedPrivateKey = PRIVATE_KEY,
|
||||||
|
),
|
||||||
|
kdfType = PBKDF2_SHA256,
|
||||||
|
kdfIterations = DEFAULT_KDF_ITERATIONS.toUInt(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} returns Result.success(RegisterResponseJson.Success(captchaBypassToken = CAPTCHA_KEY))
|
||||||
|
|
||||||
val result = repository.register(
|
val result = repository.register(
|
||||||
email = EMAIL,
|
email = EMAIL,
|
||||||
|
@ -247,7 +264,7 @@ class AuthRepositoryTest {
|
||||||
captchaToken = null,
|
captchaToken = null,
|
||||||
shouldCheckDataBreaches = true,
|
shouldCheckDataBreaches = true,
|
||||||
)
|
)
|
||||||
assertEquals(RegisterResult.Error(null), result)
|
assertEquals(RegisterResult.Success(CAPTCHA_KEY), result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Reference in a new issue