@@ -355,6 +355,33 @@ - (void)testFetchNewLatestReleaseFailure {
355355 OCMReject ([_mockMachO codeHash ]);
356356}
357357
358+ - (void )testFetchNewLatestReleaseUnauthenticatedFailure {
359+ NSError *mockError =
360+ [NSError errorWithDomain: kFIRFADApiErrorDomain
361+ code: FIRFADApiErrorUnauthenticated
362+ userInfo: @{NSLocalizedDescriptionKey : @" This is unfortunate." }];
363+ [self mockFetchReleasesCompletion: nil error: mockError];
364+ OCMStub ([_mockMachO codeHash ]).andReturn (@" this-is-old" );
365+ [[GULUserDefaults standardUserDefaults ] setBool: YES forKey: @" FIRFADSignInState" ];
366+ XCTAssertTrue ([[self appDistribution ] isTesterSignedIn ]);
367+
368+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch latest release fails." ];
369+
370+ [[self appDistribution ] fetchNewLatestRelease: ^(FIRAppDistributionRelease *_Nullable release,
371+ NSError *_Nullable error) {
372+ XCTAssertNil (release);
373+ XCTAssertNotNil (error);
374+ XCTAssertEqual ([error code ], FIRAppDistributionErrorAuthenticationFailure);
375+ XCTAssertEqual ([error domain ], FIRAppDistributionErrorDomain);
376+ XCTAssertFalse ([[self appDistribution ] isTesterSignedIn ]);
377+ [expectation fulfill ];
378+ }];
379+
380+ [self waitForExpectations: @[ expectation ] timeout: 5.0 ];
381+ [self verifyFetchReleasesCompletion ];
382+ OCMReject ([_mockMachO codeHash ]);
383+ }
384+
358385- (void )testCheckForUpdateWithCompletionTesterSignedIn {
359386 [self mockInstallationIdCompletion: _mockInstallationId error: nil ];
360387 [self mockUIServiceRegistrationCompletion: nil ];
0 commit comments