@Test
public void testAuthenticateCertificate() {

    HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
    Http.AuthorityList authorities = new Http.AuthorityList();
    Authority authority = Mockito.mock(Authority.class);
    Mockito.when(authority.getCredSource()).thenReturn(CredSource.CERTIFICATE);
    X509Certificate[] certs = new X509Certificate[1];
    certs[0] = Mockito.mock(X509Certificate.class);
    Mockito.when(httpServletRequest.getAttribute(Http.JAVAX_CERT_ATTR)).thenReturn(certs);
    Principal principal = Mockito.mock(Principal.class);
    Mockito.when(authority.authenticate(ArgumentMatchers.any(X509Certificate[].class),
            ArgumentMatchers.any())).thenReturn(principal);
    authorities.add(authority);
    assertNotNull(Http.authenticate(httpServletRequest, authorities));
}