}
public void testGetCredentialsBadCredentials() {
final BasicAuthClient basicAuthClient = getBasicAuthClient();
final String header = USERNAME + ":" + PASSWORD;
final MockWebContext context = MockWebContext.create();
try {
basicAuthClient
.getCredentials(context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
"Basic " + Base64.encodeBase64String(header.getBytes())));
fail("should throw RequiresHttpAction");
} catch (final RequiresHttpAction e) {
assertEquals(401, context.getResponseStatus());
assertEquals("Basic realm=\"authentication required\"",
context.getResponseHeaders().get(HttpConstants.AUTHENTICATE_HEADER));
assertEquals("Requires basic auth (credentials validation fails)", e.getMessage());
}
}