aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth
diff options
context:
space:
mode:
authorGravatar Xiangtian Dai <xiangtian@google.com>2017-07-28 17:43:33 -0700
committerGravatar GitHub <noreply@github.com>2017-07-28 17:43:33 -0700
commit925a1cc0a27a3afb17b862a0740b56e56c3ae669 (patch)
treeda6935aa77f50ae17e0b6f60425c8bd0f1c142e6 /Example/Auth
parent0abd3444344ea134b0593fcaaf428e82cd190e12 (diff)
Merge from private/auth-master (#159)
* Adds passing state and continue URL in OOBCodes actions. (#82) * Adds actionCodeSettings class (#83) * Adds FIRActionCodeSettings class * Removes iOSAppStoreId to reflect update spec. * Adds “reset password in app” to sample app (#84) * Adds “reset password in app” to sample app * Addresses comments * Addresses comments * Adds @param documentation for actionCodeSettings (#85) Adds @param documentation for actionCodeSettings in FIRGetOOBConfirmationCodeRequest. * Adds request configuration class Adds a class that will comprise of all configurations needed to make a request to the Firebase Auth backend; including APIKey and Language code in the future. * Addresses comments. * Adds Setting Language Add Setting Language Feature to Firebase Auth. - Only adds support for two languages (English and Spanish) in this change. (Also supports two languages in test), more to come after this change is accepted. - For now sample app tests language setting only when using “reset password in app” option, the email sent will be in the current app language. Additional tests to come after change is accepted. * Amends code for unit tests Will add more comprehensive testing when code accepted. * Ecodes strings files in UTF-8 * Addresses comments * Addresses comments * Remove comments in .strings * Adds remaining TC languages to Firebase Auth. * Add line break to .strings files * remove language code english fallback Remove the fallback that sends “en” as the language code to the backend if no language code is specified. * addresses comment * Fixes FIRSecureToken Crash Integrates FIRSecureTokenService and FIRSecureTokenRequest with FIRAuthRequestConfiguration. * Addresses comment * Add auth language input Adds Auth language input to the Sample App in preparation for manual testing. * removes unnecessary comment * address comments * Add app language option Allow user to set the current app language code as the auth language code. This is in preparation for manual testing before release. * Addresses Comment * Adds missing continue URI Adds missing continue URL to Firebear error handling. * Remove unused line Removes unused line from FIRPhoneAuthProvider.m * Moves the new public header to the right place. * Fixes broken macOS build. * Removes trailing spaces. * Addresses review comments.
Diffstat (limited to 'Example/Auth')
-rw-r--r--Example/Auth/Tests/FIRAuthBackendCreateAuthURITests.m5
-rw-r--r--Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m12
-rw-r--r--Example/Auth/Tests/FIRAuthDispatcherTests.m2
-rw-r--r--Example/Auth/Tests/FIRAuthTests.m2
-rw-r--r--Example/Auth/Tests/FIRCreateAuthURIRequestTests.m4
-rw-r--r--Example/Auth/Tests/FIRCreateAuthURIResponseTests.m19
-rw-r--r--Example/Auth/Tests/FIRDeleteAccountRequestTests.m10
-rw-r--r--Example/Auth/Tests/FIRDeleteAccountResponseTests.m35
-rw-r--r--Example/Auth/Tests/FIRFakeBackendRPCIssuer.m9
-rw-r--r--Example/Auth/Tests/FIRGetAccountInfoRequestTests.m5
-rw-r--r--Example/Auth/Tests/FIRGetAccountInfoResponseTests.m10
-rw-r--r--Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m104
-rw-r--r--Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m203
-rw-r--r--Example/Auth/Tests/FIRGitHubAuthProviderTests.m5
-rw-r--r--Example/Auth/Tests/FIRPhoneAuthProviderTests.m5
-rw-r--r--Example/Auth/Tests/FIRResetPasswordRequestTests.m8
-rw-r--r--Example/Auth/Tests/FIRResetPasswordResponseTests.m45
-rw-r--r--Example/Auth/Tests/FIRSendVerificationCodeRequestTests.m4
-rw-r--r--Example/Auth/Tests/FIRSendVerificationCodeResponseTests.m18
-rw-r--r--Example/Auth/Tests/FIRSetAccountInfoRequestTests.m13
-rw-r--r--Example/Auth/Tests/FIRSetAccountInfoResponseTests.m49
-rw-r--r--Example/Auth/Tests/FIRSignUpNewUserRequestTests.m18
-rw-r--r--Example/Auth/Tests/FIRSignUpNewUserResponseTests.m30
-rw-r--r--Example/Auth/Tests/FIRTwitterAuthProviderTests.m6
-rw-r--r--Example/Auth/Tests/FIRVerifyAssertionRequestTests.m16
-rw-r--r--Example/Auth/Tests/FIRVerifyAssertionResponseTests.m28
-rw-r--r--Example/Auth/Tests/FIRVerifyClientRequestTest.m4
-rw-r--r--Example/Auth/Tests/FIRVerifyClientResponseTests.m13
-rw-r--r--Example/Auth/Tests/FIRVerifyCustomTokenRequestTests.m13
-rw-r--r--Example/Auth/Tests/FIRVerifyCustomTokenResponseTests.m22
-rw-r--r--Example/Auth/Tests/FIRVerifyPasswordRequestTest.m11
-rw-r--r--Example/Auth/Tests/FIRVerifyPasswordResponseTests.m62
-rw-r--r--Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m11
-rw-r--r--Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m18
34 files changed, 654 insertions, 165 deletions
diff --git a/Example/Auth/Tests/FIRAuthBackendCreateAuthURITests.m b/Example/Auth/Tests/FIRAuthBackendCreateAuthURITests.m
index 5d40343..12f2b38 100644
--- a/Example/Auth/Tests/FIRAuthBackendCreateAuthURITests.m
+++ b/Example/Auth/Tests/FIRAuthBackendCreateAuthURITests.m
@@ -68,11 +68,12 @@ static NSString *const kTestProviderID2 = @"facebook.com";
- (void)testRequestAndResponseEncoding {
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
-
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc] initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:requestConfiguration];
__block FIRCreateAuthURIResponse *createAuthURIResponse;
__block NSError *createAuthURIError;
diff --git a/Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m b/Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m
index 5930e13..b50e866 100644
--- a/Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m
+++ b/Example/Auth/Tests/FIRAuthBackendRPCImplementationTests.m
@@ -19,6 +19,7 @@
#import "FIRAuthErrorUtils.h"
#import "FIRAuthInternalErrors.h"
#import "FIRAuthBackend.h"
+#import "FIRAuthRequestConfiguration.h"
#import "FIRAuthRPCRequest.h"
#import "FIRAuthRPCResponse.h"
#import "FIRFakeBackendRPCIssuer.h"
@@ -29,6 +30,11 @@
*/
static NSString *const kFakeRequestURL = @"https://www.google.com/";
+/** @var kFakeAPIkey
+ @brief Used as a fake APIKey for a fake RPC request. We don't test this here.
+ */
+static NSString *const kFakeAPIkey = @"FAKE_API_KEY";
+
/** @var kFakeErrorDomain
@brief A value to use for fake @c NSErrors.
*/
@@ -230,6 +236,12 @@ static NSString *const kTestValue = @"TestValue";
return [NSURL URLWithString:kFakeRequestURL];
}
+- (FIRAuthRequestConfiguration *)requestConfiguration {
+ FIRAuthRequestConfiguration *fakeConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kFakeAPIkey];
+ return fakeConfiguration;
+}
+
- (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
if (error) {
*error = _requestEncodingError;
diff --git a/Example/Auth/Tests/FIRAuthDispatcherTests.m b/Example/Auth/Tests/FIRAuthDispatcherTests.m
index 9b0abc4..fc8cab1 100644
--- a/Example/Auth/Tests/FIRAuthDispatcherTests.m
+++ b/Example/Auth/Tests/FIRAuthDispatcherTests.m
@@ -98,7 +98,7 @@ id<OS_dispatch_queue> testWorkQueue;
XCTFail();
}];
[self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
- dispatcher.dispatchAfterImplementation = nil;;
+ dispatcher.dispatchAfterImplementation = nil;
}
diff --git a/Example/Auth/Tests/FIRAuthTests.m b/Example/Auth/Tests/FIRAuthTests.m
index 299c0d9..8513063 100644
--- a/Example/Auth/Tests/FIRAuthTests.m
+++ b/Example/Auth/Tests/FIRAuthTests.m
@@ -269,7 +269,7 @@ static const NSTimeInterval kWaitInterval = .5;
*/
- (void)testAppAPIkey {
FIRAuth *auth = [FIRAuth auth];
- XCTAssertEqualObjects(auth.APIKey, kAPIKey);
+ XCTAssertEqualObjects(auth.requestConfiguration.APIKey, kAPIKey);
}
/** @fn testAppAssociation
diff --git a/Example/Auth/Tests/FIRCreateAuthURIRequestTests.m b/Example/Auth/Tests/FIRCreateAuthURIRequestTests.m
index 409c232..523c61a 100644
--- a/Example/Auth/Tests/FIRCreateAuthURIRequestTests.m
+++ b/Example/Auth/Tests/FIRCreateAuthURIRequestTests.m
@@ -83,10 +83,12 @@ static NSString *const kExpectedAPIURL =
@brief Tests the encoding of an create auth URI request.
*/
- (void)testEmailVerificationRequest {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc]initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:requestConfiguration];
[FIRAuthBackend createAuthURI:request
callback:^(FIRCreateAuthURIResponse *_Nullable response,
diff --git a/Example/Auth/Tests/FIRCreateAuthURIResponseTests.m b/Example/Auth/Tests/FIRCreateAuthURIResponseTests.m
index 11cab9d..06242a0 100644
--- a/Example/Auth/Tests/FIRCreateAuthURIResponseTests.m
+++ b/Example/Auth/Tests/FIRCreateAuthURIResponseTests.m
@@ -69,10 +69,15 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
@end
@implementation FIRCreateAuthURIResponseTests{
/** @var _RPCIssuer
- @brief This backend RPC issuer is used to fake network responses for each test in the suite.
+ @brief This backend RPC issuer is used to fake network responses for each test in the suite.
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -80,9 +85,11 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -95,7 +102,7 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc]initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRCreateAuthURIResponse *RPCResponse;
@@ -112,7 +119,7 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
XCTAssert(callbackInvoked);
XCTAssertNotNil(RPCError);
- XCTAssertEqual(RPCError.code, FIRAuthErrorCodeInternalError);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeMissingContinueURI);
XCTAssertNil(RPCResponse);
}
@@ -123,7 +130,7 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc]initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRCreateAuthURIResponse *RPCResponse;
@@ -151,7 +158,7 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc]initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRCreateAuthURIResponse *RPCResponse;
@@ -179,7 +186,7 @@ static NSString *const kInvalidEmailErrorMessage = @"INVALID_EMAIL:";
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc]initWithIdentifier:kTestIdentifier
continueURI:kTestContinueURI
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRCreateAuthURIResponse *RPCResponse;
diff --git a/Example/Auth/Tests/FIRDeleteAccountRequestTests.m b/Example/Auth/Tests/FIRDeleteAccountRequestTests.m
index 05f1d47..ebc4ac4 100644
--- a/Example/Auth/Tests/FIRDeleteAccountRequestTests.m
+++ b/Example/Auth/Tests/FIRDeleteAccountRequestTests.m
@@ -78,10 +78,12 @@ static NSString *const kExpectedAPIURL =
@brief Tests the delete account request.
*/
- (void)testDeleteAccountRequest {
-
- FIRDeleteAccountRequest *request = [[FIRDeleteAccountRequest alloc] initWithAPIKey:kTestAPIKey
- localID:kLocalID
- accessToken:kAccessToken];
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
+ FIRDeleteAccountRequest *request =
+ [[FIRDeleteAccountRequest alloc] initWitLocalID:kLocalID
+ accessToken:kAccessToken
+ requestConfiguration:requestConfiguration];
__block BOOL callbackInvoked;
__block NSError *RPCError;
[FIRAuthBackend deleteAccount:request
diff --git a/Example/Auth/Tests/FIRDeleteAccountResponseTests.m b/Example/Auth/Tests/FIRDeleteAccountResponseTests.m
index f75735e..998bff8 100644
--- a/Example/Auth/Tests/FIRDeleteAccountResponseTests.m
+++ b/Example/Auth/Tests/FIRDeleteAccountResponseTests.m
@@ -65,6 +65,11 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -72,9 +77,11 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -84,9 +91,10 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
@brief This test simulates the occurrence of a @c userDisabled error.
*/
- (void)testUserDisabledError {
- FIRDeleteAccountRequest *request = [[FIRDeleteAccountRequest alloc] initWithAPIKey:kTestAPIKey
- localID:kLocalID
- accessToken:kAccessToken];
+ FIRDeleteAccountRequest *request =
+ [[FIRDeleteAccountRequest alloc] initWitLocalID:kLocalID
+ accessToken:kAccessToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block NSError *RPCError;
@@ -107,9 +115,10 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
@brief This test simulates the occurrence of a @c invalidUserToken error.
*/
- (void)testinvalidUserTokenError {
- FIRDeleteAccountRequest *request = [[FIRDeleteAccountRequest alloc] initWithAPIKey:kTestAPIKey
- localID:kLocalID
- accessToken:kAccessToken];
+ FIRDeleteAccountRequest *request =
+ [[FIRDeleteAccountRequest alloc] initWitLocalID:kLocalID
+ accessToken:kAccessToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block NSError *RPCError;
@@ -130,9 +139,10 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
@brief This test simulates the occurrence of a @c credentialTooOld error.
*/
- (void)testrequiredRecentLoginError {
- FIRDeleteAccountRequest *request = [[FIRDeleteAccountRequest alloc] initWithAPIKey:kTestAPIKey
- localID:kLocalID
- accessToken:kAccessToken];
+ FIRDeleteAccountRequest *request =
+ [[FIRDeleteAccountRequest alloc] initWitLocalID:kLocalID
+ accessToken:kAccessToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block NSError *RPCError;
[FIRAuthBackend deleteAccount:request
@@ -152,9 +162,10 @@ static NSString *const kCredentialTooOldErrorMessage = @"CREDENTIAL_TOO_OLD_LOGI
@brief This test simulates a completed succesful deleteAccount operation.
*/
- (void)testSuccessfulDeleteAccountResponse {
- FIRDeleteAccountRequest *request = [[FIRDeleteAccountRequest alloc] initWithAPIKey:kTestAPIKey
- localID:kLocalID
- accessToken:kAccessToken];
+ FIRDeleteAccountRequest *request =
+ [[FIRDeleteAccountRequest alloc] initWitLocalID:kLocalID
+ accessToken:kAccessToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block NSError *RPCError;
[FIRAuthBackend deleteAccount:request
diff --git a/Example/Auth/Tests/FIRFakeBackendRPCIssuer.m b/Example/Auth/Tests/FIRFakeBackendRPCIssuer.m
index 93589e7..bdc7706 100644
--- a/Example/Auth/Tests/FIRFakeBackendRPCIssuer.m
+++ b/Example/Auth/Tests/FIRFakeBackendRPCIssuer.m
@@ -28,10 +28,11 @@ static NSString *const kFakeErrorDomain = @"fake domain";
FIRAuthBackendRPCIssuerCompletionHandler _handler;
}
-- (void)asyncPostToURL:(NSURL *)URL
- body:(NSData *)body
- contentType:(NSString *)contentType
- completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler {
+- (void)asyncPostToURLWithRequestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration
+ URL:(NSURL *)URL
+ body:(NSData *)body
+ contentType:(NSString *)contentType
+ completionHandler:(FIRAuthBackendRPCIssuerCompletionHandler)handler {
_requestURL = [URL copy];
_requestData = body;
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:body options:0 error:nil];
diff --git a/Example/Auth/Tests/FIRGetAccountInfoRequestTests.m b/Example/Auth/Tests/FIRGetAccountInfoRequestTests.m
index 6f713b0..4e4a91d 100644
--- a/Example/Auth/Tests/FIRGetAccountInfoRequestTests.m
+++ b/Example/Auth/Tests/FIRGetAccountInfoRequestTests.m
@@ -71,8 +71,11 @@ static NSString *const kExpectedAPIURL =
@brief Tests the set account info request.
*/
- (void)testGetAccountInfoRequest {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRGetAccountInfoRequest *request =
- [[FIRGetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey accessToken:kTestAccessToken];
+ [[FIRGetAccountInfoRequest alloc] initWithAccessToken:kTestAccessToken
+ requestConfiguration:requestConfiguration];
[FIRAuthBackend getAccountInfo:request callback:^(FIRGetAccountInfoResponse *_Nullable response,
NSError *_Nullable error) {
diff --git a/Example/Auth/Tests/FIRGetAccountInfoResponseTests.m b/Example/Auth/Tests/FIRGetAccountInfoResponseTests.m
index b6c261e..d9433bb 100644
--- a/Example/Auth/Tests/FIRGetAccountInfoResponseTests.m
+++ b/Example/Auth/Tests/FIRGetAccountInfoResponseTests.m
@@ -150,8 +150,11 @@ static NSString *const kEmailVerifiedKey = @"emailVerified";
flow.
*/
- (void)testGetAccountInfoUnexpectedResponseError {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRGetAccountInfoRequest *request =
- [[FIRGetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey accessToken:kTestAccessToken];
+ [[FIRGetAccountInfoRequest alloc] initWithAccessToken:kTestAccessToken
+ requestConfiguration:requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetAccountInfoResponse *RPCResponse;
@@ -184,8 +187,11 @@ static NSString *const kEmailVerifiedKey = @"emailVerified";
@brief This test simulates a successful @c GetAccountInfo flow.
*/
- (void)testSuccessfulGetAccountInfoResponse {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRGetAccountInfoRequest *request =
- [[FIRGetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey accessToken:kTestAccessToken];
+ [[FIRGetAccountInfoRequest alloc] initWithAccessToken:kTestAccessToken
+ requestConfiguration:requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetAccountInfoResponse *RPCResponse;
diff --git a/Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m b/Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m
index d5a22aa..965af8a 100644
--- a/Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m
+++ b/Example/Auth/Tests/FIRGetOOBConfirmationCodeRequestTests.m
@@ -16,6 +16,7 @@
#import <XCTest/XCTest.h>
+#import "FIRActionCodeSettings.h"
#import "FIRAuthErrors.h"
#import "FIRAuthBackend.h"
#import "FIRGetOOBConfirmationCodeRequest.h"
@@ -68,17 +69,74 @@ static NSString *const kAccessTokenKey = @"idToken";
*/
static NSString *const kTestAccessToken = @"ACCESS_TOKEN";
+/** @var kIosBundleID
+ @brief Fake iOS bundle ID for testing.
+ */
+static NSString *const kIosBundleID = @"testBundleID";
+
+/** @var kAndroidPackageName
+ @brief Fake android package name for testing.
+ */
+static NSString *const kAndroidPackageName = @"adroidpackagename";
+
+/** @var kContinueURL
+ @brief Fake string value of continue url.
+ */
+static NSString *const kContinueURL = @"continueURL";
+
+/** @var kAndroidMinimumVersion
+ @brief Fake android minimum version for testing.
+ */
+static NSString *const kAndroidMinimumVersion = @"3.0";
+
+/** @var kContinueURLKey
+ @brief The key for the "continue URL" value in the request.
+ */
+static NSString *const kContinueURLKey = @"continueUrl";
+
+/** @var kIosBundeIDKey
+ @brief The key for the "iOS Bundle Identifier" value in the request.
+ */
+static NSString *const kIosBundleIDKey = @"iOSBundleId";
+
+/** @var kAndroidPackageNameKey
+ @brief The key for the "Android Package Name" value in the request.
+ */
+static NSString *const kAndroidPackageNameKey = @"androidPackageName";
+
+/** @var kAndroidInstallAppKey
+ @brief The key for the request parameter indicating whether the android app should be installed
+ or not.
+ */
+static NSString *const kAndroidInstallAppKey = @"androidInstallApp";
+
+/** @var kAndroidMinimumVersionKey
+ @brief The key for the "minimum Android version supported" value in the request.
+ */
+static NSString *const kAndroidMinimumVersionKey = @"androidMinimumVersion";
+
+/** @var kCanHandleCodeInAppKey
+ @brief The key for the request parameter indicating whether the action code can be handled in
+ the app or not.
+ */
+static NSString *const kCanHandleCodeInAppKey = @"canHandleCodeInApp";
+
/** @class FIRGetOOBConfirmationCodeRequestTests
@brief Tests for @c FIRGetOOBConfirmationCodeRequest.
*/
@interface FIRGetOOBConfirmationCodeRequestTests : XCTestCase
@end
@implementation FIRGetOOBConfirmationCodeRequestTests {
- /** @var _RPCIssuer
+ /** @var _RPCIssuer
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -86,9 +144,11 @@ static NSString *const kTestAccessToken = @"ACCESS_TOKEN";
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -100,7 +160,8 @@ static NSString *const kTestAccessToken = @"ACCESS_TOKEN";
- (void)testPasswordResetRequest {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -118,15 +179,26 @@ static NSString *const kTestAccessToken = @"ACCESS_TOKEN";
XCTAssert([_RPCIssuer.decodedRequest isKindOfClass:[NSDictionary class]]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kEmailKey], kTestEmail);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kRequestTypeKey], kPasswordResetRequestTypeValue);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kContinueURLKey], kContinueURL);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kIosBundleIDKey], kIosBundleID);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidPackageNameKey], kAndroidPackageName);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidMinimumVersionKey],
+ kAndroidMinimumVersion);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidInstallAppKey],
+ [NSNumber numberWithBool:YES]);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kCanHandleCodeInAppKey],
+ [NSNumber numberWithBool:YES]);
}
/** @fn testEmailVerificationRequest
@brief Tests the encoding of an email verification request.
*/
- (void)testEmailVerificationRequest {
+ FIRActionCodeSettings *testSettings = [self fakeActionCodeSettings];
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest verifyEmailRequestWithAccessToken:kTestAccessToken
- APIKey:kTestAPIKey];
+ actionCodeSettings:testSettings
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -144,6 +216,32 @@ static NSString *const kTestAccessToken = @"ACCESS_TOKEN";
XCTAssert([_RPCIssuer.decodedRequest isKindOfClass:[NSDictionary class]]);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAccessTokenKey], kTestAccessToken);
XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kRequestTypeKey], kVerifyEmailRequestTypeValue);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kContinueURLKey], kContinueURL);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kIosBundleIDKey], kIosBundleID);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidPackageNameKey], kAndroidPackageName);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidMinimumVersionKey],
+ kAndroidMinimumVersion);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kAndroidInstallAppKey],
+ [NSNumber numberWithBool:YES]);
+ XCTAssertEqualObjects(_RPCIssuer.decodedRequest[kCanHandleCodeInAppKey],
+ [NSNumber numberWithBool:YES]);
+}
+
+#pragma mark - Helpers
+
+/** @fn fakeActionCodeSettings
+ @brief Constructs and returns a fake instance of @c FIRActionCodeSettings for testing.
+ @return An instance of @c FIRActionCodeSettings for testing.
+ */
+- (FIRActionCodeSettings *)fakeActionCodeSettings {
+ FIRActionCodeSettings *actionCodeSettings = [[FIRActionCodeSettings alloc]init];
+ [actionCodeSettings setIOSBundleID:kIosBundleID];
+ [actionCodeSettings setAndroidPackageName:kAndroidPackageName
+ installIfNotAvailable:YES
+ minimumVersion:kAndroidMinimumVersion];
+ actionCodeSettings.handleCodeInApp = YES;
+ actionCodeSettings.URL = [NSURL URLWithString:kContinueURL];
+ return actionCodeSettings;
}
@end
diff --git a/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m b/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m
index 98c9d8e..71ab41c 100644
--- a/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m
+++ b/Example/Auth/Tests/FIRGetOOBConfirmationCodeResponseTests.m
@@ -16,6 +16,7 @@
#import <XCTest/XCTest.h>
+#import "FIRActionCodeSettings.h"
#import "FIRAuthErrors.h"
#import "FIRAuthBackend.h"
#import "FIRGetOOBConfirmationCodeRequest.h"
@@ -69,6 +70,23 @@ static NSString *const kInvalidMessagePayloadErrorMessage = @"INVALID_MESSAGE_PA
*/
static NSString *const kInvalidSenderErrorMessage = @"INVALID_SENDER";
+/** @var kMissingIosBundleIDErrorMessage
+ @brief This is the error message the server will respond with if iOS bundle ID is missing but
+ the iOS App store ID is provided.
+ */
+static NSString *const kMissingIosBundleIDErrorMessage = @"MISSING_IOS_BUNDLE_ID";
+
+/** @var kMissingAndroidPackageNameErrorMessage
+ @brief This is the error message the server will respond with if Android Package Name is missing
+ but the flag indicating the app should be installed is set to true.
+ */
+static NSString *const kMissingAndroidPackageNameErrorMessage = @"MISSING_ANDROID_PACKAGE_NAME";
+
+/** @var kUnauthorizedDomainErrorMessage
+ @brief This is the error message the server will respond with if the domain of the continue URL
+ specified is not whitelisted in the firebase console.
+ */
+static NSString *const kUnauthorizedDomainErrorMessage = @"ERROR_UNAUTHORIZED_DOMAIN";
/** @var kInvalidRecipientEmailErrorMessage
@brief This is the prefix for the error message the server responds with if the recipient email
@@ -76,6 +94,23 @@ static NSString *const kInvalidSenderErrorMessage = @"INVALID_SENDER";
*/
static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_EMAIL";
+/** @var kInvalidContinueURIErrorMessage
+ @brief This is the error returned by the backend if the continue URL provided in the request
+ is invalid.
+ */
+static NSString *const kInvalidContinueURIErrorMessage = @"INVALID_CONTINUE_URI";
+
+/** @var kMissingContinueURIErrorMessage
+ @brief This is the error message the server will respond with if there was no continue URI
+ present in a request that required one.
+ */
+static NSString *const kMissingContinueURIErrorMessage = @"MISSING_CONTINUE_URI";
+
+/** @var kIosBundleID
+ @brief Fake iOS bundle ID for testing.
+ */
+static NSString *const kIosBundleID = @"testBundleID";
+
/** @class FIRGetOOBConfirmationCodeResponseTests
@brief Tests for @c FIRGetOOBConfirmationCodeResponse.
*/
@@ -87,6 +122,11 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -94,9 +134,11 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -109,7 +151,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testSuccessfulPasswordResetResponse {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -139,7 +182,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testSuccessfulPasswordResetResponseWithoutOOBCode {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -167,7 +211,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testEmailNotFoundError {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -195,7 +240,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testInvalidEmailError {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -222,7 +268,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testInvalidMessagePayloadError {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -246,7 +293,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testInvalidSenderError {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -264,13 +312,139 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
XCTAssertEqual(RPCError.code, FIRAuthErrorCodeInvalidSender);
}
+/** @fn testMissingIosBundleIDError
+ @brief Tests for @c FIRAuthErrorCodeMissingIosBundleID.
+ */
+- (void)testMissingIosBundleIDError {
+ FIRGetOOBConfirmationCodeRequest *request =
+ [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
+
+ __block BOOL callbackInvoked;
+ __block FIRGetOOBConfirmationCodeResponse *RPCResponse;
+ __block NSError *RPCError;
+ [FIRAuthBackend getOOBConfirmationCode:request
+ callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ callbackInvoked = YES;
+ RPCResponse = response;
+ RPCError = error;
+ }];
+ [_RPCIssuer respondWithServerErrorMessage:kMissingIosBundleIDErrorMessage];
+ XCTAssert(callbackInvoked);
+ XCTAssertNil(RPCResponse);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeMissingIosBundleID);
+}
+
+/** @fn testMissingAndroidPackageNameError
+ @brief Tests for @c FIRAuthErrorCodeMissingAndroidPackageName.
+ */
+- (void)testMissingAndroidPackageNameError {
+ FIRGetOOBConfirmationCodeRequest *request =
+ [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
+
+ __block BOOL callbackInvoked;
+ __block FIRGetOOBConfirmationCodeResponse *RPCResponse;
+ __block NSError *RPCError;
+ [FIRAuthBackend getOOBConfirmationCode:request
+ callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ callbackInvoked = YES;
+ RPCResponse = response;
+ RPCError = error;
+ }];
+ [_RPCIssuer respondWithServerErrorMessage:kMissingAndroidPackageNameErrorMessage];
+ XCTAssert(callbackInvoked);
+ XCTAssertNil(RPCResponse);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeMissingAndroidPackageName);
+}
+
+/** @fn testUnauthorizedDomainError
+ @brief Tests for @c FIRAuthErrorCodeUnauthorizedDomain.
+ */
+- (void)testUnauthorizedDomainError {
+ FIRGetOOBConfirmationCodeRequest *request =
+ [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
+
+ __block BOOL callbackInvoked;
+ __block FIRGetOOBConfirmationCodeResponse *RPCResponse;
+ __block NSError *RPCError;
+ [FIRAuthBackend getOOBConfirmationCode:request
+ callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ callbackInvoked = YES;
+ RPCResponse = response;
+ RPCError = error;
+ }];
+ [_RPCIssuer respondWithServerErrorMessage:kUnauthorizedDomainErrorMessage];
+ XCTAssert(callbackInvoked);
+ XCTAssertNil(RPCResponse);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeUnauthorizedDomain);
+}
+
+/** @fn testInvalidContinueURIError
+ @brief Tests for @c FIRAuthErrorCodeInvalidContinueAuthURI.
+ */
+- (void)testInvalidContinueURIError {
+ FIRGetOOBConfirmationCodeRequest *request =
+ [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
+
+ __block BOOL callbackInvoked;
+ __block FIRGetOOBConfirmationCodeResponse *RPCResponse;
+ __block NSError *RPCError;
+ [FIRAuthBackend getOOBConfirmationCode:request
+ callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ callbackInvoked = YES;
+ RPCResponse = response;
+ RPCError = error;
+ }];
+ [_RPCIssuer respondWithServerErrorMessage:kInvalidContinueURIErrorMessage];
+ XCTAssert(callbackInvoked);
+ XCTAssertNil(RPCResponse);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeInvalidContinueURI);
+}
+
+/** @fn testMissingContinueURIError
+ @brief Tests for @c FIRAuthErrorCodeMissingContinueURI.
+ */
+- (void)testMissingContinueURIError {
+ FIRGetOOBConfirmationCodeRequest *request =
+ [FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
+
+ __block BOOL callbackInvoked;
+ __block FIRGetOOBConfirmationCodeResponse *RPCResponse;
+ __block NSError *RPCError;
+ [FIRAuthBackend getOOBConfirmationCode:request
+ callback:^(FIRGetOOBConfirmationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ callbackInvoked = YES;
+ RPCResponse = response;
+ RPCError = error;
+ }];
+ [_RPCIssuer respondWithServerErrorMessage:kMissingContinueURIErrorMessage];
+ XCTAssert(callbackInvoked);
+ XCTAssertNil(RPCResponse);
+ XCTAssertEqual(RPCError.code, FIRAuthErrorCodeMissingContinueURI);
+}
+
/** @fn testInvalidRecipientEmailError
@brief Tests for @c FIRAuthErrorCodeInvalidRecipientEmail.
*/
- (void)testInvalidRecipientEmailError {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
@@ -295,7 +469,8 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
- (void)testSuccessfulEmailVerificationResponse {
FIRGetOOBConfirmationCodeRequest *request =
[FIRGetOOBConfirmationCodeRequest passwordResetRequestWithEmail:kTestEmail
- APIKey:kTestAPIKey];
+ actionCodeSettings:[self fakeActionCodeSettings]
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRGetOOBConfirmationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -317,4 +492,16 @@ static NSString *const kInvalidRecipientEmailErrorMessage = @"INVALID_RECIPIENT_
XCTAssertEqualObjects(RPCResponse.OOBCode, kTestOOBCode);
}
+#pragma mark - Helpers
+
+/** @fn fakeActionCodeSettings
+ @brief Constructs and returns a fake instance of @c FIRActionCodeSettings for testing.
+ @return An instance of @c FIRActionCodeSettings for testing.
+ */
+- (FIRActionCodeSettings *)fakeActionCodeSettings {
+ FIRActionCodeSettings *actionCodeSettings = [[FIRActionCodeSettings alloc] init];
+ [actionCodeSettings setIOSBundleID:kIosBundleID];
+ return actionCodeSettings;
+}
+
@end
diff --git a/Example/Auth/Tests/FIRGitHubAuthProviderTests.m b/Example/Auth/Tests/FIRGitHubAuthProviderTests.m
index 7d02d74..6ac3792 100644
--- a/Example/Auth/Tests/FIRGitHubAuthProviderTests.m
+++ b/Example/Auth/Tests/FIRGitHubAuthProviderTests.m
@@ -42,9 +42,12 @@ static NSString *const kAPIKey = @"APIKey";
the appropriate fields in a verify assertion request.
*/
- (void)testCredentialWithToken {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kAPIKey];
FIRAuthCredential *credential = [FIRGitHubAuthProvider credentialWithToken:kGitHubToken];
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kAPIKey providerID:FIRGitHubAuthProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:FIRGitHubAuthProviderID
+ requestConfiguration:requestConfiguration];
[credential prepareVerifyAssertionRequest:request];
XCTAssertEqualObjects(request.providerAccessToken, kGitHubToken);
}
diff --git a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m
index 71bdd5d..05f3774 100644
--- a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m
+++ b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m
@@ -86,11 +86,6 @@ static NSString *const kTestVerificationCode = @"verificationCode";
*/
static const NSTimeInterval kTestTimeout = 5;
-/** @var kAPIKey
- @brief The fake API key.
- */
-static NSString *const kAPIKey = @"FAKE_API_KEY";
-
/** @var kExpectationTimeout
@brief The maximum time waiting for expectations to fulfill.
*/
diff --git a/Example/Auth/Tests/FIRResetPasswordRequestTests.m b/Example/Auth/Tests/FIRResetPasswordRequestTests.m
index d0ccc5d..50cd2fb 100644
--- a/Example/Auth/Tests/FIRResetPasswordRequestTests.m
+++ b/Example/Auth/Tests/FIRResetPasswordRequestTests.m
@@ -84,10 +84,12 @@ static NSString *const kExpectedAPIURL =
@brief Tests the reset password reqeust.
*/
- (void)testResetPasswordRequest {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:requestConfiguration];
[FIRAuthBackend resetPassword:request callback:^(FIRResetPasswordResponse *_Nullable response,
NSError *_Nullable error) {
diff --git a/Example/Auth/Tests/FIRResetPasswordResponseTests.m b/Example/Auth/Tests/FIRResetPasswordResponseTests.m
index 51f1155..a6a7cbb 100644
--- a/Example/Auth/Tests/FIRResetPasswordResponseTests.m
+++ b/Example/Auth/Tests/FIRResetPasswordResponseTests.m
@@ -92,11 +92,16 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
@end
@implementation FIRResetPasswordResponseTests {
- /** @var _RPCIssuer
+ /** @var _RPCIssuer
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -104,9 +109,11 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -117,9 +124,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testUserDisabledError {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -140,9 +147,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testOperationNotAllowedError {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -163,9 +170,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testOOBExpiredError {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -186,9 +193,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testOOBInvalidError {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -209,9 +216,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testWeakPasswordError {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -232,9 +239,9 @@ static NSString *const kExpectedResetPasswordRequestType = @"PASSWORD_RESET";
*/
- (void)testSuccessfulResetPassword {
FIRResetPasswordRequest *request =
- [[FIRResetPasswordRequest alloc] initWithAPIKey:kTestAPIKey
- oobCode:kTestOOBCode
- newPassword:kTestNewPassword];
+ [[FIRResetPasswordRequest alloc] initWithOobCode:kTestOOBCode
+ newPassword:kTestNewPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRResetPasswordResponse *RPCResponse;
__block NSError *RPCError;
diff --git a/Example/Auth/Tests/FIRSendVerificationCodeRequestTests.m b/Example/Auth/Tests/FIRSendVerificationCodeRequestTests.m
index 5582d32..0f0b420 100644
--- a/Example/Auth/Tests/FIRSendVerificationCodeRequestTests.m
+++ b/Example/Auth/Tests/FIRSendVerificationCodeRequestTests.m
@@ -94,12 +94,14 @@ static NSString *const kExpectedAPIURL =
@brief Tests the sendVerificationCode request.
*/
- (void)testSendVerificationCodeRequest {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
FIRAuthAppCredential *credential =
[[FIRAuthAppCredential alloc]initWithReceipt:kTestReceipt secret:kTestSecret];
FIRSendVerificationCodeRequest *request =
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:kTestPhoneNumber
appCredential:credential
- APIKey:kTestAPIKey];
+ requestConfiguration:requestConfiguration];
XCTAssertEqualObjects(request.phoneNumber, kTestPhoneNumber);
XCTAssertEqualObjects(request.appCredential.receipt, kTestReceipt);
XCTAssertEqualObjects(request.appCredential.secret, kTestSecret);
diff --git a/Example/Auth/Tests/FIRSendVerificationCodeResponseTests.m b/Example/Auth/Tests/FIRSendVerificationCodeResponseTests.m
index 5a1244b..6f917ce 100644
--- a/Example/Auth/Tests/FIRSendVerificationCodeResponseTests.m
+++ b/Example/Auth/Tests/FIRSendVerificationCodeResponseTests.m
@@ -84,20 +84,28 @@ static NSString *const kAppNotVerifiedErrorMessage = @"APP_NOT_VERIFIED";
@end
@implementation FIRSendVerificationCodeResponseTests {
- /** @var _RPCIssuer
+ /** @var _RPCIssuer
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
+ [super setUp];
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -112,7 +120,7 @@ static NSString *const kAppNotVerifiedErrorMessage = @"APP_NOT_VERIFIED";
FIRSendVerificationCodeRequest *request =
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:kTestInvalidPhoneNumber
appCredential:credential
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSendVerificationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -140,7 +148,7 @@ static NSString *const kAppNotVerifiedErrorMessage = @"APP_NOT_VERIFIED";
FIRSendVerificationCodeRequest *request =
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:kTestPhoneNumber
appCredential:credential
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSendVerificationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -169,7 +177,7 @@ static NSString *const kAppNotVerifiedErrorMessage = @"APP_NOT_VERIFIED";
FIRSendVerificationCodeRequest *request =
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:kTestPhoneNumber
appCredential:credential
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSendVerificationCodeResponse *RPCResponse;
__block NSError *RPCError;
@@ -197,7 +205,7 @@ static NSString *const kAppNotVerifiedErrorMessage = @"APP_NOT_VERIFIED";
FIRSendVerificationCodeRequest *request =
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:kTestPhoneNumber
appCredential:credential
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSendVerificationCodeResponse *RPCResponse;
__block NSError *RPCError;
diff --git a/Example/Auth/Tests/FIRSetAccountInfoRequestTests.m b/Example/Auth/Tests/FIRSetAccountInfoRequestTests.m
index 54d8ff0..4301fa1 100644
--- a/Example/Auth/Tests/FIRSetAccountInfoRequestTests.m
+++ b/Example/Auth/Tests/FIRSetAccountInfoRequestTests.m
@@ -190,6 +190,11 @@ static NSString *const kExpectedAPIURL =
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -197,10 +202,12 @@ static NSString *const kExpectedAPIURL =
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -209,7 +216,8 @@ static NSString *const kExpectedAPIURL =
@brief Tests the set account info request.
*/
- (void)testSetAccountInfoRequest {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
request.returnSecureToken = NO;
[FIRAuthBackend setAccountInfo:request
callback:^(FIRSetAccountInfoResponse *_Nullable response,
@@ -240,7 +248,8 @@ static NSString *const kExpectedAPIURL =
@brief Tests the set account info request with optional fields.
*/
- (void)testSetAccountInfoRequestOptionalFields {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
request.accessToken = kTestAccessToken;
request.displayName = kTestDisplayName;
request.localID = kTestLocalID;
diff --git a/Example/Auth/Tests/FIRSetAccountInfoResponseTests.m b/Example/Auth/Tests/FIRSetAccountInfoResponseTests.m
index 1107bee..2506e1a 100644
--- a/Example/Auth/Tests/FIRSetAccountInfoResponseTests.m
+++ b/Example/Auth/Tests/FIRSetAccountInfoResponseTests.m
@@ -172,6 +172,11 @@ static const double kAllowedTimeDifference = 0.1;
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -179,10 +184,12 @@ static const double kAllowedTimeDifference = 0.1;
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -192,7 +199,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeEmailExists error.
*/
- (void)testEmailExistsError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -216,7 +224,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeOperationNotAllowed error.
*/
- (void)testEmailSignUpNotAllowedError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -240,7 +249,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeOperationNotAllowed error.
*/
- (void)testPasswordLoginDisabledError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -263,7 +273,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c testUserDisabledError with @c FIRAuthErrorCodeUserDisabled error.
*/
- (void)testUserDisabledError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -287,7 +298,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeCredentialTooOld error.
*/
- (void)testInvalidUserTokenError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -311,7 +323,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeRequiresRecentLogin error.
*/
- (void)testrequiresRecentLogin {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -334,7 +347,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c FIRAuthErrorCodeWeakPassword error.
*/
- (void)testWeakPasswordError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -359,7 +373,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c FIRAuthErrorCodeInvalidEmail error code.
*/
- (void)testInvalidEmailError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -382,7 +397,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c FIRAuthErrorCodeInvalidActionCode error code.
*/
- (void)testInvalidActionCodeError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -405,7 +421,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c FIRAuthErrorCodeExpiredActionCode error code.
*/
- (void)testExpiredActionCodeError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -428,7 +445,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief Tests for @c FIRAuthErrorCodeInvalidMessagePayload.
*/
- (void)testInvalidMessagePayloadError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -450,7 +468,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief Tests for @c FIRAuthErrorCodeInvalidSender.
*/
- (void)testInvalidSenderError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -472,7 +491,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief Tests for @c FIRAuthErrorCodeInvalidRecipientEmail.
*/
- (void)testInvalidRecipientEmailError {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
@@ -494,7 +514,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates a successful @c SetAccountInfo flow.
*/
- (void)testSuccessfulSetAccountInfoResponse {
- FIRSetAccountInfoRequest *request = [[FIRSetAccountInfoRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSetAccountInfoRequest *request =
+ [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSetAccountInfoResponse *RPCResponse;
diff --git a/Example/Auth/Tests/FIRSignUpNewUserRequestTests.m b/Example/Auth/Tests/FIRSignUpNewUserRequestTests.m
index 622ec7c..3e0cbdf 100644
--- a/Example/Auth/Tests/FIRSignUpNewUserRequestTests.m
+++ b/Example/Auth/Tests/FIRSignUpNewUserRequestTests.m
@@ -79,6 +79,11 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -86,9 +91,11 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -98,7 +105,8 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
@brief Tests the encoding of a sign up new user request when user is signed in anonymously.
*/
- (void)testSignUpNewUserRequestAnonymous {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
request.returnSecureToken = NO;
[FIRAuthBackend signUpNewUser:request
callback:^(FIRSignUpNewUserResponse *_Nullable response,
@@ -119,10 +127,10 @@ static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
*/
- (void)testSignUpNewUserRequestNotAnonymous {
FIRSignUpNewUserRequest *request =
- [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey
- email:kTestEmail
- password:kTestPassword
- displayName:kTestDisplayName];
+ [[FIRSignUpNewUserRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ displayName:kTestDisplayName
+ requestConfiguration:_requestConfiguration];
[FIRAuthBackend signUpNewUser:request
callback:^(FIRSignUpNewUserResponse *_Nullable response,
NSError *_Nullable error) {
diff --git a/Example/Auth/Tests/FIRSignUpNewUserResponseTests.m b/Example/Auth/Tests/FIRSignUpNewUserResponseTests.m
index ee0c785..cfe4a15 100644
--- a/Example/Auth/Tests/FIRSignUpNewUserResponseTests.m
+++ b/Example/Auth/Tests/FIRSignUpNewUserResponseTests.m
@@ -117,22 +117,29 @@ static const double kAllowedTimeDifference = 0.1;
@interface FIRSignUpNewUserResponseTests : XCTestCase
@end
-@implementation FIRSignUpNewUserResponseTests
+@implementation FIRSignUpNewUserResponseTests {
/** @var _RPCIssuer
@brief This backend RPC issuer is used to fake network responses for each test in the suite.
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
+}
- (void)setUp {
[super setUp];
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -142,10 +149,10 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testSuccessfulSignUp {
FIRSignUpNewUserRequest *request =
- [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey
- email:kTestEmail
+ [[FIRSignUpNewUserRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- displayName:kTestDisplayName];
+ displayName:kTestDisplayName
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
@@ -178,7 +185,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeEmailAlreadyInUse error.
*/
- (void)testSignUpNewUserEmailAlreadyInUseError {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
@@ -201,7 +209,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeOperationNotAllowed error.
*/
- (void)testSignUpNewUserOperationNotAllowedError {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
@@ -224,7 +233,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorCodeOperationNotAllowed error.
*/
- (void)testSignUpNewUserPasswordLoginDisabledError {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
@@ -247,7 +257,8 @@ static const double kAllowedTimeDifference = 0.1;
FIRAuthErrorInvalidEmail error as a result.
*/
- (void)testInvalidEmailError {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
@@ -269,7 +280,8 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates @c FIRAuthErrorCodeWeakPassword error.
*/
- (void)testSignUpNewUserWeakPasswordError {
- FIRSignUpNewUserRequest *request = [[FIRSignUpNewUserRequest alloc] initWithAPIKey:kTestAPIKey];
+ FIRSignUpNewUserRequest *request =
+ [[FIRSignUpNewUserRequest alloc] initWithRequestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRSignUpNewUserResponse *RPCResponse;
diff --git a/Example/Auth/Tests/FIRTwitterAuthProviderTests.m b/Example/Auth/Tests/FIRTwitterAuthProviderTests.m
index 5b9c0fc..d7b7c71 100644
--- a/Example/Auth/Tests/FIRTwitterAuthProviderTests.m
+++ b/Example/Auth/Tests/FIRTwitterAuthProviderTests.m
@@ -49,9 +49,11 @@ static NSString *const kAPIKey = @"APIKey";
- (void)testCredentialWithToken {
FIRAuthCredential *credential =
[FIRTwitterAuthProvider credentialWithToken:kTwitterToken secret:kTwitterSecret];
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kAPIKey];
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kAPIKey
- providerID:FIRTwitterAuthProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:FIRTwitterAuthProviderID
+ requestConfiguration:requestConfiguration];
[credential prepareVerifyAssertionRequest:request];
XCTAssertEqualObjects(request.providerAccessToken, kTwitterToken);
XCTAssertEqualObjects(request.providerOAuthTokenSecret, kTwitterSecret);
diff --git a/Example/Auth/Tests/FIRVerifyAssertionRequestTests.m b/Example/Auth/Tests/FIRVerifyAssertionRequestTests.m
index becc420..2bb9b88 100644
--- a/Example/Auth/Tests/FIRVerifyAssertionRequestTests.m
+++ b/Example/Auth/Tests/FIRVerifyAssertionRequestTests.m
@@ -131,6 +131,11 @@ static NSString *const kAutoCreateKey = @"autoCreate";
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -138,10 +143,12 @@ static NSString *const kAutoCreateKey = @"autoCreate";
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -153,7 +160,8 @@ static NSString *const kAutoCreateKey = @"autoCreate";
*/
- (void)testVerifyAssertionRequestMissingTokens {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
FIRVerifyAssertionResponseCallback callback =
^(FIRVerifyAssertionResponse *_Nullable response, NSError *_Nullable error) {};
@@ -172,7 +180,8 @@ static NSString *const kAutoCreateKey = @"autoCreate";
*/
- (void)testVerifyAssertionRequestProviderAccessToken {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerAccessToken = kTestProviderAccessToken;
request.returnSecureToken = NO;
[FIRAuthBackend verifyAssertion:request
@@ -199,7 +208,8 @@ static NSString *const kAutoCreateKey = @"autoCreate";
*/
- (void)testVerifyAssertionRequestOptionalFields {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
request.providerAccessToken = kTestProviderAccessToken;
request.accessToken = kTestAccessToken;
diff --git a/Example/Auth/Tests/FIRVerifyAssertionResponseTests.m b/Example/Auth/Tests/FIRVerifyAssertionResponseTests.m
index 34edf39..923a9e5 100644
--- a/Example/Auth/Tests/FIRVerifyAssertionResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyAssertionResponseTests.m
@@ -159,6 +159,11 @@ static const double kAllowedTimeDifference = 0.1;
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
/** @fn profile
@@ -183,10 +188,12 @@ static const double kAllowedTimeDifference = 0.1;
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -197,7 +204,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testInvalidIDPResponseError {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -224,7 +232,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testUserDisabledError {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -250,7 +259,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testCredentialAlreadyInUseError {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -276,7 +286,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testOperationNotAllowedError {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -302,7 +313,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testPasswordLoginDisabledError {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -328,7 +340,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testSuccessfulVerifyAssertionResponse {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
@@ -374,7 +387,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testSuccessfulVerifyAssertionResponseWithTextData {
FIRVerifyAssertionRequest *request =
- [[FIRVerifyAssertionRequest alloc] initWithAPIKey:kTestAPIKey providerID:kTestProviderID];
+ [[FIRVerifyAssertionRequest alloc] initWithProviderID:kTestProviderID
+ requestConfiguration:_requestConfiguration];
request.providerIDToken = kTestProviderIDToken;
__block BOOL callbackInvoked;
diff --git a/Example/Auth/Tests/FIRVerifyClientRequestTest.m b/Example/Auth/Tests/FIRVerifyClientRequestTest.m
index dcb00f6..31d4ca8 100644
--- a/Example/Auth/Tests/FIRVerifyClientRequestTest.m
+++ b/Example/Auth/Tests/FIRVerifyClientRequestTest.m
@@ -78,10 +78,12 @@ static NSString *const kExpectedAPIURL =
@brief Tests the verify client request.
*/
- (void)testVerifyClientRequest {
+ FIRAuthRequestConfiguration *requestConfiguration =
+ [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kFakeAPIKey];
FIRVerifyClientRequest *request =
[[FIRVerifyClientRequest alloc] initWithAppToken:kFakeAppToken
isSandbox:YES
- APIKey:kFakeAPIKey];
+ requestConfiguration:requestConfiguration];
[FIRAuthBackend verifyClient:request callback:^(FIRVerifyClientResponse *_Nullable response,
NSError *_Nullable error) {
}];
diff --git a/Example/Auth/Tests/FIRVerifyClientResponseTests.m b/Example/Auth/Tests/FIRVerifyClientResponseTests.m
index 8077ace..b34ab27 100644
--- a/Example/Auth/Tests/FIRVerifyClientResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyClientResponseTests.m
@@ -89,12 +89,19 @@ static NSString *const kInvalidAppCredentialErrorMessage = @"INVALID_APP_CREDENT
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
+ [super setUp];
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kFakeAPIKey];
}
/** @fn testMissingAppCredentialError
@@ -104,7 +111,7 @@ static NSString *const kInvalidAppCredentialErrorMessage = @"INVALID_APP_CREDENT
FIRVerifyClientRequest *request =
[[FIRVerifyClientRequest alloc] initWithAppToken:kFakeAppToken
isSandbox:YES
- APIKey:kFakeAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyClientResponse *RPCResponse;
__block NSError *RPCError;
@@ -128,7 +135,7 @@ static NSString *const kInvalidAppCredentialErrorMessage = @"INVALID_APP_CREDENT
FIRVerifyClientRequest *request =
[[FIRVerifyClientRequest alloc] initWithAppToken:kFakeAppToken
isSandbox:YES
- APIKey:kFakeAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyClientResponse *RPCResponse;
__block NSError *RPCError;
@@ -152,7 +159,7 @@ static NSString *const kInvalidAppCredentialErrorMessage = @"INVALID_APP_CREDENT
FIRVerifyClientRequest *request =
[[FIRVerifyClientRequest alloc] initWithAppToken:kFakeAppToken
isSandbox:YES
- APIKey:kFakeAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyClientResponse *RPCResponse;
__block NSError *RPCError;
diff --git a/Example/Auth/Tests/FIRVerifyCustomTokenRequestTests.m b/Example/Auth/Tests/FIRVerifyCustomTokenRequestTests.m
index 9f65f73..66ac3b2 100644
--- a/Example/Auth/Tests/FIRVerifyCustomTokenRequestTests.m
+++ b/Example/Auth/Tests/FIRVerifyCustomTokenRequestTests.m
@@ -57,6 +57,11 @@ static NSString *const kExpectedAPIURL =
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -64,10 +69,12 @@ static NSString *const kExpectedAPIURL =
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -77,7 +84,8 @@ static NSString *const kExpectedAPIURL =
*/
- (void)testVerifyCustomTokenRequest {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
request.returnSecureToken = NO;
[FIRAuthBackend verifyCustomToken:request
callback:^(FIRVerifyCustomTokenResponse *_Nullable response,
@@ -95,7 +103,8 @@ static NSString *const kExpectedAPIURL =
*/
- (void)testVerifyCustomTokenRequestOptionalFields {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
[FIRAuthBackend verifyCustomToken:request
callback:^(FIRVerifyCustomTokenResponse *_Nullable response,
NSError *_Nullable error) {
diff --git a/Example/Auth/Tests/FIRVerifyCustomTokenResponseTests.m b/Example/Auth/Tests/FIRVerifyCustomTokenResponseTests.m
index dd175fd..b1d9d97 100644
--- a/Example/Auth/Tests/FIRVerifyCustomTokenResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyCustomTokenResponseTests.m
@@ -115,6 +115,11 @@ static const double kAllowedTimeDifference = 0.1;
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -122,10 +127,12 @@ static const double kAllowedTimeDifference = 0.1;
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -136,7 +143,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testInvalidCustomTokenError {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyCustomTokenResponse *RPCResponse;
@@ -162,7 +170,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testInvalidCustomTokenServerError {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyCustomTokenResponse *RPCResponse;
@@ -192,7 +201,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testEmptyServerDetailMessage {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyCustomTokenResponse *RPCResponse;
@@ -220,7 +230,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testInvalidCredentialMismatchError {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyCustomTokenResponse *RPCResponse;
@@ -245,7 +256,8 @@ static const double kAllowedTimeDifference = 0.1;
*/
- (void)testSuccessfulVerifyCustomTokenResponse {
FIRVerifyCustomTokenRequest *request =
- [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken APIKey:kTestAPIKey];
+ [[FIRVerifyCustomTokenRequest alloc] initWithToken:kTestToken
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyCustomTokenResponse *RPCResponse;
diff --git a/Example/Auth/Tests/FIRVerifyPasswordRequestTest.m b/Example/Auth/Tests/FIRVerifyPasswordRequestTest.m
index f07afdc..54ba7b0 100644
--- a/Example/Auth/Tests/FIRVerifyPasswordRequestTest.m
+++ b/Example/Auth/Tests/FIRVerifyPasswordRequestTest.m
@@ -99,6 +99,11 @@ static NSString *const kExpectedAPIURL =
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -106,10 +111,12 @@ static NSString *const kExpectedAPIURL =
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -120,7 +127,7 @@ static NSString *const kExpectedAPIURL =
- (void)testVerifyPasswordRequest {
FIRVerifyPasswordRequest * request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
request.returnSecureToken = NO;
[FIRAuthBackend verifyPassword:request
callback:^(FIRVerifyPasswordResponse *_Nullable response,
@@ -142,7 +149,7 @@ static NSString *const kExpectedAPIURL =
- (void)testVerifyPasswordRequestOptionalFields {
FIRVerifyPasswordRequest * request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
request.pendingIDToken = kTestPendingToken;
request.captchaChallenge = kTestCaptchaChallenge;
request.captchaResponse = kTestCaptchaResponse;
diff --git a/Example/Auth/Tests/FIRVerifyPasswordResponseTests.m b/Example/Auth/Tests/FIRVerifyPasswordResponseTests.m
index b8fc81b..b980847 100644
--- a/Example/Auth/Tests/FIRVerifyPasswordResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyPasswordResponseTests.m
@@ -176,21 +176,29 @@ static const double kAllowedTimeDifference = 0.1;
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
+ [super setUp];
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
/** @fn testUserDisabledError
@brief Tests that @c FIRAuthErrorCodeUserDisabled error is received if the email is disabled.
*/
- (void)testUserDisabledError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -211,9 +219,10 @@ static const double kAllowedTimeDifference = 0.1;
@brief Tests that @c FIRAuthErrorCodeEmailNotFound error is received if the email is not found.
*/
- (void)testEmailNotFoundError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -235,9 +244,10 @@ static const double kAllowedTimeDifference = 0.1;
invalid.
*/
- (void)testInvalidPasswordError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -259,9 +269,10 @@ static const double kAllowedTimeDifference = 0.1;
incorrect format.
*/
- (void)testInvalidEmailError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -283,9 +294,10 @@ static const double kAllowedTimeDifference = 0.1;
attempts were made.
*/
- (void)testTooManySignInAttemptsError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -306,9 +318,10 @@ static const double kAllowedTimeDifference = 0.1;
@brief Tests that @c FIRAuthErrorCodeInvalidApiKey error is received from the server.
*/
- (void)testKeyInvalid {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -336,9 +349,10 @@ static const double kAllowedTimeDifference = 0.1;
@brief This test simulates a @c FIRAuthErrorCodeOperationNotAllowed error.
*/
- (void)testOperationNotAllowedError {
- FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
- password:kTestPassword
- APIKey:kTestAPIKey];
+ FIRVerifyPasswordRequest *request =
+ [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
+ password:kTestPassword
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -363,7 +377,7 @@ static const double kAllowedTimeDifference = 0.1;
- (void)testPasswordLoginDisabledError {
FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -388,7 +402,7 @@ static const double kAllowedTimeDifference = 0.1;
- (void)testAppNotAuthorized {
FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
@@ -418,7 +432,7 @@ static const double kAllowedTimeDifference = 0.1;
- (void)testSuccessfulVerifyPasswordResponse {
FIRVerifyPasswordRequest *request = [[FIRVerifyPasswordRequest alloc] initWithEmail:kTestEmail
password:kTestPassword
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPasswordResponse *RPCResponse;
__block NSError *RPCError;
diff --git a/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m b/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
index f51d102..9719d4f 100644
--- a/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
+++ b/Example/Auth/Tests/FIRVerifyPhoneNumberRequestTests.m
@@ -94,6 +94,11 @@ static NSString *const kExpectedAPIURL =
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
@@ -101,10 +106,12 @@ static NSString *const kExpectedAPIURL =
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
_RPCIssuer = nil;
+ _requestConfiguration = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
}
@@ -116,7 +123,7 @@ static NSString *const kExpectedAPIURL =
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
request.accessToken = kTestAccessToken;
[FIRAuthBackend verifyPhoneNumber:request
callback:^(FIRVerifyPhoneNumberResponse *_Nullable response,
@@ -137,7 +144,7 @@ static NSString *const kExpectedAPIURL =
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithTemporaryProof:kTemporaryProof
phoneNumber:kPhoneNumber
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
request.accessToken = kTestAccessToken;
[FIRAuthBackend verifyPhoneNumber:request
callback:^(FIRVerifyPhoneNumberResponse *_Nullable response,
diff --git a/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m b/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
index e3fa1f8..92110f2 100644
--- a/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
+++ b/Example/Auth/Tests/FIRVerifyPhoneNumberResponseTests.m
@@ -104,15 +104,23 @@ static const double kAllowedTimeDifference = 0.1;
In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
*/
FIRFakeBackendRPCIssuer *_RPCIssuer;
+
+ /** @var _requestConfiguration
+ @brief This is the request configuration used for testing.
+ */
+ FIRAuthRequestConfiguration *_requestConfiguration;
}
- (void)setUp {
+ [super setUp];
FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
_RPCIssuer = RPCIssuer;
+ _requestConfiguration = [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
}
- (void)tearDown {
+ _requestConfiguration = nil;
_RPCIssuer = nil;
[FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
[super tearDown];
@@ -125,7 +133,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
__block NSError *RPCError;
@@ -153,7 +161,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
__block NSError *RPCError;
@@ -180,7 +188,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
__block NSError *RPCError;
@@ -207,7 +215,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithVerificationID:kVerificationID
verificationCode:kVerificationCode
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
__block NSError *RPCError;
@@ -244,7 +252,7 @@ static const double kAllowedTimeDifference = 0.1;
FIRVerifyPhoneNumberRequest *request =
[[FIRVerifyPhoneNumberRequest alloc] initWithTemporaryProof:kFakeTemporaryProof
phoneNumber:kFakePhoneNumber
- APIKey:kTestAPIKey];
+ requestConfiguration:_requestConfiguration];
__block BOOL callbackInvoked;
__block FIRVerifyPhoneNumberResponse *RPCResponse;
__block NSError *RPCError;