Skip to content

Commit daec7f4

Browse files
committed
Added UT for the secure credentials manager class
1 parent 38ccea9 commit daec7f4

File tree

2 files changed

+460
-18
lines changed

2 files changed

+460
-18
lines changed

auth0/src/test/java/com/auth0/android/authentication/storage/CredentialsManagerTest.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class CredentialsManagerTest {
6868
private lateinit var ssoCallback: Callback<SSOCredentials, CredentialsManagerException>
6969

7070
@Mock
71-
private lateinit var apiCallback: Callback<APICredentials, CredentialsManagerException>
71+
private lateinit var apiCredentialsCallback: Callback<APICredentials, CredentialsManagerException>
7272

7373
@Mock
7474
private lateinit var jwtDecoder: JWTDecoder
@@ -398,8 +398,8 @@ public class CredentialsManagerTest {
398398
Date(accessTokenExpiry), "scope"
399399
)
400400
Mockito.`when`(storage.retrieveString("audience")).thenReturn(gson.toJson(apiCredentials))
401-
manager.getApiCredentials("audience", "scope", callback = apiCallback)
402-
verify(apiCallback).onSuccess(apiCredentialsCaptor.capture())
401+
manager.getApiCredentials("audience", "scope", callback = apiCredentialsCallback)
402+
verify(apiCredentialsCallback).onSuccess(apiCredentialsCaptor.capture())
403403
val retrievedCredentials = apiCredentialsCaptor.firstValue
404404
MatcherAssert.assertThat(retrievedCredentials, Is.`is`(Matchers.notNullValue()))
405405
Assert.assertEquals(retrievedCredentials.accessToken, apiCredentials.accessToken)
@@ -409,8 +409,8 @@ public class CredentialsManagerTest {
409409
public fun shouldThrowExceptionIfThereISNoRefreshTokenToGetNewApiToken() {
410410
verifyNoMoreInteractions(client)
411411
Mockito.`when`(storage.retrieveString("com.auth0.refresh_token")).thenReturn(null)
412-
manager.getApiCredentials(audience = "audience", callback = apiCallback)
413-
verify(apiCallback).onFailure(exceptionCaptor.capture())
412+
manager.getApiCredentials(audience = "audience", callback = apiCredentialsCallback)
413+
verify(apiCredentialsCallback).onFailure(exceptionCaptor.capture())
414414
val exception = exceptionCaptor.firstValue
415415
MatcherAssert.assertThat(exception, Is.`is`(Matchers.notNullValue()))
416416
MatcherAssert.assertThat(
@@ -437,8 +437,8 @@ public class CredentialsManagerTest {
437437
val renewedCredentials =
438438
Credentials("newId", "newAccess", "newType", newRefresh, newDate, "newScope")
439439
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
440-
manager.getApiCredentials("audience", "newScope", callback = apiCallback)
441-
verify(apiCallback).onSuccess(
440+
manager.getApiCredentials("audience", "newScope", callback = apiCredentialsCallback)
441+
verify(apiCredentialsCallback).onSuccess(
442442
apiCredentialsCaptor.capture()
443443
)
444444

@@ -479,8 +479,8 @@ public class CredentialsManagerTest {
479479
val renewedCredentials =
480480
Credentials("newId", "newAccess", "newType", newRefresh, newDate, "newScope")
481481
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
482-
manager.getApiCredentials("audience", "newScope", callback = apiCallback)
483-
verify(apiCallback).onSuccess(
482+
manager.getApiCredentials("audience", "newScope", callback = apiCredentialsCallback)
483+
verify(apiCredentialsCallback).onSuccess(
484484
apiCredentialsCaptor.capture()
485485
)
486486

@@ -521,8 +521,8 @@ public class CredentialsManagerTest {
521521
val renewedCredentials =
522522
Credentials("newId", "newAccess", "newType", newRefresh, newDate, "newScope")
523523
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
524-
manager.getApiCredentials("audience", "newScope", minTtl = 10, callback = apiCallback)
525-
verify(apiCallback).onSuccess(
524+
manager.getApiCredentials("audience", "newScope", minTtl = 10, callback = apiCredentialsCallback)
525+
verify(apiCredentialsCallback).onSuccess(
526526
apiCredentialsCaptor.capture()
527527
)
528528

@@ -563,8 +563,8 @@ public class CredentialsManagerTest {
563563
val renewedCredentials =
564564
Credentials("newId", "newAccess", "newType", newRefresh, newDate, "newScope")
565565
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
566-
manager.getApiCredentials("audience", "newScope", callback = apiCallback)
567-
verify(apiCallback).onSuccess(
566+
manager.getApiCredentials("audience", "newScope", callback = apiCredentialsCallback)
567+
verify(apiCredentialsCallback).onSuccess(
568568
apiCredentialsCaptor.capture()
569569
)
570570

@@ -599,8 +599,8 @@ public class CredentialsManagerTest {
599599
val renewedCredentials =
600600
Credentials("newId", "newAccess", "newType", "newRefreshToken", newDate, "newScope")
601601
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
602-
manager.getApiCredentials("audience", "newScope", callback = apiCallback)
603-
verify(apiCallback).onSuccess(
602+
manager.getApiCredentials("audience", "newScope", callback = apiCredentialsCallback)
603+
verify(apiCredentialsCallback).onSuccess(
604604
apiCredentialsCaptor.capture()
605605
)
606606

@@ -636,8 +636,8 @@ public class CredentialsManagerTest {
636636
val renewedCredentials =
637637
Credentials("newId", "newAccess", "newType", newRefresh, newDate, "newScope")
638638
Mockito.`when`(request.execute()).thenReturn(renewedCredentials)
639-
manager.getApiCredentials("audience", "newScope", minTtl = 1, callback = apiCallback)
640-
verify(apiCallback).onFailure(
639+
manager.getApiCredentials("audience", "newScope", minTtl = 1, callback = apiCredentialsCallback)
640+
verify(apiCredentialsCallback).onFailure(
641641
exceptionCaptor.capture()
642642
)
643643
val exception = exceptionCaptor.firstValue

0 commit comments

Comments
 (0)