use of javax.ws.rs.container.ContainerRequestContext in project dropwizard by dropwizard.
the class AuthFilterTest method isSecureShouldStayTheSame.
@Test
void isSecureShouldStayTheSame() throws Exception {
ContainerRequestContext requestContext = new FakeSecureRequestContext();
new SimpleAuthFilter().filter(requestContext);
assertTrue(requestContext.getSecurityContext().isSecure());
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method setMock.
private ContainerRequestContext setMock(String authorization, String username, String password) {
ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getMethod()).thenReturn(HttpMethod.GET);
when(requestContext.getHeaderString(JaasBasicAuthFilter.AUTHORIZATION)).thenReturn(authHeader(authorization, username, password));
return requestContext;
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testUnknownCredentialsFile.
@Test
public void testUnknownCredentialsFile() throws IOException {
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", "/tmp/testcrednetial");
ContainerRequestContext requestContext = setMock("Basic", "user", "password");
jaasBasicAuthFilter.filter(requestContext);
verify(requestContext).abortWith(any(Response.class));
verify(requestContext).getMethod();
verify(requestContext).getHeaderString(JaasBasicAuthFilter.AUTHORIZATION);
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testEmptyCredentialsFile.
@Test
public void testEmptyCredentialsFile() throws IOException {
File credentialFile = setupPropertyLoginFile(false);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", credentialFile.getPath());
ContainerRequestContext requestContext = setMock("Basic", "user", "password");
jaasBasicAuthFilter.filter(requestContext);
verify(requestContext).getMethod();
verify(requestContext).getHeaderString(JaasBasicAuthFilter.AUTHORIZATION);
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testBadPassword.
@Test
public void testBadPassword() throws IOException {
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", credentialFile.getPath());
ContainerRequestContext requestContext = setMock("Basic", "user", "password1");
jaasBasicAuthFilter.filter(requestContext);
verify(requestContext).abortWith(any(Response.class));
verify(requestContext).getMethod();
verify(requestContext).getHeaderString(JaasBasicAuthFilter.AUTHORIZATION);
}
Aggregations