@Test
    void verifyClientCredentialExtracted() throws Throwable {
        val context = MockRequestContext.create(applicationContext);
        val client = mock(BaseClient.class);

        val uid = UUID.randomUUID().toString();
        val passwordlessRequest = PasswordlessAuthenticationRequest
            .builder()
            .properties(Map.of(SurrogatePasswordlessAuthenticationRequestParser.PROPERTY_SURROGATE_USERNAME, "cassurrogate"))
            .username(uid)
            .build();
        PasswordlessWebflowUtils.putPasswordlessAuthenticationRequest(context, passwordlessRequest);

        val tokenCredentials = new TokenCredentials(uid);
        when(client.getCredentials(any())).thenReturn(Optional.of(tokenCredentials));
        when(client.validateCredentials(any(), any())).thenReturn(Optional.of(tokenCredentials));

        val credentials = delegatedAuthenticationCredentialExtractor.extract(client, context).get();
        assertNotNull(credentials);
        val trait = credentials.getCredentialMetadata().getTrait(SurrogateCredentialTrait.class);
        assertTrue(trait.isPresent());
        assertEquals("cassurrogate", trait.get().getSurrogateUsername());
        when(client.getCredentials(any())).thenReturn(Optional.empty());
        assertTrue(delegatedAuthenticationCredentialExtractor.extract(client, context).isEmpty());
    }
This is {@link SurrogateDelegatedAuthenticationCredentialExtractorTests}.

@author Misagh Moayyed
@since 7.0.0
support/cas-server-support-surrogate-webflow/src/test/java/org/apereo/cas/web/flow/pac4j/SurrogateDelegatedAuthenticationCredentialExtractorTests.java