use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testUnknownLoginModule.
@Test
public void testUnknownLoginModule() throws IOException {
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect1", credentialFile.getPath());
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 testPostWithoutAppropriateCredential.
@Test
public void testPostWithoutAppropriateCredential() throws IOException {
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getPath()).thenReturn("connectors/connName/tasks");
ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getMethod()).thenReturn(HttpMethod.POST);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect1", credentialFile.getPath());
jaasBasicAuthFilter.filter(requestContext);
verify(uriInfo).getPath();
verify(requestContext).getMethod();
verify(requestContext).getUriInfo();
}
use of javax.ws.rs.container.ContainerRequestContext in project kafka by apache.
the class JaasBasicAuthFilterTest method testUnknownBearer.
@Test
public void testUnknownBearer() throws IOException {
File credentialFile = setupPropertyLoginFile(true);
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", credentialFile.getPath());
ContainerRequestContext requestContext = setMock("Unknown", "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 instrumentation-java by census-instrumentation.
the class JaxrsContainerFilterTest method testResponseFilter.
@Test
public void testResponseFilter() throws Exception {
Span span = new FakeSpan(SpanContext.INVALID, null);
TagContext tagContext = mock(TagContext.class);
HttpRequestContext context = JaxrsClientFilterTest.createHttpRequestContext(span, tagContext);
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getMatchedURIs()).thenReturn(Collections.singletonList("/resource/{route}"));
ContainerRequestContext requestContext = mock(ContainerRequestContext.class);
when(requestContext.getProperty("opencensus.context")).thenReturn(context);
when(requestContext.getUriInfo()).thenReturn(uriInfo);
ContainerResponseContext responseContext = mock(ContainerResponseContext.class);
filter.filter(requestContext, responseContext);
verify(requestContext).getProperty("opencensus.context");
verify(responseContext, times(1)).getStatus();
}
use of javax.ws.rs.container.ContainerRequestContext in project graylog2-server by Graylog2.
the class MessageExportFormatFilterTest method returns415IfAcceptedFormatIsNotEnabled.
@Test
void returns415IfAcceptedFormatIsNotEnabled() throws Exception {
final ContainerRequestFilter filter = new MessageExportFormatFilter(Collections.singleton(disabledJsonExportFormat));
final ContainerRequestContext requestContext = mockRequestContext(Collections.emptyList());
filter.filter(requestContext);
verifyRequestAborted(requestContext);
}
Aggregations