@@ -28,7 +28,6 @@ import XCTest
28
28
final class MSALNativeAuthSignInUsernameEndToEndTests : MSALNativeAuthEndToEndBaseTestCase {
29
29
// Hero Scenario 2.2.1. Sign in - Use email and OTP to get token and sign in
30
30
func test_signInAndSendingCorrectOTPResultsInSuccess( ) async throws {
31
-
32
31
guard let sut = initialisePublicClientApplication ( clientIdType: . code) , let username = retrieveUsernameForSignInCode ( ) else {
33
32
XCTFail ( " Missing information " )
34
33
return
@@ -90,10 +89,10 @@ final class MSALNativeAuthSignInUsernameEndToEndTests: MSALNativeAuthEndToEndBas
90
89
}
91
90
92
91
// User Case 2.2.3 Sign In - User email is registered with password method, which is not supported by client (aka redirect flow)
93
- func test_signInWithInsufficientChallengeInError ( ) async throws {
92
+ func test_signInWithPasswordConfigInsufficientChallengeInError ( ) async throws {
94
93
throw XCTSkip ( " Retrieving OTP failure " )
95
94
96
- guard let sut = initialisePublicClientApplication ( clientIdType: . code ) , let username = retrieveUsernameForSignInCode ( ) else {
95
+ guard let sut = initialisePublicClientApplication ( clientIdType: . password , challengeTypes : . OOB ) , let username = retrieveUsernameForSignInCode ( ) else {
97
96
XCTFail ( " Missing information " )
98
97
return
99
98
}
@@ -109,7 +108,60 @@ final class MSALNativeAuthSignInUsernameEndToEndTests: MSALNativeAuthEndToEndBas
109
108
XCTAssertTrue ( signInDelegateSpy. onSignInErrorCalled)
110
109
XCTAssertEqual ( signInDelegateSpy. error? . isBrowserRequired, true )
111
110
}
111
+
112
+ // User Case 2.2.5 Sign In - Resend email OTP
113
+ func test_signUpWithEmailOTP_resendEmail_success( ) async throws {
114
+ guard let sut = initialisePublicClientApplication ( clientIdType: . code) , let username = retrieveUsernameForSignInCode ( ) else {
115
+ XCTFail ( " Missing information " )
116
+ return
117
+ }
112
118
119
+ let signInExpectation = expectation ( description: " signing in " )
120
+ let signInDelegate = SignInStartDelegateSpy ( expectation: signInExpectation)
121
+
122
+ sut. signIn ( username: username, correlationId: correlationId, delegate: signInDelegate)
123
+
124
+ await fulfillment ( of: [ signInExpectation] )
125
+
126
+ guard signInDelegate. onSignInCodeRequiredCalled else {
127
+ XCTFail ( " OTP not sent " )
128
+ return
129
+ }
130
+ XCTAssertNotNil ( signInDelegate. newStateCodeRequired)
131
+ XCTAssertNotNil ( signInDelegate. sentTo)
132
+
133
+ // Now get code1...
134
+ guard let code1 = await retrieveCodeFor ( email: username) else {
135
+ XCTFail ( " OTP code could not be retrieved " )
136
+ return
137
+ }
138
+
139
+ // Resend code
140
+ let resendCodeRequiredExp = expectation ( description: " code required again " )
141
+ let signInResendCodeDelegate = SignInResendCodeDelegateSpy ( expectation: resendCodeRequiredExp)
142
+
143
+ // Call resend code method
144
+ signInDelegate. newStateCodeRequired? . resendCode ( delegate: signInResendCodeDelegate)
145
+
146
+ await fulfillment ( of: [ resendCodeRequiredExp] )
147
+
148
+ // Verify that resend code method was called
149
+ XCTAssertTrue ( signInResendCodeDelegate. onSignInResendCodeCodeRequiredCalled,
150
+ " Resend code method should have been called " )
151
+
152
+ // Now get code2...
153
+ guard let code2 = await retrieveCodeFor ( email: username) else {
154
+ XCTFail ( " OTP code could not be retrieved " )
155
+ return
156
+ }
157
+
158
+ // Verify that the codes are different
159
+ XCTAssertNotEqual ( code1, code2, " Resent code should be different from the original code " )
160
+ }
161
+
162
+ /* User Case 2.2.6 Sign In - Ability to provide scope to control auth strength of the token
163
+ Please refer to SignInUsernameAndPasswordEndToEndTests 1.2.6 for the test*/
164
+
113
165
// Hero Scenario 2.2.7. Sign in - Invalid OTP code
114
166
func test_signInAndSendingIncorrectOTPResultsInError( ) async throws {
115
167
throw XCTSkip ( " The test account is locked " )
0 commit comments