Skip to content

Adds API Test for Email Update #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions Example/Auth/ApiTests/FirebaseAuthApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
/** The testing email address for testSignInExistingUserWithEmailAndPassword. */
static NSString *const kExistingTestingEmailToSignIn = @"[email protected]";

/** The testing email address for testUpdatingUsersEmail. */
static NSString *const kNewTestingEmail = @"[email protected]";

/** 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.";
Expand All @@ -75,7 +81,7 @@
*/
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 \
Expand Down Expand Up @@ -145,6 +151,38 @@ - (void)testCreateAccountWithEmailAndPassword {
[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) {
Expand Down Expand Up @@ -293,7 +331,6 @@ - (void)testSignInWithValidCustomAuthExpiredToken {

XCTAssertNil(auth.currentUser);
XCTAssertEqual(apiError.code, FIRAuthErrorCodeInvalidCustomToken);
[NSThread sleepForTimeInterval:3.0];
}

- (void)testInMemoryUserAfterSignOut {
Expand Down