Skip to content

Commit fb1b4ba

Browse files
authored
Add get Auth domain RPC (#214)
* Add get Auth domain RPC * Fixes indentation * Addresses comments * ran tests on Example/Firebase.xcodeproj
1 parent 1a857fe commit fb1b4ba

15 files changed

+504
-57
lines changed

AuthSamples/Samples.xcodeproj/project.pbxproj

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
52C975C71EE10B1304EBBEB2 /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BC8C39EF1F42A0C750FF5186 /* Pods_SwiftSample.framework */; };
2727
569C3F4E18627674CABE02AE /* Pods_EarlGreyTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEE2E563FADF8C3382956B4F /* Pods_EarlGreyTests.framework */; };
2828
67AFFB52FF0FC4668D92F2E4 /* Pods_Sample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5FE06BD9AA795DFBA9EFAAD /* Pods_Sample.framework */; };
29+
7E9969EE1F4E277900627C2B /* FIRGetProjectConfigRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9969EC1F4E277900627C2B /* FIRGetProjectConfigRequestTests.m */; };
2930
7EDFD35B1F0EA29200B29DC5 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7EDFD35D1F0EA29200B29DC5 /* Localizable.strings */; };
31+
7EEEFEE61F4E4F75000FF966 /* FIRGetProjectConfigResponseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EEA8ADD1F4E4E840014A23B /* FIRGetProjectConfigResponseTests.m */; };
3032
A7609DCAD8A247411F27EA14 /* Pods_TestApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDD2401395E91D0923BC5CD8 /* Pods_TestApp.framework */; };
3133
AB62D09AF8C1196E07F37D3B /* Pods_SwiftSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1F689EE8E0E6F83D82429F0 /* Pods_SwiftSample.framework */; };
3234
BD555A1DCF4E889DC3338248 /* Pods_FirebaseAuthUnitTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4FFAD3F37BC4D7CEF0CAD579 /* Pods_FirebaseAuthUnitTests.framework */; };
@@ -183,8 +185,10 @@
183185
6EC09307D636721EAAB89BB2 /* Pods_ApiTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ApiTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
184186
7E0BC64A1F199D86008BE4E0 /* fr-FR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "fr-FR"; path = "fr-FR.lproj/Localizable.strings"; sourceTree = "<group>"; };
185187
7E0BC64E1F19A77C008BE4E0 /* ru-RU */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "ru-RU"; path = "ru-RU.lproj/Localizable.strings"; sourceTree = "<group>"; };
188+
7E9969EC1F4E277900627C2B /* FIRGetProjectConfigRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIRGetProjectConfigRequestTests.m; path = ../../Example/Auth/Tests/FIRGetProjectConfigRequestTests.m; sourceTree = "<group>"; };
186189
7EDFD35C1F0EA29200B29DC5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
187190
7EDFD3771F0EA2A900B29DC5 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
191+
7EEA8ADD1F4E4E840014A23B /* FIRGetProjectConfigResponseTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRGetProjectConfigResponseTests.m; sourceTree = "<group>"; };
188192
81ED9C5F2E61472DE3FA17CC /* Pods-ApiTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ApiTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ApiTests/Pods-ApiTests.release.xcconfig"; sourceTree = "<group>"; };
189193
920E926BD468CBC593349A36 /* Pods-FirebaseAuthUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FirebaseAuthUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FirebaseAuthUnitTests/Pods-FirebaseAuthUnitTests.debug.xcconfig"; sourceTree = "<group>"; };
190194
94E3B3EB70D34E55CFF2E45D /* Pods-EarlGreyTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EarlGreyTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-EarlGreyTests/Pods-EarlGreyTests.release.xcconfig"; sourceTree = "<group>"; };
@@ -551,6 +555,8 @@
551555
DE5371B01EA7E89D000DA57F /* OCMStubRecorder+FIRAuthUnitTests.h */,
552556
DE5371B11EA7E89D000DA57F /* OCMStubRecorder+FIRAuthUnitTests.m */,
553557
DE5371B21EA7E89D000DA57F /* Tests-Info.plist */,
558+
7E9969EC1F4E277900627C2B /* FIRGetProjectConfigRequestTests.m */,
559+
7EEA8ADD1F4E4E840014A23B /* FIRGetProjectConfigResponseTests.m */,
554560
);
555561
path = UnitTests;
556562
sourceTree = "<group>";
@@ -918,7 +924,7 @@
918924
);
919925
runOnlyForDeploymentPostprocessing = 0;
920926
shellPath = /bin/sh;
921-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
927+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
922928
showEnvVarsInLog = 0;
923929
};
924930
14D1078EE81275B0906224AE /* [CP] Embed Pods Frameworks */ = {
@@ -966,7 +972,7 @@
966972
);
967973
runOnlyForDeploymentPostprocessing = 0;
968974
shellPath = /bin/sh;
969-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
975+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
970976
showEnvVarsInLog = 0;
971977
};
972978
31C9CD5738CD8A86F3E29FD4 /* [CP] Check Pods Manifest.lock */ = {
@@ -984,7 +990,7 @@
984990
);
985991
runOnlyForDeploymentPostprocessing = 0;
986992
shellPath = /bin/sh;
987-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
993+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
988994
showEnvVarsInLog = 0;
989995
};
990996
45E0A7D32BD529EA299F169F /* [CP] Embed Pods Frameworks */ = {
@@ -1046,7 +1052,7 @@
10461052
);
10471053
runOnlyForDeploymentPostprocessing = 0;
10481054
shellPath = /bin/sh;
1049-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1055+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
10501056
showEnvVarsInLog = 0;
10511057
};
10521058
90FD4EF0F0A764C0793CAA62 /* [CP] Embed Pods Frameworks */ = {
@@ -1218,7 +1224,7 @@
12181224
);
12191225
runOnlyForDeploymentPostprocessing = 0;
12201226
shellPath = /bin/sh;
1221-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1227+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
12221228
showEnvVarsInLog = 0;
12231229
};
12241230
DECFE0EC98C60CEE719E03CA /* [CP] Check Pods Manifest.lock */ = {
@@ -1236,7 +1242,7 @@
12361242
);
12371243
runOnlyForDeploymentPostprocessing = 0;
12381244
shellPath = /bin/sh;
1239-
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
1245+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
12401246
showEnvVarsInLog = 0;
12411247
};
12421248
F2982E8E37D71A5B31C19526 /* [CP] Embed Pods Frameworks */ = {
@@ -1317,6 +1323,7 @@
13171323
isa = PBXSourcesBuildPhase;
13181324
buildActionMask = 2147483647;
13191325
files = (
1326+
7E9969EE1F4E277900627C2B /* FIRGetProjectConfigRequestTests.m in Sources */,
13201327
DE5371B31EA7E89D000DA57F /* FIRAdditionalUserInfoTests.m in Sources */,
13211328
DE5371B61EA7E89D000DA57F /* FIRAuthAppDelegateProxyTests.m in Sources */,
13221329
DE5371DD1EA7E89D000DA57F /* FIRVerifyPhoneNumberResponseTests.m in Sources */,
@@ -1359,6 +1366,7 @@
13591366
DECEA56C1EBBED1200273585 /* FIRAuthAPNSTokenManagerTests.m in Sources */,
13601367
DE5371CD1EA7E89D000DA57F /* FIRSendVerificationCodeResponseTests.m in Sources */,
13611368
DE5371C71EA7E89D000DA57F /* FIRGetOOBConfirmationCodeResponseTests.m in Sources */,
1369+
7EEEFEE61F4E4F75000FF966 /* FIRGetProjectConfigResponseTests.m in Sources */,
13621370
DE5371C21EA7E89D000DA57F /* FIRDeleteAccountResponseTests.m in Sources */,
13631371
DE5371CB1EA7E89D000DA57F /* FIRResetPasswordResponseTests.m in Sources */,
13641372
DE5371D21EA7E89D000DA57F /* FIRTwitterAuthProviderTests.m in Sources */,

Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ - (NSURL *)requestURL {
236236
return [NSURL URLWithString:kFakeRequestURL];
237237
}
238238

239+
- (BOOL)containsPostBody {
240+
return YES;
241+
}
242+
239243
- (FIRAuthRequestConfiguration *)requestConfiguration {
240244
FIRAuthRequestConfiguration *fakeConfiguration =
241245
[[FIRAuthRequestConfiguration alloc] initWithAPIKey:kFakeAPIkey];

Example/Auth/Tests/FIRFakeBackendRPCIssuer.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ - (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)re
3434
contentType:(NSString *)contentType
3535
completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler {
3636
_requestURL = [URL copy];
37-
_requestData = body;
38-
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:body options:0 error:nil];
39-
_decodedRequest = JSON;
37+
if (body) {
38+
_requestData = body;
39+
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:body options:0 error:nil];
40+
_decodedRequest = JSON;
41+
}
4042
_contentType = contentType;
4143
_handler = handler;
4244
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2017 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "FIRAuthBackend.h"
20+
#import "FIRGetProjectConfigRequest.h"
21+
#import "FIRGetProjectConfigResponse.h"
22+
#import "FIRFakeBackendRPCIssuer.h"
23+
24+
/** @var kTestAPIKey
25+
@brief Fake API key used for testing.
26+
*/
27+
static NSString *const kTestAPIKey = @"APIKey";
28+
29+
@interface FIRGetProjectConfigRequestTests : XCTestCase
30+
@end
31+
32+
@implementation FIRGetProjectConfigRequestTests {
33+
/** @var _RPCIssuer
34+
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
35+
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
36+
*/
37+
FIRFakeBackendRPCIssuer *_RPCIssuer;
38+
}
39+
40+
- (void)setUp {
41+
[super setUp];
42+
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
43+
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
44+
_RPCIssuer = RPCIssuer;
45+
}
46+
47+
- (void)tearDown {
48+
_RPCIssuer = nil;
49+
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
50+
[super tearDown];
51+
}
52+
53+
/** @fn testGetProjectConfigRequest
54+
@brief Tests get project config request.
55+
*/
56+
- (void)testGetProjectConfigRequest {
57+
FIRAuthRequestConfiguration *requestConfiguration =
58+
[[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
59+
FIRGetProjectConfigRequest *request =
60+
[[FIRGetProjectConfigRequest alloc] initWithRequestConfiguration:requestConfiguration];
61+
62+
[FIRAuthBackend getProjectConfig:request
63+
callback:^(FIRGetProjectConfigResponse *_Nullable response,
64+
NSError *_Nullable error) {
65+
66+
67+
}];
68+
XCTAssertFalse([request containsPostBody]);
69+
// Confirm that the quest has no decoded body as it is get request.
70+
XCTAssertNil(_RPCIssuer.decodedRequest);
71+
}
72+
73+
@end
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright 2017 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "FIRAuthBackend.h"
20+
#import "FIRAuthErrors.h"
21+
#import "FIRAuthInternalErrors.h"
22+
#import "FIRGetProjectConfigRequest.h"
23+
#import "FIRGetProjectConfigResponse.h"
24+
#import "FIRFakeBackendRPCIssuer.h"
25+
26+
/** @var kTestAPIKey
27+
@brief Fake API key used for testing.
28+
*/
29+
static NSString *const kTestAPIKey = @"APIKey";
30+
31+
/** @var kTestProjectID
32+
@brief Fake project ID used for testing.
33+
*/
34+
static NSString *const kTestProjectID = @"21141651616";
35+
36+
/** @var kTestDomain1
37+
@brief Fake whitelisted domain used for testing.
38+
*/
39+
static NSString *const kTestDomain1 = @"localhost";
40+
41+
/** @var kTestDomain2
42+
@brief Fake whitelisted domain used for testing.
43+
*/
44+
static NSString *const kTestDomain2 = @"example.firebaseapp.com";
45+
46+
/** @var kMissingAPIKeyErrorMessage
47+
@brief The error message the server would respond with if the API Key was missing.
48+
*/
49+
static NSString *const kMissingAPIKeyErrorMessage = @"MISSING_API_KEY";
50+
51+
@interface FIRGetProjectConfigResponseTests : XCTestCase
52+
@end
53+
54+
@implementation FIRGetProjectConfigResponseTests {
55+
/** @var _RPCIssuer
56+
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
57+
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
58+
*/
59+
FIRFakeBackendRPCIssuer *_RPCIssuer;
60+
}
61+
62+
- (void)setUp {
63+
[super setUp];
64+
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
65+
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
66+
_RPCIssuer = RPCIssuer;
67+
}
68+
69+
- (void)tearDown {
70+
_RPCIssuer = nil;
71+
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
72+
[super tearDown];
73+
}
74+
75+
/** @fn testMissingAPIKeyError
76+
@brief This test simulates a missing API key error. Since the API key is provided to the backend
77+
from the auth library this error should map to an internal error.
78+
*/
79+
- (void)testMissingAPIKeyError {
80+
FIRAuthRequestConfiguration *requestConfiguration =
81+
[[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
82+
FIRGetProjectConfigRequest *request =
83+
[[FIRGetProjectConfigRequest alloc] initWithRequestConfiguration:requestConfiguration];
84+
85+
__block BOOL callbackInvoked;
86+
__block FIRGetProjectConfigResponse *RPCResponse;
87+
__block NSError *RPCError;
88+
[FIRAuthBackend getProjectConfig:request
89+
callback:^(FIRGetProjectConfigResponse *_Nullable response,
90+
NSError *_Nullable error) {
91+
callbackInvoked = YES;
92+
RPCResponse = response;
93+
RPCError = error;
94+
}];
95+
96+
[_RPCIssuer respondWithServerErrorMessage:kMissingAPIKeyErrorMessage];
97+
98+
XCTAssert(callbackInvoked);
99+
XCTAssertNotNil(RPCError);
100+
XCTAssertEqualObjects(RPCError.domain, FIRAuthErrorDomain);
101+
XCTAssertEqual(RPCError.code, FIRAuthErrorCodeInternalError);
102+
XCTAssertNotNil(RPCError.userInfo[NSUnderlyingErrorKey]);
103+
}
104+
105+
/** @fn testSuccessFulGetProjectConfigRequest
106+
@brief This test simulates a successful @c getProjectConfig Flow.
107+
*/
108+
- (void)testSuccessFulGetProjectConfigRequest {
109+
FIRAuthRequestConfiguration *requestConfiguration =
110+
[[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
111+
FIRGetProjectConfigRequest *request =
112+
[[FIRGetProjectConfigRequest alloc] initWithRequestConfiguration:requestConfiguration];
113+
114+
__block BOOL callbackInvoked;
115+
__block FIRGetProjectConfigResponse *RPCResponse;
116+
__block NSError *RPCError;
117+
[FIRAuthBackend getProjectConfig:request
118+
callback:^(FIRGetProjectConfigResponse *_Nullable response,
119+
NSError *_Nullable error) {
120+
callbackInvoked = YES;
121+
RPCResponse = response;
122+
RPCError = error;
123+
}];
124+
125+
[_RPCIssuer respondWithJSON:@{
126+
@"projectId": kTestProjectID,
127+
@"authorizedDomains": @[ kTestDomain1, kTestDomain2 ]
128+
}];
129+
XCTAssert(callbackInvoked);
130+
XCTAssertNil(RPCError);
131+
XCTAssertEqualObjects(kTestProjectID, RPCResponse.projectID);
132+
XCTAssertEqualObjects(kTestDomain1, RPCResponse.authorizedDomains[0]);
133+
XCTAssertEqualObjects(kTestDomain2, RPCResponse.authorizedDomains[1]);
134+
}
135+
136+
@end

0 commit comments

Comments
 (0)