@BeforeEach
    void initialize() {
        val httpRequestCredentialFactory = new UsernamePasswordRestHttpRequestCredentialFactory() {
            @Override
            public List<Credential> fromAuthentication(final HttpServletRequest request,
                                                       final MultiValueMap<String, String> requestBody,
                                                       final Authentication authentication,
                                                       final MultifactorAuthenticationProvider provider) {
                if (provider.getId().contains("unknown")) {
                    return List.of();
                }
                return List.of(new UsernamePasswordCredential("mfa-user", "mfa-user"));
            }
        };

        val applicationContext = new GenericApplicationContext();
        val api = new DefaultRestAuthenticationService(authenticationSupport, httpRequestCredentialFactory,
            RegisteredServiceTestUtils.getWebApplicationServiceFactory(),
            multifactorTriggerSelectionStrategy,
            servicesManager, requestedContextValidator,
            AuthenticationPolicy.alwaysSatisfied(), applicationContext);
        userAuthenticationResource = new UserAuthenticationResource(api,
            new DefaultUserAuthenticationResourceEntityResponseFactory(),
            applicationContext);

        mockMvc = MockMvcBuilders.standaloneSetup(userAuthenticationResource)
            .defaultRequest(get("/")
                .contextPath("/cas")
                .contentType(MediaType.APPLICATION_FORM_URLENCODED))
            .build();
    }
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