aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth
diff options
context:
space:
mode:
Diffstat (limited to 'Example/Auth')
-rw-r--r--Example/Auth/Tests/FIRAuthTests.m2
-rw-r--r--Example/Auth/Tests/FIRUserTests.m21
-rw-r--r--Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m28
-rw-r--r--Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m6
4 files changed, 51 insertions, 6 deletions
diff --git a/Example/Auth/Tests/FIRAuthTests.m b/Example/Auth/Tests/FIRAuthTests.m
index 8513063..8e00284 100644
--- a/Example/Auth/Tests/FIRAuthTests.m
+++ b/Example/Auth/Tests/FIRAuthTests.m
@@ -23,6 +23,7 @@
#import "FirebaseCommunity/FIRGoogleAuthProvider.h"
#import "FirebaseCommunity/FIRAdditionalUserInfo.h"
#import "FIRAuth_Internal.h"
+#import "FIRAuthOperationType.h"
#import "FIRAuthErrorUtils.h"
#import "FIRAuthDispatcher.h"
#import "FIRAuthGlobalWorkQueue.h"
@@ -423,6 +424,7 @@ static const NSTimeInterval kWaitInterval = .5;
FIRVerifyPhoneNumberResponseCallback callback) {
XCTAssertEqualObjects(request.verificationCode, kVerificationCode);
XCTAssertEqualObjects(request.verificationID, kVerificationID);
+ XCTAssertEqual(request.operation, FIRAuthOperationTypeSignUpOrSignIn);
dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
id mockVerifyPhoneResponse = OCMClassMock([FIRVerifyPhoneNumberResponse class]);
[self stubTokensWithMockResponse:mockVerifyPhoneResponse];
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) {
diff --git a/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m b/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
index 9719d4f..b1ceaf4 100644
--- a/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
+++ b/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
@@ -17,6 +17,7 @@
#import <XCTest/XCTest.h>
#import "FIRAuthBackend.h"
+#import "FIRAuthOperationType.h"
#import "FIRVerifyPhoneNumberRequest.h"
#import "FIRVerifyPhoneNumberResponse.h"
#import "FIRFakeBackendRPCIssuer.h"
@@ -61,6 +62,11 @@ static NSString *const kVerificationIDKey = @"sessionInfo";
*/
static NSString *const kIDTokenKey = @"idToken";
+/** @var kOperationKey
+ @brief The key for the "operation" value in the request.
+ */
+static NSString *const kOperationKey = @"operation";
+
/** @var kTestAccessToken
@bried Fake acess token for testing.
*/
@@ -82,6 +88,22 @@ static NSString *const kPhoneNumberKey = @"phoneNumber";
static NSString *const kExpectedAPIURL =
@"https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPhoneNumber?key=APIKey";
+/** @Extension FIRVerifyPhoneNumberRequest
+ @brief Exposes FIRAuthOperationString from FIRVerifyPhoneNumberRequest to assist testing.
+ */
+@interface FIRVerifyPhoneNumberRequest ()
+
+/** @fn FIRAuthOperationString
+ @brief Exposes FIRAuthOperationString from FIRVerifyPhoneNumberRequest to assist testing.
+ @param operationType The value of the FIRAuthOperationType enum which will be translated to its
+ corresponding string value.
+ @return The string value corresponding to the FIRAuthOperationType argument.
+
+ */
+NSString *const FIRAuthOperationString(FIRAuthOperationType operationType);
+
+@end
+
/** @class FIRVerifyPhoneNumberRequestTests
@brief Tests for @c FIRVerifyPhoneNumberRequest.
*/
@@ -123,6 +145,7 @@ static NSString *const kExpectedAPIURL =
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
request.accessToken = kTestAccessToken;
[FIRAuthBackend verifyPhoneNumber:request
@@ -135,6 +158,8 @@ static NSString *const kExpectedAPIURL =
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kVerificationIDKey], kVerificationID);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kVerificationCodeKey], kVerificationCode);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kIDTokenKey], kTestAccessToken);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kOperationKey],
+ FIRAuthOperationString(FIRAuthOperationTypeSignUpOrSignIn));
}
/** @fn testVerifyPhoneNumberRequestWithTemporaryProof
@@ -144,6 +169,7 @@ static NSString *const kExpectedAPIURL =
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithTemporaryProof:kTemporaryProof
phoneNumber:kPhoneNumber
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
request.accessToken = kTestAccessToken;
[FIRAuthBackend verifyPhoneNumber:request
@@ -156,6 +182,8 @@ static NSString *const kExpectedAPIURL =
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kTemporaryProofKey], kTemporaryProof);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kPhoneNumberKey], kPhoneNumber);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kIDTokenKey], kTestAccessToken);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kOperationKey],
+ FIRAuthOperationString(FIRAuthOperationTypeSignUpOrSignIn));
}
@end
diff --git a/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m b/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
index 92110f2..0363729 100644
--- a/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
@@ -18,6 +18,7 @@
#import "Phone/FIRPhoneAuthCredential_Internal.h"
#import "FIRAuthBackend.h"
#import "FIRAuthErrors.h"
+#import "FIRAuthOperationType.h"
#import "FIRVerifyPhoneNumberRequest.h"
#import "FIRVerifyPhoneNumberResponse.h"
#import "FIRFakeBackendRPCIssuer.h"
@@ -133,6 +134,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
@@ -161,6 +163,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
@@ -188,6 +191,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
@@ -215,6 +219,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
@@ -252,6 +257,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithTemporaryProof:kFakeTemporaryProof
phoneNumber:kFakePhoneNumber
+ operation:FIRAuthOperationTypeSignUpOrSignIn
requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;