@Test
    public void testAuthentication() {
        val client = new DirectDigestAuthClient(new SimpleTestDigestAuthenticator());
        client.setRealm(REALM);
        val context = MockWebContext.create();
        context.addRequestHeader(AUTHORIZATION_HEADER,
                DIGEST_AUTHORIZATION_HEADER_VALUE);
        context.setRequestMethod(HTTP_METHOD.GET.name());

        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = (DigestCredentials) client.getCredentials(ctx).get();
        val authnCredentials = client.validateCredentials(ctx, credentials).get();
        UserProfile profile = (CommonProfile) client.getUserProfile(ctx, authnCredentials).get();

        val ha1 = CredentialUtil.encryptMD5(USERNAME + ":" + REALM + ":" +PASSWORD);
        val serverDigest1 = credentials.calculateServerDigest(true, ha1);
        val serverDigest2 = credentials.calculateServerDigest(false, PASSWORD);
        assertEquals(DIGEST_RESPONSE, serverDigest1);
        assertEquals(DIGEST_RESPONSE, serverDigest2);
        assertEquals(USERNAME, profile.getId());
    }
This class tests the {@link DirectDigestAuthClient} class.

@author Mircea Carasel
@since 1.9.0
pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectDigestAuthClientTests.java