Skip to content

Commit 10296e1

Browse files
manny-jimenezManny Jimenez
and
Manny Jimenez
authored
Removing sign in tester from checkForNewRelease (#3397)
* Removing sign in tester from checkForNewRelease * Fixing tests * removing comment * Fixing message * Fixing tests Co-authored-by: Manny Jimenez <[email protected]>
1 parent 7f09987 commit 10296e1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ public UpdateTask updateIfNewReleaseAvailable() {
167167

168168
lifecycleNotifier
169169
.applyToForegroundActivityTask(this::showSignInConfirmationDialog)
170-
// TODO(rachelprince): Revisit this comment once changes to checkForNewRelease are reviewed
171-
// Even though checkForNewRelease() calls signInTester(), we explicitly call signInTester
172-
// here for code clarity, and because we plan to remove the signInTester() call
173-
// from checkForNewRelease() in the near future
174170
.onSuccessTask(unused -> signInTester())
175171
.onSuccessTask(unused -> checkForNewRelease())
176172
.continueWithTask(
@@ -266,9 +262,14 @@ public synchronized Task<AppDistributionRelease> checkForNewRelease() {
266262
LogWrapper.getInstance().v("Response in progress");
267263
return cachedCheckForNewReleaseTask;
268264
}
265+
if (!isTesterSignedIn()) {
266+
return Tasks.forException(
267+
new FirebaseAppDistributionException("Tester is not signed in", AUTHENTICATION_FAILURE));
268+
}
269+
269270
cachedCheckForNewReleaseTask =
270-
signInTester()
271-
.onSuccessTask(unused -> this.newReleaseFetcher.checkForNewRelease())
271+
this.newReleaseFetcher
272+
.checkForNewRelease()
272273
.onSuccessTask(
273274
appDistributionReleaseInternal -> {
274275
setCachedNewRelease(appDistributionReleaseInternal);
@@ -315,7 +316,7 @@ private UpdateTask updateApp(boolean showDownloadInNotificationManager) {
315316
UpdateTaskImpl updateTask = new UpdateTaskImpl();
316317
updateTask.setException(
317318
new FirebaseAppDistributionException(
318-
Constants.ErrorMessages.AUTHENTICATION_ERROR, AUTHENTICATION_FAILURE));
319+
"Tester is not signed in", AUTHENTICATION_FAILURE));
319320
return updateTask;
320321
}
321322
if (cachedNewRelease == null) {

firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/FirebaseAppDistributionTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,12 @@ public void checkForNewRelease_whenCheckForNewReleaseFails_throwsError() {
188188
}
189189

190190
@Test
191-
public void checkForNewRelease_callsSignInTester() {
192-
when(mockNewReleaseFetcher.checkForNewRelease())
193-
.thenReturn(Tasks.forResult(TEST_RELEASE_NEWER_AAB_INTERNAL.build()));
191+
public void checkForNewRelease_testerIsNotSignedIn_taskFails() {
192+
when(firebaseAppDistribution.isTesterSignedIn()).thenReturn(false);
194193

195-
firebaseAppDistribution.checkForNewRelease();
194+
Task<AppDistributionRelease> task = firebaseAppDistribution.checkForNewRelease();
196195

197-
verify(mockTesterSignInManager, times(1)).signInTester();
196+
assertTaskFailure(task, AUTHENTICATION_FAILURE, "Tester is not signed in");
198197
}
199198

200199
@Test
@@ -228,7 +227,7 @@ public void updateApp_whenNotSignedIn_throwsError() {
228227

229228
UpdateTask updateTask = firebaseAppDistribution.updateApp();
230229

231-
assertTaskFailure(updateTask, AUTHENTICATION_FAILURE, AUTHENTICATION_ERROR);
230+
assertTaskFailure(updateTask, AUTHENTICATION_FAILURE, "Tester is not signed in");
232231
}
233232

234233
@Test

0 commit comments

Comments
 (0)