@Test
    public void testAuthentication() {
        val client = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
        val context = MockWebContext.create();
        val header = USERNAME + ":" + USERNAME;
        context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
            "Basic " + Base64.getEncoder().encodeToString(header.getBytes(StandardCharsets.UTF_8)));
        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = (UsernamePasswordCredentials) client.getCredentials(ctx).get();
        assertEquals(CredentialSource.HEADER.name(), credentials.getSource());
        val authnCredentials = client.validateCredentials(ctx, credentials).get();
        val profile = (CommonProfile) client.getUserProfile(ctx, authnCredentials).get();
        assertEquals(USERNAME, profile.getId());
    }
This class tests the {@link DirectBasicAuthClient} class.

@author Jerome Leleu
@since 1.8.0
pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBasicAuthClientTests.java