Skip to content

Removing sign in tester from checkForNewRelease #3397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -252,9 +248,14 @@ public synchronized Task<AppDistributionRelease> 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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the comment that starts on line 155? With this PR, we no longer need to qualify why we call signIn before calling checkForNewRelease

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.onSuccessTask(unused -> this.newReleaseFetcher.checkForNewRelease())
this.newReleaseFetcher
.checkForNewRelease()
.onSuccessTask(
appDistributionReleaseInternal -> {
setCachedNewRelease(appDistributionReleaseInternal);
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppDistributionRelease> task = firebaseAppDistribution.checkForNewRelease();

verify(mockTesterSignInManager, times(1)).signInTester();
assertTaskFailure(task, AUTHENTICATION_FAILURE, "Tester is not signed in");
}

@Test
Expand Down Expand Up @@ -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
Expand Down