Skip to content

Commit de15c9a

Browse files
committed
fix and add new integration tests
1 parent 9dfc333 commit de15c9a

2 files changed

Lines changed: 61 additions & 2 deletions

File tree

common/src/test/java/com/microsoft/identity/common/nativeauth/internal/controllers/NativeAuthControllerTest.kt

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class NativeAuthControllerTest {
572572
}
573573

574574
@Test
575-
fun testSubmitPasswordReturnMFARequiredIntrospectSuccess_checkAuthMethods() {
575+
fun testSubmitPasswordReturnMFARequiredIntrospectSuccess_checkEmailAuthMethod() {
576576
val correlationId = UUID.randomUUID().toString()
577577
MockApiUtils.configureMockApi(
578578
endpointType = MockApiEndpoint.SignInToken,
@@ -588,8 +588,66 @@ class NativeAuthControllerTest {
588588

589589
val signInParameters = createSignInSubmitPasswordCommandParameters(correlationId)
590590
val signInResult = controller.signInSubmitPassword(signInParameters) as SignInCommandResult.MFARequired
591-
assert(signInResult.authMethods.count() == 2)
592591
assert(signInResult.authMethods.filter { it.challengeChannel == "email" }.count() == 1)
592+
}
593+
594+
@Test
595+
fun testSubmitCodeReturnMFARequiredIntrospectSuccess_checkEmailAuthMethod() {
596+
val correlationId = UUID.randomUUID().toString()
597+
MockApiUtils.configureMockApi(
598+
endpointType = MockApiEndpoint.SignInToken,
599+
correlationId = correlationId,
600+
responseType = MockApiResponseType.MFA_REQUIRED
601+
)
602+
603+
MockApiUtils.configureMockApi(
604+
endpointType = MockApiEndpoint.Introspect,
605+
correlationId = correlationId,
606+
responseType = MockApiResponseType.INTROSPECT_SUCCESS
607+
)
608+
609+
val signInCodeParameters = createSignInSubmitCodeCommandParameters(correlationId)
610+
val signInResult = controller.signInSubmitCode(signInCodeParameters) as SignInCommandResult.MFARequired
611+
assert(signInResult.authMethods.filter { it.challengeChannel == "email" }.count() == 1)
612+
}
613+
614+
@Test
615+
fun testSubmitCodeReturnMFARequiredIntrospectSuccess_checkSMSAuthMethod() {
616+
val correlationId = UUID.randomUUID().toString()
617+
MockApiUtils.configureMockApi(
618+
endpointType = MockApiEndpoint.SignInToken,
619+
correlationId = correlationId,
620+
responseType = MockApiResponseType.MFA_REQUIRED
621+
)
622+
623+
MockApiUtils.configureMockApi(
624+
endpointType = MockApiEndpoint.Introspect,
625+
correlationId = correlationId,
626+
responseType = MockApiResponseType.INTROSPECT_SMS_SUCCESS
627+
)
628+
629+
val signInCodeParameters = createSignInSubmitCodeCommandParameters(correlationId)
630+
val signInResult = controller.signInSubmitCode(signInCodeParameters) as SignInCommandResult.MFARequired
631+
assert(signInResult.authMethods.filter { it.challengeChannel == "sms" }.count() == 1)
632+
}
633+
634+
@Test
635+
fun testSubmitPasswordReturnMFARequiredIntrospectSuccess_checkSMSAuthMethod() {
636+
val correlationId = UUID.randomUUID().toString()
637+
MockApiUtils.configureMockApi(
638+
endpointType = MockApiEndpoint.SignInToken,
639+
correlationId = correlationId,
640+
responseType = MockApiResponseType.MFA_REQUIRED
641+
)
642+
643+
MockApiUtils.configureMockApi(
644+
endpointType = MockApiEndpoint.Introspect,
645+
correlationId = correlationId,
646+
responseType = MockApiResponseType.INTROSPECT_SMS_SUCCESS
647+
)
648+
649+
val signInParameters = createSignInSubmitPasswordCommandParameters(correlationId)
650+
val signInResult = controller.signInSubmitPassword(signInParameters) as SignInCommandResult.MFARequired
593651
assert(signInResult.authMethods.filter { it.challengeChannel == "sms" }.count() == 1)
594652
}
595653

common4j/src/testFixtures/java/com/microsoft/identity/common/nativeauth/MockApiResponseType.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum class MockApiResponseType(val stringValue: String) {
3838
EXPIRED_TOKEN("ExpiredToken"),
3939
INITIATE_SUCCESS("InitiateSuccess"),
4040
INTROSPECT_SUCCESS("IntrospectSuccess"),
41+
INTROSPECT_SMS_SUCCESS("IntrospectSMSSuccess"),
4142
INVALID_AUTHENTICATION_METHOD("InvalidAuthMethodForUser"),
4243
INVALID_CLIENT("InvalidClient"),
4344
INVALID_USERNAME("InvalidUsername"),

0 commit comments

Comments
 (0)