Skip to content

Commit

Permalink
update emailMFACode step to confirmSignInWithOTP
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Oct 15, 2024
1 parent 27112df commit f332d12
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Amplify/Categories/Auth/Models/AuthSignInStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public enum AuthSignInStep {
///
case continueSignInWithEmailMFASetup

/// Auth step is EMAIL multi factor authentication.
///
/// Confirmation code for the MFA will be send to the provided EMAIL.
case confirmSignInWithEmailMFACode(AuthCodeDeliveryDetails)

/// Auth step is for continuing sign in by selecting multi factor authentication type to setup
///
case continueSignInWithMFASetupSelection(AllowedMFATypes)

/// Auth step is for confirming sign in with OTP
///
/// OTP for the factor will be sent to the delivery medium.
case confirmSignInWithOTP(AuthCodeDeliveryDetails)

/// Auth step required the user to change their password.
///
case resetPassword(AdditionalInfo?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct InitializeResolveChallenge: Action {
case .selectMFAType:
return .continueSignInWithMFASelection(challenge.getAllowedMFATypesForSelection)
case .emailMFA:
return .confirmSignInWithEmailMFACode(challenge.codeDeliveryDetails)
return .confirmSignInWithOTP(challenge.codeDeliveryDetails)
case .setUpMFA:
var allowedMFATypesForSetup = challenge.getAllowedMFATypesForSetup
// remove SMS, as it is not supported and should not be sent back to the customer, since it could be misleading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ class EmailMFATests: BasePluginTest {
}
}

/// Test a signIn with valid inputs getting confirmSignInWithEmailMFACode challenge
/// Test a signIn with valid inputs getting confirmSignInWithOTP challenge
///
/// - Given: Given an auth plugin with mocked service.
///
/// - When:
/// - I invoke signIn with valid values
/// - Then:
/// - I should get a .confirmSignInWithEmailMFACode response
/// - I should get a .confirmSignInWithOTP response
///
func testSuccessfulEmailMFACodeStep() async {
var signInStepIterator = 0
Expand Down Expand Up @@ -134,8 +134,8 @@ class EmailMFATests: BasePluginTest {
username: "username",
password: "password",
options: AuthSignInRequest.Options())
guard case .confirmSignInWithEmailMFACode(let codeDetails) = result.nextStep else {
XCTFail("Result should be .confirmSignInWithEmailMFACode for next step, instead got: \(result.nextStep)")
guard case .confirmSignInWithOTP(let codeDetails) = result.nextStep else {
XCTFail("Result should be .confirmSignInWithOTP for next step, instead got: \(result.nextStep)")
return
}
if case .email(let destination) = codeDetails.destination {
Expand Down Expand Up @@ -232,7 +232,7 @@ class EmailMFATests: BasePluginTest {
signInStepIterator = 1
confirmSignInResult = try await plugin.confirmSignIn(
challengeResponse: "[email protected]")
guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else {
guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else {
XCTFail("Result should be .continueSignInWithEmailMFASetup but got: \(confirmSignInResult.nextStep)")
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class EmailMFARequiredTests: AWSAuthBaseTest {
challengeResponse: username + "@integTest.com")

// Step 6: Ensure that the next step is to confirm the Email MFA code
guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else {
XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(confirmSignInResult.nextStep)")
guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else {
XCTFail("Expected .confirmSignInWithOTP step, got \(confirmSignInResult.nextStep)")
return
}
if case .email(let destination) = deliveryDetails.destination {
Expand Down Expand Up @@ -137,7 +137,7 @@ class EmailMFARequiredTests: AWSAuthBaseTest {
/// they should successfully complete the MFA process and sign in.
///
/// - MFA Setup Flow:
/// - Step 1: User signs in and receives the `confirmSignInWithEmailMFACode` challenge.
/// - Step 1: User signs in and receives the `confirmSignInWithOTP` challenge.
/// - Step 2: User enters an incorrect MFA code and receives a `codeMismatch` error.
/// - Step 3: User enters the correct MFA code.
/// - Step 4: Sign-in completes, and the email is associated with the user account.
Expand Down Expand Up @@ -165,8 +165,8 @@ class EmailMFARequiredTests: AWSAuthBaseTest {
options: options)

// Step 6: Ensure that the next step is to confirm the Email MFA code
guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = result.nextStep else {
XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(result.nextStep)")
guard case .confirmSignInWithOTP(let deliveryDetails) = result.nextStep else {
XCTFail("Expected .confirmSignInWithOTP step, got \(result.nextStep)")
return
}
if case .email(let destination) = deliveryDetails.destination {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class EmailMFAWithAllMFATypesRequiredTests: AWSAuthBaseTest {
options: AuthSignInRequest.Options())

// Step 4: Verify that the next step is to confirm the Email MFA code
guard case .confirmSignInWithEmailMFACode(let codeDetails) = result.nextStep else {
XCTFail("Expected .confirmSignInWithEmailMFACode step, got \(result.nextStep)")
guard case .confirmSignInWithOTP(let codeDetails) = result.nextStep else {
XCTFail("Expected .confirmSignInWithOTP step, got \(result.nextStep)")
return
}
if case .email(let destination) = codeDetails.destination {
Expand Down Expand Up @@ -193,8 +193,8 @@ class EmailMFAWithAllMFATypesRequiredTests: AWSAuthBaseTest {
challengeResponse: username + "@integTest.com")

// Step 8: Verify that the next step is to confirm the Email MFA code
guard case .confirmSignInWithEmailMFACode(let deliveryDetails) = confirmSignInResult.nextStep else {
XCTFail("Expected .confirmSignInWithEmailMFACode step")
guard case .confirmSignInWithOTP(let deliveryDetails) = confirmSignInResult.nextStep else {
XCTFail("Expected .confirmSignInWithOTP step")
return
}
if case .email(let destination) = deliveryDetails.destination {
Expand Down

0 comments on commit f332d12

Please sign in to comment.