@Test
    public void testAuthentication() {
        Client client = new CookieClient(USERNAME, new SimpleTestTokenAuthenticator());
        val context = MockWebContext.create();

        val c = new Cookie(USERNAME, Base64.getEncoder().encodeToString(getClass().getName().getBytes(StandardCharsets.UTF_8)));
        context.getRequestCookies().add(c);
        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = (TokenCredentials) client.getCredentials(ctx).get();
        val authnCredentials = client.validateCredentials(ctx, credentials).get();
        UserProfile profile = (CommonProfile) client.getUserProfile(ctx, authnCredentials).get();
        assertEquals(c.getValue(), profile.getId());
    }
This class tests the {@link CookieClient} class.

@author Misagh Moayyed
@since 1.8.0
pac4j-http/src/test/java/org/pac4j/http/client/direct/CookieClientTests.java