Skip to content

Commit

Permalink
Update AWSAuthSignInPluginTests.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Nov 23, 2022
1 parent 53a02e8 commit 3aa0916
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,56 @@ class AWSAuthSignInPluginTests: BasePluginTest {
}
}

/// Test a signIn with customAuthWIthoutSRP
///
/// - Given: Given an auth plugin with mocked service. Returning a new challenge after confirm sign in is called
///
/// - When:
/// - I invoke signIn and then confirm sign in
/// - Then:
/// - The next step smsMfA should be triggered
///
func testSignInWithCustomAuthIncorrectCode() async {

self.mockIdentityProvider = MockIdentityProvider(mockInitiateAuthResponse: { _ in
InitiateAuthOutputResponse(
authenticationResult: .none,
challengeName: .customChallenge,
challengeParameters: InitiateAuthOutputResponse.validChalengeParams,
session: "someSession")
}, mockRespondToAuthChallengeResponse: { _ in
RespondToAuthChallengeOutputResponse(
authenticationResult: .none,
challengeName: .smsMfa,
challengeParameters: ["paramKey": "value"],
session: "session")
})

let pluginOptions = AWSAuthSignInOptions(validationData: ["somekey": "somevalue"],
metadata: ["somekey": "somevalue"],
authFlowType: .customWithoutSRP)
let options = AuthSignInRequest.Options(pluginOptions: pluginOptions)
do {
let result = try await plugin.signIn(
username: "username",
password: "password",
options: options)
if case .confirmSignInWithCustomChallenge = result.nextStep {
let confirmSignInResult = try await plugin.confirmSignIn(challengeResponse: "245234")
if case .confirmSignInWithSMSMFACode = confirmSignInResult.nextStep {

} else {
XCTFail("Incorrect challenge type")
}
} else {
XCTFail("Incorrect challenge type")
}
} catch {
XCTFail("Should not fail with \(error)")
}
}


// MARK: - Service error for initiateAuth

/// Test a signIn with `InternalErrorException` from service
Expand Down

0 comments on commit 3aa0916

Please sign in to comment.