aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth/Tests/FIRUserTests.m
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2017-09-27 00:16:33 -0700
committerGravatar GitHub <noreply@github.com>2017-09-27 00:16:33 -0700
commitaebb293f3dcfaef012e847689d8b814477c0c301 (patch)
treed097bb35727b77c96901357af5c0bf7df3ec9570 /Example/Auth/Tests/FIRUserTests.m
parent804ff523a20072fb958e9137c76b9c0e14dda870 (diff)
Add operation phone auth (#309)
* Adds operation to verify PhoneNumber requests * Improvements and unit tests * Fixes typo * Addresses comments - Removes the FIRAuthOperation class. - Defines the FIRAuthOperationType as an enum in a class of the same name. - Passes the FIRAuthOperationType value down to the verifyPhoneNumber RPC where it is translated to a string. * Fixes unit tests * Actually fixes the unit tests.
Diffstat (limited to 'Example/Auth/Tests/FIRUserTests.m')
-rw-r--r--Example/Auth/Tests/FIRUserTests.m21
1 files changed, 15 insertions, 6 deletions
diff --git a/Example/Auth/Tests/FIRUserTests.m b/Example/Auth/Tests/FIRUserTests.m
index 62d2eda..3384885 100644
--- a/Example/Auth/Tests/FIRUserTests.m
+++ b/Example/Auth/Tests/FIRUserTests.m
@@ -23,10 +23,11 @@
#import "FirebaseCommunity/FIRFacebookAuthProvider.h"
#import "FirebaseCommunity/FIRGoogleAuthProvider.h"
#import "FirebaseCommunity/FIRAdditionalUserInfo.h"
-#import "FirebaseCommunity/FIRAuth.h"
+#import "FIRAuth_Internal.h"
#import "FIRAuthErrorUtils.h"
#import "FIRAuthBackend.h"
#import "FIRAuthGlobalWorkQueue.h"
+#import "FIRAuthOperationType.h"
#import "FIRGetAccountInfoRequest.h"
#import "FIRGetAccountInfoResponse.h"
#import "FIRSetAccountInfoRequest.h"
@@ -535,7 +536,7 @@ static const NSTimeInterval kExpectationTimeout = 1;
id userInfoResponse = mockUserInfoWithPhoneNumber(nil);
[self signInWithEmailPasswordWithMockUserInfoResponse:userInfoResponse
completion:^(FIRUser *user) {
- [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber error:nil];
+ [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber isLinkOperation:NO error:nil];
id userInfoResponseUpdate = mockUserInfoWithPhoneNumber(kPhoneNumber);
[self expectGetAccountInfoWithMockUserInfoResponse:userInfoResponseUpdate];
@@ -1496,7 +1497,7 @@ static const NSTimeInterval kExpectationTimeout = 1;
id userInfoResponse = mockUserInfoWithPhoneNumber(nil);
[self signInWithEmailPasswordWithMockUserInfoResponse:userInfoResponse
completion:^(FIRUser *user) {
- [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber error:nil];
+ [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber isLinkOperation:YES error:nil];
id userInfoResponseUpdate = mockUserInfoWithPhoneNumber(kPhoneNumber);
[self expectGetAccountInfoWithMockUserInfoResponse:userInfoResponseUpdate];
@@ -1560,7 +1561,7 @@ static const NSTimeInterval kExpectationTimeout = 1;
id userInfoResponse = mockUserInfoWithPhoneNumber(nil);
[self signInWithEmailPasswordWithMockUserInfoResponse:userInfoResponse
completion:^(FIRUser *user) {
- [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber error:nil];
+ [self expectVerifyPhoneNumberRequestWithPhoneNumber:kPhoneNumber isLinkOperation:YES error:nil];
id userInfoResponseUpdate = mockUserInfoWithPhoneNumber(kPhoneNumber);
[self expectGetAccountInfoWithMockUserInfoResponse:userInfoResponseUpdate];
@@ -1610,7 +1611,7 @@ static const NSTimeInterval kExpectationTimeout = 1;
[self signInWithEmailPasswordWithMockUserInfoResponse:userInfoResponse
completion:^(FIRUser *user) {
NSError *error = [FIRAuthErrorUtils providerAlreadyLinkedError];
- [self expectVerifyPhoneNumberRequestWithPhoneNumber:nil error:error];
+ [self expectVerifyPhoneNumberRequestWithPhoneNumber:nil isLinkOperation:YES error:error];
FIRPhoneAuthCredential *credential =
[[FIRPhoneAuthProvider provider] credentialWithVerificationID:kVerificationID
verificationCode:kVerificationCode];
@@ -1869,15 +1870,23 @@ static const NSTimeInterval kExpectationTimeout = 1;
@brief Expects a verify phone numner request on the mock backend and calls back with fake
account data or an error.
@param phoneNumber Optionally; The phone number to use in the mocked response.
+ @param isLinkOperation Boolean value that indicates whether or not this method is triggered by
+ a link operation.
@param error Optionally; The error to return in the mocked response.
*/
- (void)expectVerifyPhoneNumberRequestWithPhoneNumber:(nullable NSString *)phoneNumber
- error:(nullable NSError*)error {
+ isLinkOperation:(BOOL)isLinkOperation
+ error:(nullable NSError*)error {
OCMExpect([_mockBackend verifyPhoneNumber:[OCMArg any] callback:[OCMArg any]])
.andCallBlock2(^(FIRVerifyPhoneNumberRequest *_Nullable request,
FIRVerifyPhoneNumberResponseCallback callback) {
XCTAssertEqualObjects(request.verificationID, kVerificationID);
XCTAssertEqualObjects(request.verificationCode, kVerificationCode);
+ if (isLinkOperation) {
+ XCTAssertEqual(request.operation, FIRAuthOperationTypeLink);
+ } else {
+ XCTAssertEqual(request.operation, FIRAuthOperationTypeUpdate);
+ }
XCTAssertEqualObjects(request.accessToken, kAccessToken);
dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
if (error) {