Skip to content

Commit b119ca3

Browse files
committed
Move the order
1 parent 7c60548 commit b119ca3

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

MSAL/test/integration/native_auth/end_to_end/sign_in/MSALNativeAuthSignInUserNameAndPasswordEndToEndTests.swift

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,28 @@ import Foundation
2626
import XCTest
2727

2828
final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuthEndToEndPasswordTestCase {
29+
// Hero Scenario 1.2.1. Sign in - Use email and password to get token
30+
func test_signInUsingPasswordWithKnownUsernameResultsInSuccess() async throws {
31+
#if os(macOS)
32+
throw XCTSkip("For some reason this test now requires Keychain access, reason needs to be investigated")
33+
#endif
34+
guard let sut = initialisePublicClientApplication(), let username = retrieveUsernameForSignInUsernameAndPassword(), let password = await retrievePasswordForSignInUsername() else {
35+
XCTFail("Missing information")
36+
return
37+
}
38+
39+
let signInExpectation = expectation(description: "signing in")
40+
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
2941

42+
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy)
43+
44+
await fulfillment(of: [signInExpectation])
45+
46+
XCTAssertTrue(signInDelegateSpy.onSignInCompletedCalled)
47+
XCTAssertNotNil(signInDelegateSpy.result?.idToken)
48+
XCTAssertEqual(signInDelegateSpy.result?.account.username, username)
49+
}
50+
3051
// Hero Scenario 1.2.2. Sign in - User is not registered with given email
3152
func test_signInUsingPasswordWithUnknownUsernameResultsInError() async throws {
3253
guard let sut = initialisePublicClientApplication() else {
@@ -63,28 +84,6 @@ final class MSALNativeAuthSignInUsernameAndPasswordEndToEndTests: MSALNativeAuth
6384
XCTAssertTrue(signInDelegateSpy.onSignInPasswordErrorCalled)
6485
XCTAssertTrue(signInDelegateSpy.error!.isInvalidCredentials)
6586
}
66-
67-
// Hero Scenario 1.2.1. Sign in - Use email and password to get token
68-
func test_signInUsingPasswordWithKnownUsernameResultsInSuccess() async throws {
69-
#if os(macOS)
70-
throw XCTSkip("For some reason this test now requires Keychain access, reason needs to be investigated")
71-
#endif
72-
guard let sut = initialisePublicClientApplication(), let username = retrieveUsernameForSignInUsernameAndPassword(), let password = await retrievePasswordForSignInUsername() else {
73-
XCTFail("Missing information")
74-
return
75-
}
76-
77-
let signInExpectation = expectation(description: "signing in")
78-
let signInDelegateSpy = SignInPasswordStartDelegateSpy(expectation: signInExpectation)
79-
80-
sut.signIn(username: username, password: password, correlationId: correlationId, delegate: signInDelegateSpy)
81-
82-
await fulfillment(of: [signInExpectation])
83-
84-
XCTAssertTrue(signInDelegateSpy.onSignInCompletedCalled)
85-
XCTAssertNotNil(signInDelegateSpy.result?.idToken)
86-
XCTAssertEqual(signInDelegateSpy.result?.account.username, username)
87-
}
8887

8988
// Sign in - Password is incorrect (sent over delegate.newStatePasswordRequired)
9089
func test_signInAndSendingIncorrectPasswordResultsInError() async throws {

0 commit comments

Comments
 (0)