aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example/Auth
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2018-01-04 10:51:07 -0800
committerGravatar GitHub <noreply@github.com>2018-01-04 10:51:07 -0800
commit4ec8b410988dc0145b8ec68d18880382a2a3071c (patch)
treeabe9c9525f8c2e19997b2b0567f8a884d31c219c /Example/Auth
parentf08b5044d64197a3227017ad44235a2bd7421691 (diff)
Adds API Test for Email Update (#613)
Diffstat (limited to 'Example/Auth')
-rw-r--r--Example/Auth/ApiTests/FirebaseAuthApiTests.m41
1 files changed, 39 insertions, 2 deletions
diff --git a/Example/Auth/ApiTests/FirebaseAuthApiTests.m b/Example/Auth/ApiTests/FirebaseAuthApiTests.m
index ee96bd0..741814c 100644
--- a/Example/Auth/ApiTests/FirebaseAuthApiTests.m
+++ b/Example/Auth/ApiTests/FirebaseAuthApiTests.m
@@ -63,6 +63,12 @@ static NSString *const kTestingEmailToCreateUser = @"abc@xyz.com";
/** The testing email address for testSignInExistingUserWithEmailAndPassword. */
static NSString *const kExistingTestingEmailToSignIn = @"456@abc.com";
+/** The testing email address for testUpdatingUsersEmail. */
+static NSString *const kNewTestingEmail = @"updatedEmail@abc.com";
+
+/** The testing password for testSignInExistingUserWithModifiedEmailAndPassword. */
+static NSString *const kNewTestingPasswordToSignIn = @"password_new";
+
/** Error message for invalid custom token sign in. */
NSString *kInvalidTokenErrorMessage =
@"The custom token format is incorrect. Please check the documentation.";
@@ -75,7 +81,7 @@ NSString *kGoogleCliendId = KGOOGLE_CLIENT_ID;
*/
NSString *kGoogleTestAccountRefreshToken = KGOOGLE_TEST_ACCOUNT_REFRESH_TOKEN;
-static NSTimeInterval const kExpectationsTimeout = 30;
+static NSTimeInterval const kExpectationsTimeout = 10;
#ifdef NO_NETWORK
#define SKIP_IF_ON_MOBILE_HARNESS \
@@ -145,6 +151,38 @@ static NSTimeInterval const kExpectationsTimeout = 30;
[self deleteCurrentFirebaseUser];
}
+- (void)testUpdatingUsersEmail {
+ SKIP_IF_ON_MOBILE_HARNESS
+ FIRAuth *auth = [FIRAuth auth];
+ if (!auth) {
+ XCTFail(@"Could not obtain auth object.");
+ }
+
+ __block NSError *apiError;
+ XCTestExpectation *expectation =
+ [self expectationWithDescription:@"Created account with email and password."];
+ [auth createUserWithEmail:kTestingEmailToCreateUser
+ password:@"password"
+ completion:^(FIRUser *user, NSError *error) {
+ apiError = error;
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
+ expectation = [self expectationWithDescription:@"Created account with email and password."];
+ XCTAssertEqualObjects(auth.currentUser.email, kTestingEmailToCreateUser);
+ XCTAssertNil(apiError);
+ [auth.currentUser updateEmail:kNewTestingEmail
+ completion:^(NSError *_Nullable error) {
+ apiError = error;
+ [expectation fulfill];
+ }];
+ [self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
+ XCTAssertNil(apiError);
+ XCTAssertEqualObjects(auth.currentUser.email, kNewTestingEmail);
+ // Clean up the created Firebase user for future runs.
+ [self deleteCurrentFirebaseUser];
+}
+
- (void)testLinkAnonymousAccountToFacebookAccount {
FIRAuth *auth = [FIRAuth auth];
if (!auth) {
@@ -293,7 +331,6 @@ static NSTimeInterval const kExpectationsTimeout = 30;
XCTAssertNil(auth.currentUser);
XCTAssertEqual(apiError.code, FIRAuthErrorCodeInvalidCustomToken);
- [NSThread sleepForTimeInterval:3.0];
}
- (void)testInMemoryUserAfterSignOut {