@@ -186,6 +186,123 @@ class AuthenticationProviderSigninTests: BaseAuthenticationProviderTest {
186
186
wait ( for: [ resultExpectation] , timeout: apiTimeout)
187
187
}
188
188
189
+ /// Test a signIn with additional info in next step
190
+ ///
191
+ /// - Given: Given an auth plugin with mocked service. Mock additional info in custom auth
192
+ ///
193
+ /// - When:
194
+ /// - I invoke signIn
195
+ /// - Then:
196
+ /// - I should get a the info in next step
197
+ ///
198
+ func testCustomAuthWithAdditionalInfo( ) {
199
+
200
+ let mockSigninResult = SignInResult ( signInState: . customChallenge, parameters: [ " paramKey " : " value " ] )
201
+ mockAWSMobileClient? . signInMockResult = . success( mockSigninResult)
202
+
203
+ let options = AuthSignInRequest . Options ( )
204
+ let resultExpectation = expectation ( description: " Should receive a result " )
205
+ _ = plugin. signIn ( username: " username " , password: " password " , options: options) { result in
206
+ defer {
207
+ resultExpectation. fulfill ( )
208
+ }
209
+ switch result {
210
+ case . success( let signinResult) :
211
+ guard case . confirmSignInWithCustomChallenge( let additionalInfo) = signinResult. nextStep else {
212
+ XCTFail ( " Result should be .confirmSignInWithCustomChallenge for next step " )
213
+ return
214
+ }
215
+ guard let addditionalValue = additionalInfo ? [ " paramKey " ] else {
216
+ XCTFail ( " Additional info should be passed to the result " )
217
+ return
218
+ }
219
+ XCTAssertEqual ( addditionalValue, " value " , " Additional info should be same " )
220
+ XCTAssertFalse ( signinResult. isSignedIn, " Signin result should not be complete " )
221
+ case . failure( let error) :
222
+ XCTFail ( " Received failure with error \( error) " )
223
+ }
224
+ }
225
+ wait ( for: [ resultExpectation] , timeout: apiTimeout)
226
+ }
227
+
228
+ /// Test a signIn with additional info in next step
229
+ ///
230
+ /// - Given: Given an auth plugin with mocked service. Mock additional info in sms mfa
231
+ ///
232
+ /// - When:
233
+ /// - I invoke signIn
234
+ /// - Then:
235
+ /// - I should get a the info in next step
236
+ ///
237
+ func testSMSMFAWithAdditionalInfo( ) {
238
+
239
+ let mockSigninResult = SignInResult ( signInState: . smsMFA, parameters: [ " paramKey " : " value " ] )
240
+ mockAWSMobileClient? . signInMockResult = . success( mockSigninResult)
241
+
242
+ let options = AuthSignInRequest . Options ( )
243
+ let resultExpectation = expectation ( description: " Should receive a result " )
244
+ _ = plugin. signIn ( username: " username " , password: " password " , options: options) { result in
245
+ defer {
246
+ resultExpectation. fulfill ( )
247
+ }
248
+ switch result {
249
+ case . success( let signinResult) :
250
+ guard case . confirmSignInWithSMSMFACode( _, let additionalInfo) = signinResult. nextStep else {
251
+ XCTFail ( " Result should be .confirmSignInWithSMSMFACode for next step " )
252
+ return
253
+ }
254
+ guard let addditionalValue = additionalInfo ? [ " paramKey " ] else {
255
+ XCTFail ( " Additional info should be passed to the result " )
256
+ return
257
+ }
258
+ XCTAssertEqual ( addditionalValue, " value " , " Additional info should be same " )
259
+ XCTAssertFalse ( signinResult. isSignedIn, " Signin result should not be complete " )
260
+ case . failure( let error) :
261
+ XCTFail ( " Received failure with error \( error) " )
262
+ }
263
+ }
264
+ wait ( for: [ resultExpectation] , timeout: apiTimeout)
265
+ }
266
+
267
+ /// Test a signIn with additional info in next step
268
+ ///
269
+ /// - Given: Given an auth plugin with mocked service. Mock additional info in new password
270
+ ///
271
+ /// - When:
272
+ /// - I invoke signIn
273
+ /// - Then:
274
+ /// - I should get a the info in next step
275
+ ///
276
+ func testNewPasswordWithAdditionalInfo( ) {
277
+
278
+ let mockSigninResult = SignInResult ( signInState: . newPasswordRequired, parameters: [ " paramKey " : " value " ] )
279
+ mockAWSMobileClient? . signInMockResult = . success( mockSigninResult)
280
+
281
+ let options = AuthSignInRequest . Options ( )
282
+ let resultExpectation = expectation ( description: " Should receive a result " )
283
+ _ = plugin. signIn ( username: " username " , password: " password " , options: options) { result in
284
+ defer {
285
+ resultExpectation. fulfill ( )
286
+ }
287
+ switch result {
288
+ case . success( let signinResult) :
289
+ guard case . confirmSignInWithNewPassword( let additionalInfo) = signinResult. nextStep else {
290
+ XCTFail ( " Result should be .confirmSignInWithNewPassword for next step " )
291
+ return
292
+ }
293
+ guard let addditionalValue = additionalInfo ? [ " paramKey " ] else {
294
+ XCTFail ( " Additional info should be passed to the result " )
295
+ return
296
+ }
297
+ XCTAssertEqual ( addditionalValue, " value " , " Additional info should be same " )
298
+ XCTAssertFalse ( signinResult. isSignedIn, " Signin result should not be complete " )
299
+ case . failure( let error) :
300
+ XCTFail ( " Received failure with error \( error) " )
301
+ }
302
+ }
303
+ wait ( for: [ resultExpectation] , timeout: apiTimeout)
304
+ }
305
+
189
306
/// Test a signIn with customChallenge as signIn result response
190
307
///
191
308
/// - Given: Given an auth plugin with mocked service. Mock customChallenge response for signIn result
0 commit comments