From 0c6d236b9bc9075db71f7b528e2d3148b25c3842 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Wed, 4 Dec 2024 11:00:49 +0530 Subject: [PATCH] Renamed server error to api error to indicate general api error types --- .../android/authentication/storage/CredentialsManager.kt | 2 +- .../authentication/storage/CredentialsManagerException.kt | 8 ++++---- .../authentication/storage/SecureCredentialsManager.kt | 2 +- .../authentication/storage/CredentialsManagerTest.kt | 4 ++-- .../storage/SecureCredentialsManagerTest.kt | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt b/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt index 5d494f5e..3346a7ca 100644 --- a/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt +++ b/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt @@ -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( diff --git a/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt b/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt index 9212546c..4367b9c0 100644 --- a/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt +++ b/auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt @@ -44,7 +44,7 @@ public class CredentialsManagerException : BIOMETRICS_INVALID_USER, BIOMETRIC_AUTHENTICATION_FAILED, NO_NETWORK, - SERVER_ERROR + API_ERROR } private var code: Code? @@ -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 { @@ -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." } } } diff --git a/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt b/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt index 37dd2311..22727cd6 100644 --- a/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt +++ b/auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt @@ -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( diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt index 3169c653..2d236218 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt @@ -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") @@ -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.") ) } diff --git a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.kt b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.kt index 54414e29..f4d8f719 100644 --- a/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.kt +++ b/auth0/src/test/java/com/auth0/android/authentication/storage/SecureCredentialsManagerTest.kt @@ -1375,7 +1375,7 @@ public class SecureCredentialsManagerTest { } @Test - public fun shouldGetAndFailToRenewExpiredCredentialsWhenServerErrorOccurs() { + public fun shouldGetAndFailToRenewExpiredCredentialsWhenApiErrorOccurs() { Mockito.`when`(localAuthenticationManager.authenticate()).then { localAuthenticationManager.resultCallback.onSuccess(true) } @@ -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.") ) }