@@ -27,9 +27,7 @@ import MSAL
27
27
28
28
final class MSALNativeAuthSignUpUsernameEndToEndTests : MSALNativeAuthEndToEndBaseTestCase {
29
29
30
- private let attributes = [ " age " : 40 ]
31
-
32
- // Hero Scenario 1.1.1. Sign up – with Email Verification (Email & Email OTP)
30
+ // Hero Scenario 2.1.1. Sign up – with Email Verification (Email & Email OTP)
33
31
func test_signUpWithCode_withEmailVerification_succeeds( ) async throws {
34
32
guard let sut = initialisePublicClientApplication ( clientIdType: . code) else {
35
33
XCTFail ( " Missing information " )
@@ -73,18 +71,17 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
73
71
checkSignInAfterSignUpDelegate ( signInAfterSignUpDelegate, username: usernameOTP)
74
72
}
75
73
76
- // Hero Scenario 1 .1.2. Sign up – with Email Verification as LAST step & Custom Attributes (Email & Email OTP)
74
+ // Hero Scenario 2 .1.2. Sign up – with Email Verification as LAST step & Custom Attributes (Email & Email OTP)
77
75
func test_signUpWithCode_withEmailVerificationAsLastStepAndCustomAttributes_succeeds( ) async throws {
78
- throw XCTSkip ( " Skipping this test because application with custom attributes is missing " )
79
- guard let sut = initialisePublicClientApplication ( clientIdType: . code) else {
80
- XCTFail ( " Missing information " )
76
+ guard let sut = initialisePublicClientApplication ( clientIdType: . codeAndAttributes) else {
77
+ XCTFail ( " OTP code not retrieved from email " )
81
78
return
82
79
}
83
80
let codeRequiredExp = expectation ( description: " code required " )
84
81
let signUpStartDelegate = SignUpStartDelegateSpy ( expectation: codeRequiredExp)
85
82
let usernameOTP = generateSignUpRandomEmail ( )
86
83
87
- sut. signUp ( username: usernameOTP, attributes: attributes , correlationId: correlationId, delegate: signUpStartDelegate)
84
+ sut. signUp ( username: usernameOTP, attributes: AttributesStub . allAttributes , correlationId: correlationId, delegate: signUpStartDelegate)
88
85
89
86
await fulfillment ( of: [ codeRequiredExp] )
90
87
checkSignUpStartDelegate ( signUpStartDelegate)
@@ -93,8 +90,13 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
93
90
94
91
let signUpCompleteExp = expectation ( description: " sign-up complete " )
95
92
let signUpVerifyCodeDelegate = SignUpVerifyCodeDelegateSpy ( expectation: signUpCompleteExp)
93
+
94
+ guard let code = await retrieveCodeFor ( email: usernameOTP) else {
95
+ XCTFail ( " OTP code not retrieved from email " )
96
+ return
97
+ }
96
98
97
- signUpStartDelegate. newState? . submitCode ( code: " 1234 " , delegate: signUpVerifyCodeDelegate)
99
+ signUpStartDelegate. newState? . submitCode ( code: code , delegate: signUpVerifyCodeDelegate)
98
100
99
101
await fulfillment ( of: [ signUpCompleteExp] )
100
102
XCTAssertTrue ( signUpVerifyCodeDelegate. onSignUpCompletedCalled)
@@ -110,18 +112,17 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
110
112
checkSignInAfterSignUpDelegate ( signInAfterSignUpDelegate, username: usernameOTP)
111
113
}
112
114
113
- // Hero Scenario 1 .1.3. Sign up – with Email Verification as FIRST step & Custom Attributes (Email & Email OTP)
115
+ // Hero Scenario 2 .1.3. Sign up – with Email Verification as FIRST step & Custom Attributes (Email & Email OTP)
114
116
func test_signUpWithCode_withEmailVerificationAsFirstStepAndCustomAttributes_succeeds( ) async throws {
115
- throw XCTSkip ( " Skipping this test because application with custom attributes is missing " )
116
- guard let sut = initialisePublicClientApplication ( clientIdType: . code) else {
117
+ guard let sut = initialisePublicClientApplication ( clientIdType: . codeAndAttributes) else {
117
118
XCTFail ( " Missing information " )
118
119
return
119
120
}
120
121
let codeRequiredExp = expectation ( description: " code required " )
121
122
let signUpStartDelegate = SignUpStartDelegateSpy ( expectation: codeRequiredExp)
122
123
let usernameOTP = generateSignUpRandomEmail ( )
123
124
124
- sut. signUp ( username: usernameOTP, attributes : attributes , correlationId: correlationId, delegate: signUpStartDelegate)
125
+ sut. signUp ( username: usernameOTP, correlationId: correlationId, delegate: signUpStartDelegate)
125
126
126
127
await fulfillment ( of: [ codeRequiredExp] )
127
128
checkSignUpStartDelegate ( signUpStartDelegate)
@@ -131,7 +132,12 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
131
132
let submitCodeExp = expectation ( description: " submit code " )
132
133
let signUpVerifyCodeDelegate = SignUpVerifyCodeDelegateSpy ( expectation: submitCodeExp)
133
134
134
- signUpStartDelegate. newState? . submitCode ( code: " 1234 " , delegate: signUpVerifyCodeDelegate)
135
+ guard let code = await retrieveCodeFor ( email: usernameOTP) else {
136
+ XCTFail ( " OTP code not retrieved from email " )
137
+ return
138
+ }
139
+
140
+ signUpStartDelegate. newState? . submitCode ( code: code, delegate: signUpVerifyCodeDelegate)
135
141
136
142
await fulfillment ( of: [ submitCodeExp] )
137
143
XCTAssertTrue ( signUpVerifyCodeDelegate. onSignUpAttributesRequiredCalled)
@@ -142,7 +148,7 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
142
148
let signUpAttributesRequiredDelegate = SignUpAttributesRequiredDelegateSpy ( expectation: attributesExp)
143
149
144
150
signUpVerifyCodeDelegate. attributesRequiredNewState? . submitAttributes (
145
- attributes: attributes ,
151
+ attributes: AttributesStub . allAttributes ,
146
152
delegate: signUpAttributesRequiredDelegate
147
153
)
148
154
@@ -160,18 +166,17 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
160
166
checkSignInAfterSignUpDelegate ( signInAfterSignUpDelegate, username: usernameOTP)
161
167
}
162
168
163
- // Hero Scenario 1.1.4. Sign up – with Email Verification as FIRST step & Custom Attributes over MULTIPLE screens (Email & Email OTP)
164
- func test_signUpWithCode_withEmailVerificationAsLastStepAndCustomAttributesOverMultipleScreens_succeeds( ) async throws {
165
- throw XCTSkip ( " Skipping this test because application with custom attributes is missing " )
166
- guard let sut = initialisePublicClientApplication ( clientIdType: . code) else {
169
+ // Hero Scenario 2.1.4. Sign up – with Email Verification as FIRST step & Custom Attributes over MULTIPLE screens (Email & Email OTP)
170
+ func test_signUpWithCode_withEmailVerificationAsFirstStepAndCustomAttributesOverMultipleScreens_succeeds( ) async throws {
171
+ guard let sut = initialisePublicClientApplication ( clientIdType: . codeAndAttributes) else {
167
172
XCTFail ( " Missing information " )
168
173
return
169
174
}
170
175
let codeRequiredExp = expectation ( description: " code required " )
171
176
let signUpStartDelegate = SignUpStartDelegateSpy ( expectation: codeRequiredExp)
172
177
let usernameOTP = generateSignUpRandomEmail ( )
173
178
174
- sut. signUp ( username: usernameOTP, attributes : attributes , correlationId: correlationId, delegate: signUpStartDelegate)
179
+ sut. signUp ( username: usernameOTP, correlationId: correlationId, delegate: signUpStartDelegate)
175
180
176
181
await fulfillment ( of: [ codeRequiredExp] )
177
182
guard signUpStartDelegate. onSignUpCodeRequiredCalled else {
@@ -184,8 +189,13 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
184
189
185
190
let submitCodeExp = expectation ( description: " submit code " )
186
191
let signUpVerifyCodeDelegate = SignUpVerifyCodeDelegateSpy ( expectation: submitCodeExp)
192
+
193
+ guard let code = await retrieveCodeFor ( email: usernameOTP) else {
194
+ XCTFail ( " OTP code not retrieved from email " )
195
+ return
196
+ }
187
197
188
- signUpStartDelegate. newState? . submitCode ( code: " 1234 " , delegate: signUpVerifyCodeDelegate)
198
+ signUpStartDelegate. newState? . submitCode ( code: code , delegate: signUpVerifyCodeDelegate)
189
199
190
200
await fulfillment ( of: [ submitCodeExp] )
191
201
XCTAssertTrue ( signUpVerifyCodeDelegate. onSignUpAttributesRequiredCalled)
@@ -196,7 +206,7 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
196
206
let signUpAttributesRequiredDelegate = SignUpAttributesRequiredDelegateSpy ( expectation: submitAttributesExp1)
197
207
198
208
signUpVerifyCodeDelegate. attributesRequiredNewState? . submitAttributes (
199
- attributes: attributes ,
209
+ attributes: AttributesStub . attribute1 ,
200
210
delegate: signUpAttributesRequiredDelegate
201
211
)
202
212
@@ -209,7 +219,7 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
209
219
signUpAttributesRequiredDelegate. expectation = submitAttributesExp2
210
220
211
221
signUpAttributesRequiredDelegate. attributesRequiredState? . submitAttributes (
212
- attributes: attributes ,
222
+ attributes: AttributesStub . attribute2 ,
213
223
delegate: signUpAttributesRequiredDelegate
214
224
)
215
225
@@ -227,7 +237,7 @@ final class MSALNativeAuthSignUpUsernameEndToEndTests: MSALNativeAuthEndToEndBas
227
237
checkSignInAfterSignUpDelegate ( signInAfterSignUpDelegate, username: usernameOTP)
228
238
}
229
239
230
- // Hero Scenario 1 .1.5 . Sign up – without automatic sign in (Email & Email OTP)
240
+ // Hero Scenario 2 .1.9 . Sign up – without automatic sign in (Email & Email OTP)
231
241
func test_signUpWithoutAutomaticSignIn( ) async throws {
232
242
guard let sut = initialisePublicClientApplication ( clientIdType: . code) else {
233
243
XCTFail ( " Missing information " )
0 commit comments