@@ -489,7 +489,7 @@ public void testGetAuthToken_fidDoesNotExist_successful() throws Exception {
489
489
when (mockUtils .isAuthTokenExpired (REGISTERED_INSTALLATION_ENTRY )).thenReturn (/*isValid*/ false );
490
490
FirebaseInstallations firebaseInstallations = getFirebaseInstallations ();
491
491
492
- Tasks .await (firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
492
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
493
493
494
494
PersistedInstallationEntry entryValue =
495
495
persistedInstallation .readPersistedInstallationEntryValue ();
@@ -510,8 +510,7 @@ public void testGetAuthToken_PersistedInstallationError_failure() throws Excepti
510
510
511
511
// Expect exception
512
512
try {
513
- Tasks .await (
514
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
513
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
515
514
fail ("Could not update local storage." );
516
515
} catch (ExecutionException expected ) {
517
516
assertWithMessage ("Exception class doesn't match" )
@@ -540,8 +539,7 @@ public void testGetAuthToken_fidExists_successful() throws Exception {
540
539
mockIidStore );
541
540
542
541
InstallationTokenResult installationTokenResult =
543
- Tasks .await (
544
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
542
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
545
543
546
544
assertWithMessage ("Persisted Auth Token doesn't match" )
547
545
.that (installationTokenResult .getToken ())
@@ -551,16 +549,15 @@ public void testGetAuthToken_fidExists_successful() throws Exception {
551
549
}
552
550
553
551
@ Test
554
- public void testGetAuthToken_expiredAuthToken_fetchedNewTokenFromFIS () throws Exception {
552
+ public void testGetToken_expiredAuthToken_fetchedNewTokenFromFIS () throws Exception {
555
553
persistedInstallation .insertOrUpdatePersistedInstallationEntry (EXPIRED_AUTH_TOKEN_ENTRY );
556
554
when (mockUtils .isAuthTokenExpired (EXPIRED_AUTH_TOKEN_ENTRY )).thenReturn (/*isExpired*/ true );
557
555
when (mockUtils .isAuthTokenExpired (UPDATED_AUTH_TOKEN_ENTRY )).thenReturn (/*isValid*/ false );
558
556
559
557
FirebaseInstallations firebaseInstallations = getFirebaseInstallations ();
560
558
561
559
InstallationTokenResult installationTokenResult =
562
- Tasks .await (
563
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
560
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
564
561
565
562
assertWithMessage ("Persisted Auth Token doesn't match" )
566
563
.that (installationTokenResult .getToken ())
@@ -570,17 +567,16 @@ public void testGetAuthToken_expiredAuthToken_fetchedNewTokenFromFIS() throws Ex
570
567
}
571
568
572
569
@ Test
573
- public void testGetAuthToken_unregisteredFid_fetchedNewTokenFromFIS () throws Exception {
574
- // Update local storage with a unregistered installation entry to validate that getAuthToken
570
+ public void testGetToken_unregisteredFid_fetchedNewTokenFromFIS () throws Exception {
571
+ // Update local storage with a unregistered installation entry to validate that getToken
575
572
// calls getId to ensure FID registration and returns a valid auth token.
576
573
persistedInstallation .insertOrUpdatePersistedInstallationEntry (UNREGISTERED_INSTALLATION_ENTRY );
577
574
when (mockUtils .isAuthTokenExpired (REGISTERED_INSTALLATION_ENTRY )).thenReturn (/*isValid*/ false );
578
575
579
576
FirebaseInstallations firebaseInstallations = getFirebaseInstallations ();
580
577
581
578
InstallationTokenResult installationTokenResult =
582
- Tasks .await (
583
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
579
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH ));
584
580
585
581
assertWithMessage ("Persisted Auth Token doesn't match" )
586
582
.that (installationTokenResult .getToken ())
@@ -590,7 +586,7 @@ public void testGetAuthToken_unregisteredFid_fetchedNewTokenFromFIS() throws Exc
590
586
}
591
587
592
588
@ Test
593
- public void testGetAuthToken_fidError_persistedInstallationCleared () throws Exception {
589
+ public void testGetToken_fidError_persistedInstallationCleared () throws Exception {
594
590
// Update local storage with an expired installation entry to ensure that generate auth token
595
591
// is called.
596
592
persistedInstallation .insertOrUpdatePersistedInstallationEntry (EXPIRED_AUTH_TOKEN_ENTRY );
@@ -606,8 +602,8 @@ public void testGetAuthToken_fidError_persistedInstallationCleared() throws Exce
606
602
607
603
// Expect exception
608
604
try {
609
- Tasks .await (firebaseInstallations .getAuthToken (FirebaseInstallationsApi .FORCE_REFRESH ));
610
- fail ("getAuthToken () failed due to Server Error." );
605
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .FORCE_REFRESH ));
606
+ fail ("getToken () failed due to Server Error." );
611
607
} catch (ExecutionException expected ) {
612
608
assertWithMessage ("Exception class doesn't match" )
613
609
.that (expected )
@@ -626,7 +622,7 @@ public void testGetAuthToken_fidError_persistedInstallationCleared() throws Exce
626
622
}
627
623
628
624
@ Test
629
- public void testGetAuthToken_serverError_failure () throws Exception {
625
+ public void testGetToken_serverError_failure () throws Exception {
630
626
when (mockPersistedInstallation .readPersistedInstallationEntryValue ())
631
627
.thenReturn (REGISTERED_INSTALLATION_ENTRY );
632
628
when (backendClientReturnsError .generateAuthToken (
@@ -645,8 +641,8 @@ public void testGetAuthToken_serverError_failure() throws Exception {
645
641
646
642
// Expect exception
647
643
try {
648
- Tasks .await (firebaseInstallations .getAuthToken (FirebaseInstallationsApi .FORCE_REFRESH ));
649
- fail ("getAuthToken () failed due to Server Error." );
644
+ Tasks .await (firebaseInstallations .getToken (FirebaseInstallationsApi .FORCE_REFRESH ));
645
+ fail ("getToken () failed due to Server Error." );
650
646
} catch (ExecutionException expected ) {
651
647
assertWithMessage ("Exception class doesn't match" )
652
648
.that (expected )
@@ -659,8 +655,7 @@ public void testGetAuthToken_serverError_failure() throws Exception {
659
655
}
660
656
661
657
@ Test
662
- public void testGetAuthToken_multipleCallsDoNotForceRefresh_fetchedNewTokenOnce ()
663
- throws Exception {
658
+ public void testGetToken_multipleCallsDoNotForceRefresh_fetchedNewTokenOnce () throws Exception {
664
659
// Update local storage with a EXPIRED_AUTH_TOKEN_ENTRY to validate the flow of multiple tasks
665
660
// triggered simultaneously. Task2 waits for Task1 to complete. On task1 completion, task2 reads
666
661
// the UPDATED_AUTH_TOKEN_FID_ENTRY generated by Task1.
@@ -670,11 +665,11 @@ public void testGetAuthToken_multipleCallsDoNotForceRefresh_fetchedNewTokenOnce(
670
665
671
666
FirebaseInstallations firebaseInstallations = getFirebaseInstallations ();
672
667
673
- // Call getAuthToken multiple times with DO_NOT_FORCE_REFRESH option
668
+ // Call getToken multiple times with DO_NOT_FORCE_REFRESH option
674
669
Task <InstallationTokenResult > task1 =
675
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH );
670
+ firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH );
676
671
Task <InstallationTokenResult > task2 =
677
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH );
672
+ firebaseInstallations .getToken (FirebaseInstallationsApi .DO_NOT_FORCE_REFRESH );
678
673
679
674
Tasks .await (Tasks .whenAllComplete (task1 , task2 ));
680
675
@@ -689,10 +684,10 @@ public void testGetAuthToken_multipleCallsDoNotForceRefresh_fetchedNewTokenOnce(
689
684
}
690
685
691
686
@ Test
692
- public void testGetAuthToken_multipleCallsForceRefresh_fetchedNewTokenTwice () throws Exception {
687
+ public void testGetToken_multipleCallsForceRefresh_fetchedNewTokenTwice () throws Exception {
693
688
persistedInstallation .insertOrUpdatePersistedInstallationEntry (REGISTERED_INSTALLATION_ENTRY );
694
689
// Use a mock ServiceClient for network calls with delay(500ms) to ensure first task is not
695
- // completed before the second task starts. Hence, we can test multiple calls to getAuthToken ()
690
+ // completed before the second task starts. Hence, we can test multiple calls to getToken ()
696
691
// and verify one task waits for another task to complete.
697
692
698
693
doAnswer (
@@ -719,11 +714,11 @@ public void testGetAuthToken_multipleCallsForceRefresh_fetchedNewTokenTwice() th
719
714
720
715
FirebaseInstallations firebaseInstallations = getFirebaseInstallations ();
721
716
722
- // Call getAuthToken multiple times with FORCE_REFRESH option.
717
+ // Call getToken multiple times with FORCE_REFRESH option.
723
718
Task <InstallationTokenResult > task1 =
724
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .FORCE_REFRESH );
719
+ firebaseInstallations .getToken (FirebaseInstallationsApi .FORCE_REFRESH );
725
720
Task <InstallationTokenResult > task2 =
726
- firebaseInstallations .getAuthToken (FirebaseInstallationsApi .FORCE_REFRESH );
721
+ firebaseInstallations .getToken (FirebaseInstallationsApi .FORCE_REFRESH );
727
722
Tasks .await (Tasks .whenAllComplete (task1 , task2 ));
728
723
729
724
// As we cannot ensure which task got executed first, verifying with both expected values
0 commit comments