Skip to content

Commit 0335ad8

Browse files
committed
add unit test
1 parent 727f2f8 commit 0335ad8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthAutoSignInTests.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,41 @@ class AWSAuthAutoSignInTests: BasePluginTest {
5858
XCTFail("Received failure with error \(error)")
5959
}
6060
}
61+
62+
/// Test auto sign in success
63+
///
64+
/// - Given: Given an auth plugin with mocked service set up to return `.selectChallenge` with `.password` and `.passwordSrp`
65+
/// for `InitiateAuth` and in signed up state
66+
/// - When:
67+
/// - I invoke autoSignIn
68+
/// - Then:
69+
/// - I should get a result with `.continueSignInWithFirstFactorSelection`
70+
///
71+
func testAutoSignInSuccessWithContinueFirstFactorSelection() async {
72+
mockIdentityProvider = MockIdentityProvider(
73+
mockInitiateAuthResponse: { input in
74+
return InitiateAuthOutput(
75+
availableChallenges: [.password, .passwordSrp],
76+
challengeName: .selectChallenge,
77+
session: "session"
78+
)
79+
}
80+
)
81+
82+
do {
83+
let result = try await plugin.autoSignIn()
84+
guard case .continueSignInWithFirstFactorSelection(let authFactorTypes) = result.nextStep else {
85+
XCTFail("Result should be .continueSignInWithFirstFactorSelection for next step")
86+
return
87+
}
88+
89+
XCTAssertTrue(authFactorTypes.count == 2)
90+
XCTAssertTrue(authFactorTypes.contains(.password))
91+
XCTAssertTrue(authFactorTypes.contains(.passwordSRP))
92+
} catch {
93+
XCTFail("Received failure with error \(error)")
94+
}
95+
}
6196

6297
/// Test auto sign in success
6398
///

0 commit comments

Comments
 (0)