use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testNoFileOption.
@Test
public void testNoFileOption() throws IOException {
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", null);
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 testPostNotChangingConnectorTask.
@Test
public void testPostNotChangingConnectorTask() throws IOException {
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getPath()).thenReturn("local:randomport/connectors/connName");
ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getMethod()).thenReturn(HttpMethod.POST);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
String authHeader = "Basic" + Base64.getEncoder().encodeToString(("user" + ":" + "password").getBytes());
when(requestContext.getHeaderString(JaasBasicAuthFilter.AUTHORIZATION)).thenReturn(authHeader);
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", credentialFile.getPath());
jaasBasicAuthFilter.filter(requestContext);
verify(requestContext).abortWith(any(Response.class));
verify(requestContext).getUriInfo();
verify(requestContext).getUriInfo();
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testSuccess.
@Test
public void testSuccess() throws IOException {
File credentialFile = setupPropertyLoginFile(true);
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 testBadCredential.
@Test
public void testBadCredential() throws IOException {
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", credentialFile.getPath());
ContainerRequestContext requestContext = setMock("Basic", "user1", "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 instrumentation-java by census-instrumentation.
the class JaxrsContainerFilterTest method testRequestFilter.
@Test
public void testRequestFilter() throws Exception {
UriInfo uriInfo = mock(UriInfo.class);
ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
filter.filter(requestContext);
verify(requestContext).setProperty(eq("opencensus.context"), any());
}
Aggregations