@Test
public void testAuthenticateHeaderErrorMessage() {

    HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
    Mockito.when(httpServletRequest.getHeader("Athenz-Principal-Auth")).thenReturn("Creds");
    Http.AuthorityList authorities = new Http.AuthorityList();
    PrincipalAuthority authority1 = new PrincipalAuthority();
    authorities.add(authority1);
    PrincipalAuthority authority2 = new PrincipalAuthority();
    authorities.add(authority2);
    try {
        Http.authenticate(httpServletRequest, authorities);
    } catch (ResourceException expected) {
        assertEquals(expected.getCode(), 401);
    }
    Mockito.verify(httpServletRequest, times(1))
            .setAttribute(ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
    Mockito.verify(httpServletRequest, times(1))
            .setAttribute(ArgumentMatchers.anyString(), ArgumentMatchers.anyIterable());
}