Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthCredentials.h.gpg \
FirebaseAuth/Tests/SampleSwift/ObjCApiTests/AuthCredentials.h "$plist_secret"
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/SwiftApplication.plist.gpg \
FirebaseAuth/Tests/SampleSwift/SwiftApplication.plist "$plist_secret"
FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist "$plist_secret"
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/AuthCredentials.h.gpg \
FirebaseAuth/Tests/SampleSwift/AuthCredentials.h "$plist_secret"
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/GoogleService-Info.plist.gpg \
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FirebaseAuth/Tests/SampleSwift/SwiftApplication.plist
FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist
FirebaseAuth/Tests/SampleSwift/ObjCApiTests/AuthCredentials.h
FirebaseAuth/Tests/SampleSwift/GoogleService-Info_multi.plist
FirebaseAuth/Tests/SampleSwift/GoogleService-Info.plist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,31 @@ class EmailPasswordTests: TestsBase {
/// ** The testing email address for testSignInExistingUserWithEmailAndPassword. */
let kExistingEmailToSignIn = "user+email_existing_user@example.com"

func testCreateAccountWithEmailAndPassword() {
func testCreateAccountWithEmailAndPassword() async throws {
let auth = Auth.auth()
// Ensure the account that will be created does not already exist.
let result = try? await auth.signIn(withEmail: kNewEmailToCreateUser, password: "password")
try? await result?.user.delete()

let expectation = self.expectation(description: "Created account with email and password.")
auth.createUser(withEmail: kNewEmailToCreateUser, password: "password") { result, error in
if let error {
print("createUserWithEmail has error: \(error)")
}
expectation.fulfill()
}
waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
await fulfillment(of: [expectation], timeout: TestsBase.kExpectationsTimeout)

XCTAssertEqual(auth.currentUser?.email, kNewEmailToCreateUser, "Expected email doesn't match")
deleteCurrentUser()
try? await deleteCurrentUserAsync()
}

func testCreateAccountWithEmailAndPasswordAsync() async throws {
let auth = Auth.auth()
// Ensure the account that will be created does not already exist.
let result = try? await auth.signIn(withEmail: kNewEmailToCreateUser, password: "password")
try? await result?.user.delete()

try await auth.createUser(withEmail: kNewEmailToCreateUser, password: "password")
XCTAssertEqual(auth.currentUser?.email, kNewEmailToCreateUser, "Expected email doesn't match")
try await deleteCurrentUserAsync()
Expand Down
4 changes: 2 additions & 2 deletions FirebaseAuth/Tests/SampleSwift/SwiftApiTests/TestsBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class TestsBase: XCTestCase {
}

func deleteCurrentUser() {
let auth = Auth.auth()
guard let currentUser = Auth.auth().currentUser else { return }
let expectation = self.expectation(description: "Delete current user finished.")
auth.currentUser?.delete { error in
currentUser.delete { error in
if let error {
print("Anonymous sign in error: \(error)")
}
Expand Down
Binary file modified scripts/gha-encrypted/AuthSample/SwiftApplication.plist.gpg
Binary file not shown.