diff --git a/firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java b/firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java index 17110e54351..1e813db421a 100644 --- a/firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java +++ b/firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java @@ -152,10 +152,6 @@ public UpdateTask updateIfNewReleaseAvailable() { lifecycleNotifier .applyToForegroundActivityTask(this::showSignInConfirmationDialog) - // TODO(rachelprince): Revisit this comment once changes to checkForNewRelease are reviewed - // Even though checkForNewRelease() calls signInTester(), we explicitly call signInTester - // here for code clarity, and because we plan to remove the signInTester() call - // from checkForNewRelease() in the near future .onSuccessTask(unused -> signInTester()) .onSuccessTask(unused -> checkForNewRelease()) .continueWithTask( @@ -252,9 +248,14 @@ public synchronized Task checkForNewRelease() { LogWrapper.getInstance().v("Response in progress"); return cachedCheckForNewReleaseTask; } + if (!isTesterSignedIn()) { + return Tasks.forException( + new FirebaseAppDistributionException("Tester is not signed in", AUTHENTICATION_FAILURE)); + } + cachedCheckForNewReleaseTask = - signInTester() - .onSuccessTask(unused -> this.newReleaseFetcher.checkForNewRelease()) + this.newReleaseFetcher + .checkForNewRelease() .onSuccessTask( appDistributionReleaseInternal -> { setCachedNewRelease(appDistributionReleaseInternal); @@ -299,7 +300,7 @@ private UpdateTask updateApp(boolean showDownloadInNotificationManager) { UpdateTaskImpl updateTask = new UpdateTaskImpl(); updateTask.setException( new FirebaseAppDistributionException( - Constants.ErrorMessages.AUTHENTICATION_ERROR, AUTHENTICATION_FAILURE)); + "Tester is not signed in", AUTHENTICATION_FAILURE)); return updateTask; } if (cachedNewRelease == null) { diff --git a/firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/FirebaseAppDistributionTest.java b/firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/FirebaseAppDistributionTest.java index d703c6b781d..3ea134a4a85 100644 --- a/firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/FirebaseAppDistributionTest.java +++ b/firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/FirebaseAppDistributionTest.java @@ -188,13 +188,12 @@ public void checkForNewRelease_whenCheckForNewReleaseFails_throwsError() { } @Test - public void checkForNewRelease_callsSignInTester() { - when(mockNewReleaseFetcher.checkForNewRelease()) - .thenReturn(Tasks.forResult(TEST_RELEASE_NEWER_AAB_INTERNAL.build())); + public void checkForNewRelease_testerIsNotSignedIn_taskFails() { + when(firebaseAppDistribution.isTesterSignedIn()).thenReturn(false); - firebaseAppDistribution.checkForNewRelease(); + Task task = firebaseAppDistribution.checkForNewRelease(); - verify(mockTesterSignInManager, times(1)).signInTester(); + assertTaskFailure(task, AUTHENTICATION_FAILURE, "Tester is not signed in"); } @Test @@ -228,7 +227,7 @@ public void updateApp_whenNotSignedIn_throwsError() { UpdateTask updateTask = firebaseAppDistribution.updateApp(); - assertTaskFailure(updateTask, AUTHENTICATION_FAILURE, AUTHENTICATION_ERROR); + assertTaskFailure(updateTask, AUTHENTICATION_FAILURE, "Tester is not signed in"); } @Test