|
|
@@ -324,9 +324,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
number was provided.
|
|
|
*/
|
|
|
- (void)testVerifyEmptyPhoneNumber {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -334,6 +331,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Empty phone number is checked on the client side so no backend RPC is mocked.
|
|
|
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
|
|
|
[_provider verifyPhoneNumber:@""
|
|
|
@@ -351,9 +351,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
number was provided.
|
|
|
*/
|
|
|
- (void)testVerifyInvalidPhoneNumber {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -361,6 +358,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(YES);
|
|
|
@@ -397,9 +397,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests a successful invocation of @c verifyPhoneNumber:completion:.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumber {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -407,6 +404,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(YES);
|
|
|
@@ -447,9 +447,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
is disabled.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberInTestMode {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -457,6 +454,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Disable app verification.
|
|
|
FIRAuthSettings *settings = [[FIRAuthSettings alloc] init];
|
|
|
settings.appVerificationDisabledForTesting = YES;
|
|
|
@@ -499,9 +499,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
is disabled.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberInTestModeFailure {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -509,6 +506,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Disable app verification.
|
|
|
FIRAuthSettings *settings = [[FIRAuthSettings alloc] init];
|
|
|
settings.appVerificationDisabledForTesting = YES;
|
|
|
@@ -548,8 +548,140 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests a successful invocation of @c verifyPhoneNumber:UIDelegate:completion:.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateFirebaseAppIdFlow {
|
|
|
+ id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
+ OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
+ OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
+ @{@"CFBundleURLSchemes" : @[ kFakeEncodedFirebaseAppID ]}
|
|
|
+ ]);
|
|
|
+ OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
+
|
|
|
_provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
|
|
|
+ // Simulate missing app token error.
|
|
|
+ OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
+ .andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
+ callback(YES);
|
|
|
+ });
|
|
|
+ OCMExpect([_mockAppCredentialManager credential]).andReturn(nil);
|
|
|
+ OCMExpect([_mockAPNSTokenManager getTokenWithCallback:OCMOCK_ANY])
|
|
|
+ .andCallBlock1(^(FIRAuthAPNSTokenCallback callback) {
|
|
|
+ NSError *error = [NSError errorWithDomain:FIRAuthErrorDomain
|
|
|
+ code:FIRAuthErrorCodeMissingAppToken
|
|
|
+ userInfo:nil];
|
|
|
+ callback(nil, error);
|
|
|
+ });
|
|
|
+ OCMExpect([_mockBackend getProjectConfig:[OCMArg any] callback:[OCMArg any]])
|
|
|
+ .andCallBlock2(
|
|
|
+ ^(FIRGetProjectConfigRequest *request, FIRGetProjectConfigResponseCallback callback) {
|
|
|
+ XCTAssertNotNil(request);
|
|
|
+ dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
|
|
|
+ id mockGetProjectConfigResponse = OCMClassMock([FIRGetProjectConfigResponse class]);
|
|
|
+ OCMStub([mockGetProjectConfigResponse authorizedDomains]).andReturn(@[
|
|
|
+ kFakeAuthorizedDomain
|
|
|
+ ]);
|
|
|
+ callback(mockGetProjectConfigResponse, nil);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ id mockUIDelegate = OCMProtocolMock(@protocol(FIRAuthUIDelegate));
|
|
|
+
|
|
|
+ // Expect view controller presentation by UIDelegate.
|
|
|
+ OCMExpect([_mockURLPresenter presentURL:OCMOCK_ANY
|
|
|
+ UIDelegate:mockUIDelegate
|
|
|
+ callbackMatcher:OCMOCK_ANY
|
|
|
+ completion:OCMOCK_ANY])
|
|
|
+ .andDo(^(NSInvocation *invocation) {
|
|
|
+ __unsafe_unretained id unretainedArgument;
|
|
|
+ // Indices 0 and 1 indicate the hidden arguments self and _cmd.
|
|
|
+ // `presentURL` is at index 2.
|
|
|
+ [invocation getArgument:&unretainedArgument atIndex:2];
|
|
|
+ NSURL *presentURL = unretainedArgument;
|
|
|
+ XCTAssertEqualObjects(presentURL.scheme, @"https");
|
|
|
+ XCTAssertEqualObjects(presentURL.host, kFakeAuthorizedDomain);
|
|
|
+ XCTAssertEqualObjects(presentURL.path, @"/__/auth/handler");
|
|
|
+
|
|
|
+ NSURLComponents *actualURLComponents = [NSURLComponents componentsWithURL:presentURL
|
|
|
+ resolvingAgainstBaseURL:NO];
|
|
|
+ NSArray<NSURLQueryItem *> *queryItems = [actualURLComponents queryItems];
|
|
|
+ XCTAssertEqualObjects([FIRAuthWebUtils queryItemValue:@"ibi" from:queryItems],
|
|
|
+ kFakeBundleID);
|
|
|
+ XCTAssertEqualObjects([FIRAuthWebUtils queryItemValue:@"appId" from:queryItems],
|
|
|
+ kFakeFirebaseAppID);
|
|
|
+ XCTAssertEqualObjects([FIRAuthWebUtils queryItemValue:@"apiKey" from:queryItems],
|
|
|
+ kFakeAPIKey);
|
|
|
+ XCTAssertEqualObjects([FIRAuthWebUtils queryItemValue:@"authType" from:queryItems],
|
|
|
+ @"verifyApp");
|
|
|
+ XCTAssertNotNil([FIRAuthWebUtils queryItemValue:@"v" from:queryItems]);
|
|
|
+ // `callbackMatcher` is at index 4
|
|
|
+ [invocation getArgument:&unretainedArgument atIndex:4];
|
|
|
+ FIRAuthURLCallbackMatcher callbackMatcher = unretainedArgument;
|
|
|
+ NSMutableString *redirectURL = [NSMutableString
|
|
|
+ stringWithString:[kFakeEncodedFirebaseAppID
|
|
|
+ stringByAppendingString:kFakeRedirectURLStringWithReCAPTCHAToken]];
|
|
|
+ // Verify that the URL is rejected by the callback matcher without the event ID.
|
|
|
+ XCTAssertFalse(callbackMatcher([NSURL URLWithString:redirectURL]));
|
|
|
+ [redirectURL appendString:@"%26eventId%3D"];
|
|
|
+ [redirectURL appendString:[FIRAuthWebUtils queryItemValue:@"eventId" from:queryItems]];
|
|
|
+ NSURLComponents *originalComponents = [[NSURLComponents alloc] initWithString:redirectURL];
|
|
|
+ // Verify that the URL is accepted by the callback matcher with the matching event ID.
|
|
|
+ XCTAssertTrue(callbackMatcher([originalComponents URL]));
|
|
|
+ NSURLComponents *components = [originalComponents copy];
|
|
|
+ components.query = @"https";
|
|
|
+ XCTAssertFalse(callbackMatcher([components URL]));
|
|
|
+ components = [originalComponents copy];
|
|
|
+ components.host = @"badhost";
|
|
|
+ XCTAssertFalse(callbackMatcher([components URL]));
|
|
|
+ components = [originalComponents copy];
|
|
|
+ components.path = @"badpath";
|
|
|
+ XCTAssertFalse(callbackMatcher([components URL]));
|
|
|
+ components = [originalComponents copy];
|
|
|
+ components.query = @"badquery";
|
|
|
+ XCTAssertFalse(callbackMatcher([components URL]));
|
|
|
+
|
|
|
+ // `completion` is at index 5
|
|
|
+ [invocation getArgument:&unretainedArgument atIndex:5];
|
|
|
+ FIRAuthURLPresentationCompletion completion = unretainedArgument;
|
|
|
+ dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
|
|
|
+ completion([NSURL URLWithString:[kFakeEncodedFirebaseAppID
|
|
|
+ stringByAppendingString:
|
|
|
+ kFakeRedirectURLStringWithReCAPTCHAToken]],
|
|
|
+ nil);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ OCMExpect([_mockBackend sendVerificationCode:[OCMArg any] callback:[OCMArg any]])
|
|
|
+ .andCallBlock2(^(FIRSendVerificationCodeRequest *request,
|
|
|
+ FIRSendVerificationCodeResponseCallback callback) {
|
|
|
+ XCTAssertEqualObjects(request.phoneNumber, kTestPhoneNumber);
|
|
|
+ XCTAssertNil(request.appCredential);
|
|
|
+ XCTAssertEqualObjects(request.reCAPTCHAToken, kFakeReCAPTCHAToken);
|
|
|
+ dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
|
|
|
+ id mockSendVerificationCodeResponse =
|
|
|
+ OCMClassMock([FIRSendVerificationCodeResponse class]);
|
|
|
+ OCMStub([mockSendVerificationCodeResponse verificationID]).andReturn(kTestVerificationID);
|
|
|
+ callback(mockSendVerificationCodeResponse, nil);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
|
|
|
+ [_provider verifyPhoneNumber:kTestPhoneNumber
|
|
|
+ UIDelegate:mockUIDelegate
|
|
|
+ completion:^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
|
|
+ XCTAssertTrue([NSThread isMainThread]);
|
|
|
+ XCTAssertNil(error);
|
|
|
+ XCTAssertEqualObjects(verificationID, kTestVerificationID);
|
|
|
+ [expectation fulfill];
|
|
|
+ }];
|
|
|
+ [self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
|
|
|
+ OCMVerifyAll(_mockBackend);
|
|
|
+ OCMVerifyAll(_mockNotificationManager);
|
|
|
+}
|
|
|
+
|
|
|
+/** @fn testVerifyPhoneNumberUIDelegateFirebaseAppIdWhileClientIdPresentFlow
|
|
|
+ @brief Tests a successful invocation of @c verifyPhoneNumber:UIDelegate:completion: when the
|
|
|
+ client ID is present in the plist file, but the encoded app ID is the registered custom URL
|
|
|
+ scheme.
|
|
|
+ */
|
|
|
+- (void)testVerifyPhoneNumberUIDelegateFirebaseAppIdWhileClientIdPresentFlow {
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -557,6 +689,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -680,9 +815,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests a successful invocation of @c verifyPhoneNumber:UIDelegate:completion:.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateClientIdFlow {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -690,6 +822,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -814,9 +949,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
invalid client ID error.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateInvalidClientID {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -824,6 +956,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -886,9 +1021,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
network request failed error.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateNetworkRequestFailed {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -896,6 +1028,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -958,9 +1093,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
internal error.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateWebInternalError {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -968,6 +1100,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -1030,9 +1165,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
invalid client ID.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateUnexpectedError {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1040,6 +1172,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -1104,9 +1239,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
structure of the error response.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateUnstructuredError {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1114,6 +1246,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -1177,14 +1312,15 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
exception.
|
|
|
*/
|
|
|
- (void)testVerifyPhoneNumberUIDelegateRaiseException {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@{@"CFBundleURLSchemes" : @[ @"badscheme" ]}
|
|
|
]);
|
|
|
+
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
id mockUIDelegate = OCMProtocolMock(@protocol(FIRAuthUIDelegate));
|
|
|
XCTAssertThrows([_provider
|
|
|
verifyPhoneNumber:kTestPhoneNumber
|
|
|
@@ -1198,9 +1334,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests returning an error for the app failing to forward notification.
|
|
|
*/
|
|
|
- (void)testNotForwardingNotification {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1208,6 +1341,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(NO);
|
|
|
@@ -1229,9 +1365,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests returning an error for the app failing to provide an APNS device token.
|
|
|
*/
|
|
|
- (void)testMissingAPNSToken {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1239,6 +1372,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
// Simulate missing app token error.
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
@@ -1302,9 +1438,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests verifying client before sending verification code.
|
|
|
*/
|
|
|
- (void)testVerifyClient {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1312,6 +1445,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(YES);
|
|
|
@@ -1386,9 +1522,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests failed retry after failing to send verification code.
|
|
|
*/
|
|
|
- (void)testSendVerificationCodeFailedRetry {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1396,6 +1529,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(YES);
|
|
|
@@ -1491,9 +1627,6 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
@brief Tests successful retry after failing to send verification code.
|
|
|
*/
|
|
|
- (void)testSendVerificationCodeSuccessFulRetry {
|
|
|
- OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
- _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
-
|
|
|
id mockBundle = OCMClassMock([NSBundle class]);
|
|
|
OCMStub(ClassMethod([mockBundle mainBundle])).andReturn(mockBundle);
|
|
|
OCMStub([mockBundle objectForInfoDictionaryKey:@"CFBundleURLTypes"]).andReturn(@[
|
|
|
@@ -1501,6 +1634,9 @@ static const NSTimeInterval kExpectationTimeout = 2;
|
|
|
]);
|
|
|
OCMStub([mockBundle bundleIdentifier]).andReturn(kFakeBundleID);
|
|
|
|
|
|
+ OCMStub([_mockOptions clientID]).andReturn(kFakeClientID);
|
|
|
+ _provider = [FIRPhoneAuthProvider providerWithAuth:_mockAuth];
|
|
|
+
|
|
|
OCMExpect([_mockNotificationManager checkNotificationForwardingWithCallback:OCMOCK_ANY])
|
|
|
.andCallBlock1(^(FIRAuthNotificationForwardingCallback callback) {
|
|
|
callback(YES);
|