@Test
    void verifyOperation() throws Throwable {
        val factory = new DuoSecurityRestHttpRequestCredentialFactory(mock(TenantExtractor.class));
        val request = new MockHttpServletRequest();

        val body = new LinkedMultiValueMap<String, String>();
        assertTrue(factory.fromRequest(request, body).isEmpty());

        body.put(RestHttpRequestCredentialFactory.PARAMETER_USERNAME, List.of("user"));
        assertTrue(factory.fromRequest(request, body).isEmpty());

        body.put(DuoSecurityRestHttpRequestCredentialFactory.PARAMETER_NAME_PASSCODE, List.of("123456"));
        body.put(DuoSecurityRestHttpRequestCredentialFactory.PARAMETER_NAME_PROVIDER, List.of("custom-duo"));
        var credentials = factory.fromRequest(request, body);
        assertFalse(credentials.isEmpty());
        var credential = (DuoSecurityPasscodeCredential) credentials.getFirst();
        assertEquals("custom-duo", credential.getProviderId());

        credentials = factory.fromAuthentication(request, body, CoreAuthenticationTestUtils.getAuthentication(),
            new TestMultifactorAuthenticationProvider());
        val directCredential = (DuoSecurityDirectCredential) credentials.getFirst();
        assertEquals(TestMultifactorAuthenticationProvider.ID, directCredential.getProviderId());
        assertNotNull(directCredential.getPrincipal());
    }
This is {@link DuoSecurityRestHttpRequestCredentialFactoryTests}.

@author Misagh Moayyed
@since 6.4.0
support/cas-server-support-duo-core-mfa/src/test/java/org/apereo/cas/adaptors/duo/rest/DuoSecurityRestHttpRequestCredentialFactoryTests.java