@Test
    public void testAuthentication() {
        when(krbValidator.validateTicket(any())).thenReturn(new KerberosTicketValidation("garry", null, null, null));
        val client = new DirectKerberosClient(new KerberosAuthenticator(krbValidator));
        val context = MockWebContext.create();

        context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER, "Negotiate " + new String(KERBEROS_TICKET, StandardCharsets.UTF_8));
        val ctx = new CallContext(context, new MockSessionStore());
        val credentials = (KerberosCredentials) client.getCredentials(ctx).get();
        assertEquals(new String(Base64.getDecoder().decode(KERBEROS_TICKET), StandardCharsets.UTF_8),
            new String(credentials.getKerberosTicket(), StandardCharsets.UTF_8));
        val authnCredentials = client.validateCredentials(ctx, credentials);
        UserProfile profile = (CommonProfile) client.getUserProfile(ctx, authnCredentials.get()).get();
        assertEquals("garry", profile.getId());
    }
Tests the Kerberos client with mocked Kerberos authenticator/validator (i.e. no real tickets used)

@author Garry Boyce
@author Vidmantas Zemleris
@since 2.1.0
pac4j-kerberos/src/test/java/org/pac4j/kerberos/client/direct/KerberosClientTests.java