use of jakarta.ws.rs.container.ContainerRequestContext in project OpenGrok by OpenGrok.
the class IncomingFilterTest method localhostTestWithForwardedHeader.
@Test
public void localhostTestWithForwardedHeader() throws Exception {
Map<String, String> headers = new TreeMap<>();
headers.put("X-Forwarded-For", "192.0.2.43, 2001:db8:cafe::17");
IncomingFilter filter = mockWithRemoteAddress("127.0.0.1", headers, true);
ContainerRequestContext context = mockContainerRequestContext("test");
ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
filter.filter(context);
verify(context).abortWith(captor.capture());
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), captor.getValue().getStatus());
}
use of jakarta.ws.rs.container.ContainerRequestContext in project OpenGrok by OpenGrok.
the class IncomingFilterTest method assertFilterDoesNotBlockAddress.
private void assertFilterDoesNotBlockAddress(final String remoteAddr) throws Exception {
IncomingFilter filter = mockWithRemoteAddress(remoteAddr);
ContainerRequestContext context = mockContainerRequestContext("test");
ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
filter.filter(context);
verify(context, never()).abortWith(captor.capture());
}
use of jakarta.ws.rs.container.ContainerRequestContext in project OpenGrok by OpenGrok.
the class IncomingFilterTest method searchTest.
@Test
public void searchTest() throws Exception {
IncomingFilter filter = mockWithRemoteAddress("10.0.0.1");
ContainerRequestContext context = mockContainerRequestContext("search");
ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
filter.filter(context);
verify(context, never()).abortWith(captor.capture());
}
Aggregations