diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt index 58d29f7b6..18e1d257c 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepository.kt @@ -221,11 +221,6 @@ interface AuthRepository : AuthenticatorProvider { */ fun setSsoCallbackResult(result: SsoCallbackResult) - /** - * Creates a new authentication request. - */ - suspend fun createAuthRequest(email: String): AuthRequestResult - /** * Creates a new authentication request and then continues to emit updates over time. */ 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 08e707b14..a39af567b 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 @@ -821,41 +821,6 @@ class AuthRepositoryImpl( mutableSsoCallbackResultFlow.tryEmit(result) } - override suspend fun createAuthRequest( - email: String, - ): AuthRequestResult = - authSdkSource - .getNewAuthRequest(email) - .flatMap { authRequest -> - newAuthRequestService - .createAuthRequest( - email = email, - publicKey = authRequest.publicKey, - deviceId = authDiskSource.uniqueAppId, - accessCode = authRequest.accessCode, - fingerprint = authRequest.fingerprint, - ) - .map { request -> - AuthRequest( - id = request.id, - publicKey = request.publicKey, - platform = request.platform, - ipAddress = request.ipAddress, - key = request.key, - masterPasswordHash = request.masterPasswordHash, - creationDate = request.creationDate, - responseDate = request.responseDate, - requestApproved = request.requestApproved ?: false, - originUrl = request.originUrl, - fingerprint = authRequest.fingerprint, - ) - } - } - .fold( - onFailure = { AuthRequestResult.Error }, - onSuccess = { AuthRequestResult.Success(it) }, - ) - @Suppress("LongMethod") override fun createAuthRequestWithUpdates( email: String, 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 2b4da7d1b..cf61bdc6c 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 @@ -2781,94 +2781,6 @@ class AuthRepositoryTest { ) } - @Test - fun `createAuthRequest should return failure when service returns failure`() = runTest { - val accessCode = "accessCode" - val fingerprint = "fingerprint" - coEvery { - newAuthRequestService.createAuthRequest( - email = EMAIL, - publicKey = PUBLIC_KEY, - deviceId = UNIQUE_APP_ID, - accessCode = accessCode, - fingerprint = fingerprint, - ) - } returns Throwable("Fail").asFailure() - - val result = repository.createAuthRequest( - email = EMAIL, - ) - - coVerify(exactly = 1) { - newAuthRequestService.createAuthRequest( - email = EMAIL, - publicKey = PUBLIC_KEY, - deviceId = UNIQUE_APP_ID, - accessCode = accessCode, - fingerprint = fingerprint, - ) - } - assertEquals(AuthRequestResult.Error, result) - } - - @Test - fun `createAuthRequest should return success when service returns success`() = runTest { - val accessCode = "accessCode" - val fingerprint = "fingerprint" - - val responseJson = AuthRequestsResponseJson.AuthRequest( - id = "1", - publicKey = PUBLIC_KEY, - platform = "Android", - ipAddress = "192.168.0.1", - key = "public", - masterPasswordHash = "verySecureHash", - creationDate = ZonedDateTime.parse("2024-09-13T00:00Z"), - responseDate = null, - requestApproved = true, - originUrl = "www.bitwarden.com", - ) - val expected = AuthRequestResult.Success( - authRequest = AuthRequest( - id = "1", - publicKey = PUBLIC_KEY, - platform = "Android", - ipAddress = "192.168.0.1", - key = "public", - masterPasswordHash = "verySecureHash", - creationDate = ZonedDateTime.parse("2024-09-13T00:00Z"), - responseDate = null, - requestApproved = true, - originUrl = "www.bitwarden.com", - fingerprint = fingerprint, - ), - ) - coEvery { - newAuthRequestService.createAuthRequest( - email = EMAIL, - publicKey = PUBLIC_KEY, - deviceId = UNIQUE_APP_ID, - accessCode = accessCode, - fingerprint = fingerprint, - ) - } returns responseJson.asSuccess() - - val result = repository.createAuthRequest( - email = EMAIL, - ) - - coVerify(exactly = 1) { - newAuthRequestService.createAuthRequest( - email = EMAIL, - publicKey = PUBLIC_KEY, - deviceId = UNIQUE_APP_ID, - accessCode = accessCode, - fingerprint = fingerprint, - ) - } - assertEquals(expected, result) - } - @Suppress("MaxLineLength") @Test fun `createAuthRequestWithUpdates with authSdkSource getNewAuthRequest error should emit Error`() =