Skip to content

Commit

Permalink
Renamed server error to api error to indicate general api error types
Browse files Browse the repository at this point in the history
  • Loading branch information
pmathew92 committed Dec 4, 2024
1 parent 9395de6 commit 0c6d236
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
error.isRefreshTokenDeleted ||
error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED
error.isNetworkError -> CredentialsManagerException.Code.NO_NETWORK
else -> CredentialsManagerException.Code.SERVER_ERROR
else -> CredentialsManagerException.Code.API_ERROR
}
callback.onFailure(
CredentialsManagerException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CredentialsManagerException :
BIOMETRICS_INVALID_USER,
BIOMETRIC_AUTHENTICATION_FAILED,
NO_NETWORK,
SERVER_ERROR
API_ERROR
}

private var code: Code?
Expand Down Expand Up @@ -140,8 +140,8 @@ public class CredentialsManagerException :
//Exceptions thrown when making api calls for access token renewal
public val NO_NETWORK: CredentialsManagerException =
CredentialsManagerException(Code.NO_NETWORK)
public val SERVER_ERROR: CredentialsManagerException =
CredentialsManagerException(Code.SERVER_ERROR)
public val API_ERROR: CredentialsManagerException =
CredentialsManagerException(Code.API_ERROR)


private fun getMessage(code: Code): String {
Expand Down Expand Up @@ -186,7 +186,7 @@ public class CredentialsManagerException :
Code.BIOMETRICS_INVALID_USER -> "The user didn't pass the authentication challenge."
Code.BIOMETRIC_AUTHENTICATION_FAILED -> "Biometric authentication failed."
Code.NO_NETWORK -> "Failed to execute the network request."
Code.SERVER_ERROR -> "An error occurred when trying to authenticate with the server."
Code.API_ERROR -> "An error occurred while processing the request."
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
error.isRefreshTokenDeleted ||
error.isInvalidRefreshToken -> CredentialsManagerException.Code.RENEW_FAILED
error.isNetworkError -> CredentialsManagerException.Code.NO_NETWORK
else -> CredentialsManagerException.Code.SERVER_ERROR
else -> CredentialsManagerException.Code.API_ERROR
}
callback.onFailure(
CredentialsManagerException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public class CredentialsManagerTest {
}

@Test
public fun shouldGetAndFailToRenewExpiredCredentialsWhenServerErrorOccurs() {
public fun shouldGetAndFailToRenewExpiredCredentialsWhenApiErrorOccurs() {
Mockito.`when`(storage.retrieveString("com.auth0.id_token")).thenReturn("idToken")
Mockito.`when`(storage.retrieveString("com.auth0.access_token")).thenReturn("accessToken")
Mockito.`when`(storage.retrieveString("com.auth0.refresh_token")).thenReturn("refreshToken")
Expand Down Expand Up @@ -950,7 +950,7 @@ public class CredentialsManagerTest {
MatcherAssert.assertThat(exception.cause, Is.`is`(authenticationException))
MatcherAssert.assertThat(
exception.message,
Is.`is`("An error occurred when trying to authenticate with the server.")
Is.`is`("An error occurred while processing the request.")
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ public class SecureCredentialsManagerTest {
}

@Test
public fun shouldGetAndFailToRenewExpiredCredentialsWhenServerErrorOccurs() {
public fun shouldGetAndFailToRenewExpiredCredentialsWhenApiErrorOccurs() {
Mockito.`when`(localAuthenticationManager.authenticate()).then {
localAuthenticationManager.resultCallback.onSuccess(true)
}
Expand Down Expand Up @@ -1406,7 +1406,7 @@ public class SecureCredentialsManagerTest {
MatcherAssert.assertThat(exception.cause, Is.`is`(authenticationException))
MatcherAssert.assertThat(
exception.message,
Is.`is`("An error occurred when trying to authenticate with the server.")
Is.`is`("An error occurred while processing the request.")
)
}

Expand Down

0 comments on commit 0c6d236

Please sign in to comment.