1
1
/*
2
- * Copyright 2020 Google LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
2
+ * Copyright 2020 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
16
17
17
import XCTest
18
18
import FirebaseAuth
@@ -26,78 +26,78 @@ class AccountInfoTests: TestsBase {
26
26
27
27
override func setUp( ) {
28
28
let auth = Auth . auth ( )
29
- let expectation1 = self . expectation ( description: " Created account with email and password. " )
29
+ let expectation1 = expectation ( description: " Created account with email and password. " )
30
30
auth. createUser ( withEmail: kOldUserEmail, password: " password " ) { user, error in
31
31
// Succeed whether or not the user already exists.
32
32
expectation1. fulfill ( )
33
33
}
34
- waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
34
+ waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
35
35
}
36
36
37
37
override func tearDown( ) {
38
38
// Clean up the created Firebase user for future runs.
39
- self . deleteCurrentUser ( )
39
+ deleteCurrentUser ( )
40
40
}
41
41
42
42
func testUpdatingUsersEmail( ) {
43
43
let auth = Auth . auth ( )
44
- let expectation1 = self . expectation ( description: " Created account with email and password. " )
44
+ let expectation1 = expectation ( description: " Created account with email and password. " )
45
45
auth. createUser ( withEmail: kOldUserEmail, password: " password " ) { user, error in
46
- if let error = error {
46
+ if let error = error {
47
47
XCTAssertEqual ( ( error as NSError ) . code,
48
- AuthErrorCode . emailAlreadyInUse. rawValue,
49
- " Created a user despite it already exiting. " )
48
+ AuthErrorCode . emailAlreadyInUse. rawValue,
49
+ " Created a user despite it already exiting. " )
50
50
} else {
51
51
XCTFail ( " Did not get error for recreating a user " )
52
52
}
53
53
expectation1. fulfill ( )
54
54
}
55
- waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
55
+ waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
56
56
57
- let expectation2 = self . expectation ( description: " Sign in with email and password. " )
57
+ let expectation2 = expectation ( description: " Sign in with email and password. " )
58
58
auth. signIn ( withEmail: kOldUserEmail, password: " password " ) { user, error in
59
59
XCTAssertNil ( error)
60
60
XCTAssertEqual ( auth. currentUser? . email,
61
61
self . kOldUserEmail,
62
62
" Signed user does not match request. " )
63
63
expectation2. fulfill ( )
64
64
}
65
- waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
65
+ waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
66
66
67
- let expectation3 = self . expectation ( description: " Update email address. " )
67
+ let expectation3 = expectation ( description: " Update email address. " )
68
68
auth. currentUser? . updateEmail ( to: kNewUserEmail) { error in
69
69
XCTAssertNil ( error)
70
70
XCTAssertEqual ( auth. currentUser? . email,
71
71
self . kNewUserEmail,
72
72
" Signed user does not match change. " )
73
73
expectation3. fulfill ( )
74
74
}
75
- waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
75
+ waitForExpectations ( timeout: TestsBase . kExpectationsTimeout)
76
76
}
77
77
78
- #if compiler(>=5.5) && canImport(_Concurrency)
79
- @available ( iOS 15 , tvOS 15 , macOS 12 , watchOS 8 , * )
80
- func testUpdatingUsersEmailAsync( ) async throws {
81
- let auth = Auth . auth ( )
82
- do {
83
- let _ = try await auth. createUser ( withEmail: kOldUserEmail, password: " password " )
84
- XCTFail ( " Did not get error for recreating a user " )
85
- } catch {
78
+ #if compiler(>=5.5) && canImport(_Concurrency)
79
+ @available ( iOS 15 , tvOS 15 , macOS 12 , watchOS 8 , * )
80
+ func testUpdatingUsersEmailAsync( ) async throws {
81
+ let auth = Auth . auth ( )
82
+ do {
83
+ _ = try await auth. createUser ( withEmail: kOldUserEmail, password: " password " )
84
+ XCTFail ( " Did not get error for recreating a user " )
85
+ } catch {
86
86
XCTAssertEqual ( ( error as NSError ) . code,
87
- AuthErrorCode . emailAlreadyInUse. rawValue,
88
- " Created a user despite it already exiting. " )
89
- }
87
+ AuthErrorCode . emailAlreadyInUse. rawValue,
88
+ " Created a user despite it already exiting. " )
89
+ }
90
90
91
- let user = try await auth. signIn ( withEmail: kOldUserEmail, password: " password " )
92
- XCTAssertEqual ( user. user. email, kOldUserEmail)
93
- XCTAssertEqual ( auth. currentUser? . email,
94
- self . kOldUserEmail,
95
- " Signed user does not match request. " )
91
+ let user = try await auth. signIn ( withEmail: kOldUserEmail, password: " password " )
92
+ XCTAssertEqual ( user. user. email, kOldUserEmail)
93
+ XCTAssertEqual ( auth. currentUser? . email,
94
+ kOldUserEmail,
95
+ " Signed user does not match request. " )
96
96
97
- try await auth. currentUser? . updateEmail ( to: kNewUserEmail)
98
- XCTAssertEqual ( auth. currentUser? . email,
99
- self . kNewUserEmail,
100
- " Signed user does not match change. " )
101
- }
97
+ try await auth. currentUser? . updateEmail ( to: kNewUserEmail)
98
+ XCTAssertEqual ( auth. currentUser? . email,
99
+ kNewUserEmail,
100
+ " Signed user does not match change. " )
101
+ }
102
102
#endif
103
103
}
0 commit comments