@Test
    void verifyAuthWithMfa() throws Throwable {
        val builder = createAuthenticationResultBuilder();
        builder.collect(CoreAuthenticationTestUtils.getAuthentication());
        val result = builder.build();
        when(authenticationSupport.finalizeAuthenticationTransaction(any(), anyCollection())).thenReturn(result);
        when(authenticationSupport.handleInitialAuthenticationTransaction(any(), any())).thenReturn(builder);
        when(requestedContextValidator.validateAuthenticationContext(any(), any(), any(), any(), any()))
            .thenReturn(AuthenticationContextValidationResult.builder().success(false).build());
        when(multifactorTriggerSelectionStrategy.resolve(any(), any(), any(), any(), any()))
            .thenReturn(Optional.of(new TestMultifactorAuthenticationProvider()));

        mockMvc.perform(post(TICKETS_RESOURCE_URL)
                .param("username", "casuser")
                .param("password", "Mellon"))
            .andExpect(status().isOk());
    }
This is {@link UserAuthenticationResourceTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-rest/src/test/java/org/apereo/cas/support/rest/UserAuthenticationResourceTests.java