mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Remove unused function (#926)
This commit is contained in:
parent
debfbc04b0
commit
6e945a4385
3 changed files with 0 additions and 128 deletions
|
@ -221,11 +221,6 @@ interface AuthRepository : AuthenticatorProvider {
|
||||||
*/
|
*/
|
||||||
fun setSsoCallbackResult(result: SsoCallbackResult)
|
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.
|
* Creates a new authentication request and then continues to emit updates over time.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -821,41 +821,6 @@ class AuthRepositoryImpl(
|
||||||
mutableSsoCallbackResultFlow.tryEmit(result)
|
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")
|
@Suppress("LongMethod")
|
||||||
override fun createAuthRequestWithUpdates(
|
override fun createAuthRequestWithUpdates(
|
||||||
email: String,
|
email: String,
|
||||||
|
|
|
@ -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")
|
@Suppress("MaxLineLength")
|
||||||
@Test
|
@Test
|
||||||
fun `createAuthRequestWithUpdates with authSdkSource getNewAuthRequest error should emit Error`() =
|
fun `createAuthRequestWithUpdates with authSdkSource getNewAuthRequest error should emit Error`() =
|
||||||
|
|
Loading…
Reference in a new issue