@@ -109,12 +109,16 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
109
109
110
110
sut. signIn ( username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy2)
111
111
112
- XCTAssertEqual ( signInDelegateSpy2. error!. description, " An account is already signed in. " )
112
+ XCTAssertTrue ( signInDelegateSpy. onSignInCompletedCalled)
113
+ XCTAssertNotNil ( signInDelegateSpy. result? . idToken)
114
+ XCTAssertEqual ( signInDelegateSpy. result? . account. username, username)
113
115
}
114
116
115
117
// User Case 1.2.5. Sign In - User signs in with account B, while data for account A already exists in SDK persistence
116
118
func test_signInWithDifferentAccountSigned( ) async throws {
117
- guard let sut = initialisePublicClientApplication ( ) , let username = retrieveUsernameForSignInUsernameAndPassword ( ) , let uesrname2 = retrieveUsernameForSignInCode ( ) , let password = await retrievePasswordForSignInUsername ( ) else {
119
+ throw XCTSkip ( " Retrieving OTP failure " )
120
+
121
+ guard let sut = initialisePublicClientApplication ( ) , let username = retrieveUsernameForSignInUsernameAndPassword ( ) , let username2 = retrieveUsernameForSignInCode ( ) , let password = await retrievePasswordForSignInUsername ( ) else {
118
122
XCTFail ( " Missing information " )
119
123
return
120
124
}
@@ -132,11 +136,32 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
132
136
133
137
// Now signed in the account again
134
138
let signInExpectation2 = expectation ( description: " signing in " )
135
- let signInDelegateSpy2 = SignInPasswordStartDelegateSpy ( expectation: signInExpectation2)
139
+ let signInDelegateSpy2 = SignInStartDelegateSpy ( expectation: signInExpectation)
140
+
141
+ sut. signIn ( username: username2, correlationId: correlationId, delegate: signInDelegateSpy2)
136
142
137
- sut. signIn ( username: uesrname2, password: password, correlationId: correlationId, delegate: signInDelegateSpy2)
143
+ await fulfillment ( of: [ signInExpectation2] )
144
+
145
+ guard signInDelegateSpy2. onSignInCodeRequiredCalled else {
146
+ XCTFail ( " onSignInCodeRequired not called " )
147
+ return
148
+ }
138
149
139
- XCTAssertEqual ( signInDelegateSpy2. error!. description, " An account is already signed in. " )
150
+ guard let code = await retrieveCodeFor ( email: username) else {
151
+ XCTFail ( " OTP code could not be retrieved " )
152
+ return
153
+ }
154
+
155
+ let verifyCodeExpectation = expectation ( description: " verifying code " )
156
+ let signInVerifyCodeDelegateSpy = SignInVerifyCodeDelegateSpy ( expectation: verifyCodeExpectation)
157
+
158
+ signInDelegateSpy. newStateCodeRequired? . submitCode ( code: code, delegate: signInVerifyCodeDelegateSpy)
159
+
160
+ await fulfillment ( of: [ verifyCodeExpectation] )
161
+
162
+ XCTAssertTrue ( signInVerifyCodeDelegateSpy. onSignInCompletedCalled)
163
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result)
164
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result? . account. username, username2)
140
165
}
141
166
142
167
/* User Case 1.2.6. Sign In - Ability to provide scope to control auth strength of the token
0 commit comments