@@ -382,6 +382,33 @@ - (void)testFetchNewLatestReleaseUnauthenticatedFailure {
382
382
OCMReject ([_mockMachO codeHash ]);
383
383
}
384
384
385
+ - (void )testFetchNewLatestReleaseUnauthorizedFailure {
386
+ NSError *mockError =
387
+ [NSError errorWithDomain: kFIRFADApiErrorDomain
388
+ code: FIRFADApiErrorUnauthorized
389
+ userInfo: @{NSLocalizedDescriptionKey : @" This is unfortunate." }];
390
+ [self mockFetchReleasesCompletion: nil error: mockError];
391
+ OCMStub ([_mockMachO codeHash ]).andReturn (@" this-is-old" );
392
+ [[GULUserDefaults standardUserDefaults ] setBool: YES forKey: @" FIRFADSignInState" ];
393
+ XCTAssertTrue ([[self appDistribution ] isTesterSignedIn ]);
394
+
395
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch latest release fails." ];
396
+
397
+ [[self appDistribution ] fetchNewLatestRelease: ^(FIRAppDistributionRelease *_Nullable release,
398
+ NSError *_Nullable error) {
399
+ XCTAssertNil (release);
400
+ XCTAssertNotNil (error);
401
+ XCTAssertEqual ([error code ], FIRAppDistributionErrorAuthenticationFailure);
402
+ XCTAssertEqual ([error domain ], FIRAppDistributionErrorDomain);
403
+ XCTAssertFalse ([[self appDistribution ] isTesterSignedIn ]);
404
+ [expectation fulfill ];
405
+ }];
406
+
407
+ [self waitForExpectations: @[ expectation ] timeout: 5.0 ];
408
+ [self verifyFetchReleasesCompletion ];
409
+ OCMReject ([_mockMachO codeHash ]);
410
+ }
411
+
385
412
- (void )testCheckForUpdateWithCompletionTesterSignedIn {
386
413
[self mockInstallationIdCompletion: _mockInstallationId error: nil ];
387
414
[self mockUIServiceRegistrationCompletion: nil ];
0 commit comments