diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index 36596352d..7942cdb6c 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -157,14 +157,11 @@ class AuthRepositoryImpl @Inject constructor( if (shouldCheckDataBreaches) { haveIBeenPwnedService .hasPasswordBeenBreached(password = masterPassword) - .fold( - onFailure = { return RegisterResult.Error(null) }, - onSuccess = { foundDataBreaches -> - if (foundDataBreaches) { - return RegisterResult.DataBreachFound - } - }, - ) + .onSuccess { foundDataBreaches -> + if (foundDataBreaches) { + return RegisterResult.DataBreachFound + } + } } val kdf = Kdf.Pbkdf2(DEFAULT_KDF_ITERATIONS.toUInt()) return authSdkSource diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index ed6baa328..cec71ad4f 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -235,10 +235,27 @@ class AuthRepositoryTest { } @Test - fun `register check data breaches error should return Error`() = runTest { + fun `register check data breaches error should still return register success`() = runTest { coEvery { haveIBeenPwnedService.hasPasswordBeenBreached(PASSWORD) } 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( email = EMAIL, @@ -247,7 +264,7 @@ class AuthRepositoryTest { captchaToken = null, shouldCheckDataBreaches = true, ) - assertEquals(RegisterResult.Error(null), result) + assertEquals(RegisterResult.Success(CAPTCHA_KEY), result) } @Test