@@ -151,7 +151,7 @@ - (void)testSetEmulatorSettings {
151
151
152
152
#pragma mark - App Check integration
153
153
154
- - (void )testCallFunctionWhenAppCheckIsInstalled {
154
+ - (void )testCallFunctionWhenAppCheckIsInstalledAndFACTokenSuccess {
155
155
_appCheckFake.tokenResult = [[FIRAppCheckTokenResultFake alloc ] initWithToken: @" valid_token"
156
156
error: nil ];
157
157
@@ -161,12 +161,8 @@ - (void)testCallFunctionWhenAppCheckIsInstalled {
161
161
162
162
XCTestExpectation *httpRequestExpectation =
163
163
[self expectationWithDescription: @" HTTPRequestExpectation" ];
164
- __weak __auto_type weakSelf = self;
165
164
_fetcherService.testBlock = ^(GTMSessionFetcher *_Nonnull fetcherToTest,
166
165
GTMSessionFetcherTestResponse _Nonnull testResponse) {
167
- // Fixes retain cycle warning for Xcode 11 and earlier.
168
- // __unused to avoid warning in Xcode 12+.
169
- __unused __auto_type self = weakSelf;
170
166
[httpRequestExpectation fulfill ];
171
167
172
168
NSString *appCheckTokenHeader =
@@ -189,6 +185,39 @@ - (void)testCallFunctionWhenAppCheckIsInstalled {
189
185
[self waitForExpectations: @[ httpRequestExpectation, completionExpectation ] timeout: 1.5 ];
190
186
}
191
187
188
+ - (void )testCallFunctionWhenAppCheckIsInstalledAndFACTokenError {
189
+ NSError *appCheckError = [NSError errorWithDomain: self .name code: -1 userInfo: nil ];
190
+ _appCheckFake.tokenResult = [[FIRAppCheckTokenResultFake alloc ] initWithToken: @" dummy_token"
191
+ error: appCheckError];
192
+
193
+ NSError *networkError = [NSError errorWithDomain: self .name code: -2 userInfo: nil ];
194
+
195
+ XCTestExpectation *httpRequestExpectation =
196
+ [self expectationWithDescription: @" HTTPRequestExpectation" ];
197
+ _fetcherService.testBlock = ^(GTMSessionFetcher *_Nonnull fetcherToTest,
198
+ GTMSessionFetcherTestResponse _Nonnull testResponse) {
199
+ [httpRequestExpectation fulfill ];
200
+
201
+ NSString *appCheckTokenHeader =
202
+ [fetcherToTest.request valueForHTTPHeaderField: @" X-Firebase-AppCheck" ];
203
+ XCTAssertNil (appCheckTokenHeader);
204
+
205
+ testResponse (nil , nil , networkError);
206
+ };
207
+
208
+ XCTestExpectation *completionExpectation =
209
+ [self expectationWithDescription: @" completionExpectation" ];
210
+ [_functions callFunction: @" fake_func"
211
+ withObject: nil
212
+ timeout: 10
213
+ completion: ^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
214
+ XCTAssertEqualObjects (error, networkError);
215
+ [completionExpectation fulfill ];
216
+ }];
217
+
218
+ [self waitForExpectations: @[ httpRequestExpectation, completionExpectation ] timeout: 1.5 ];
219
+ }
220
+
192
221
- (void )testCallFunctionWhenAppCheckIsNotInstalled {
193
222
NSError *networkError = [NSError errorWithDomain: @" testCallFunctionWhenAppCheckIsInstalled"
194
223
code: -1
@@ -197,12 +226,8 @@ - (void)testCallFunctionWhenAppCheckIsNotInstalled {
197
226
XCTestExpectation *httpRequestExpectation =
198
227
[self expectationWithDescription: @" HTTPRequestExpectation" ];
199
228
200
- __weak __auto_type weakSelf = self;
201
229
_fetcherService.testBlock = ^(GTMSessionFetcher *_Nonnull fetcherToTest,
202
230
GTMSessionFetcherTestResponse _Nonnull testResponse) {
203
- // Fixes retain cycle warning for Xcode 11 and earlier.
204
- // __unused to avoid warning in Xcode 12+.
205
- __unused __auto_type self = weakSelf;
206
231
[httpRequestExpectation fulfill ];
207
232
208
233
NSString *appCheckTokenHeader =
0 commit comments