Skip to content

Commit e50bb48

Browse files
authored
[Auth] Add background modes capability to plist (#13548)
1 parent f71480c commit e50bb48

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

.github/workflows/auth.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthCredentials.h.gpg \
7979
FirebaseAuth/Tests/SampleSwift/ObjCApiTests/AuthCredentials.h "$plist_secret"
8080
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/SwiftApplication.plist.gpg \
81-
FirebaseAuth/Tests/SampleSwift/SwiftApplication.plist "$plist_secret"
81+
FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist "$plist_secret"
8282
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/AuthCredentials.h.gpg \
8383
FirebaseAuth/Tests/SampleSwift/AuthCredentials.h "$plist_secret"
8484
scripts/decrypt_gha_secret.sh scripts/gha-encrypted/AuthSample/GoogleService-Info.plist.gpg \

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FirebaseAuth/Tests/SampleSwift/SwiftApplication.plist
1+
FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist
22
FirebaseAuth/Tests/SampleSwift/ObjCApiTests/AuthCredentials.h
33
FirebaseAuth/Tests/SampleSwift/GoogleService-Info_multi.plist
44
FirebaseAuth/Tests/SampleSwift/GoogleService-Info.plist

FirebaseAuth/Tests/SampleSwift/SwiftApiTests/EmailPasswordTests.swift

+12-3
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,31 @@ class EmailPasswordTests: TestsBase {
2525
/// ** The testing email address for testSignInExistingUserWithEmailAndPassword. */
2626
let kExistingEmailToSignIn = "[email protected]"
2727

28-
func testCreateAccountWithEmailAndPassword() {
28+
func testCreateAccountWithEmailAndPassword() async throws {
2929
let auth = Auth.auth()
30+
// Ensure the account that will be created does not already exist.
31+
let result = try? await auth.signIn(withEmail: kNewEmailToCreateUser, password: "password")
32+
try? await result?.user.delete()
33+
3034
let expectation = self.expectation(description: "Created account with email and password.")
3135
auth.createUser(withEmail: kNewEmailToCreateUser, password: "password") { result, error in
3236
if let error {
3337
print("createUserWithEmail has error: \(error)")
3438
}
3539
expectation.fulfill()
3640
}
37-
waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
41+
await fulfillment(of: [expectation], timeout: TestsBase.kExpectationsTimeout)
42+
3843
XCTAssertEqual(auth.currentUser?.email, kNewEmailToCreateUser, "Expected email doesn't match")
39-
deleteCurrentUser()
44+
try? await deleteCurrentUserAsync()
4045
}
4146

4247
func testCreateAccountWithEmailAndPasswordAsync() async throws {
4348
let auth = Auth.auth()
49+
// Ensure the account that will be created does not already exist.
50+
let result = try? await auth.signIn(withEmail: kNewEmailToCreateUser, password: "password")
51+
try? await result?.user.delete()
52+
4453
try await auth.createUser(withEmail: kNewEmailToCreateUser, password: "password")
4554
XCTAssertEqual(auth.currentUser?.email, kNewEmailToCreateUser, "Expected email doesn't match")
4655
try await deleteCurrentUserAsync()

FirebaseAuth/Tests/SampleSwift/SwiftApiTests/TestsBase.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class TestsBase: XCTestCase {
5454
}
5555

5656
func deleteCurrentUser() {
57-
let auth = Auth.auth()
57+
guard let currentUser = Auth.auth().currentUser else { return }
5858
let expectation = self.expectation(description: "Delete current user finished.")
59-
auth.currentUser?.delete { error in
59+
currentUser.delete { error in
6060
if let error {
6161
print("Anonymous sign in error: \(error)")
6262
}
Binary file not shown.

0 commit comments

Comments
 (0)