Search in sources :

Example 46 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class SuggesterControllerTest method testAllowComplexQueries.

@Test
void testAllowComplexQueries() {
    env.getSuggesterConfig().setAllowComplexQueries(false);
    Response r = target(SuggesterController.PATH).queryParam(AuthorizationFilter.PROJECTS_PARAM, "java", "kotlin").queryParam("field", QueryBuilder.FULL).queryParam(QueryBuilder.FULL, "me").queryParam(QueryBuilder.PATH, "kt").request().get();
    assertEquals(Response.Status.NOT_FOUND.getStatusCode(), r.getStatus());
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 47 with Response

use of jakarta.ws.rs.core.Response in project OpenGrok by OpenGrok.

the class SuggesterControllerTest method zTestRebuild.

@Test
void zTestRebuild() throws InterruptedException {
    Response res = target(SuggesterController.PATH).path("rebuild").request().put(Entity.text(""));
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), res.getStatus());
    SuggesterServiceImpl.getInstance().waitForRebuild(15, TimeUnit.SECONDS);
}
Also used : Response(jakarta.ws.rs.core.Response) Test(org.junit.jupiter.api.Test)

Example 48 with Response

use of jakarta.ws.rs.core.Response 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());
}
Also used : Response(jakarta.ws.rs.core.Response) ContainerRequestContext(jakarta.ws.rs.container.ContainerRequestContext) TreeMap(java.util.TreeMap) Test(org.junit.jupiter.api.Test)

Example 49 with Response

use of jakarta.ws.rs.core.Response 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());
}
Also used : Response(jakarta.ws.rs.core.Response) ContainerRequestContext(jakarta.ws.rs.container.ContainerRequestContext)

Example 50 with Response

use of jakarta.ws.rs.core.Response 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());
}
Also used : Response(jakarta.ws.rs.core.Response) ContainerRequestContext(jakarta.ws.rs.container.ContainerRequestContext) Test(org.junit.jupiter.api.Test)

Aggregations

Response (jakarta.ws.rs.core.Response)51 Test (org.junit.jupiter.api.Test)43 ContainerRequestContext (jakarta.ws.rs.container.ContainerRequestContext)6 Path (java.nio.file.Path)3 TreeMap (java.util.TreeMap)3 Configuration (org.opengrok.indexer.configuration.Configuration)3 RuntimeEnvironment (org.opengrok.indexer.configuration.RuntimeEnvironment)3 Message (org.opengrok.indexer.web.messages.Message)3 AcceptedMessage (org.opengrok.indexer.web.messages.MessagesContainer.AcceptedMessage)3 ApiTask (org.opengrok.web.api.ApiTask)3 ApiTaskManager (org.opengrok.web.api.ApiTaskManager)3 File (java.io.File)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)1 NotFoundException (jakarta.ws.rs.NotFoundException)1 WebApplicationException (jakarta.ws.rs.WebApplicationException)1 Client (jakarta.ws.rs.client.Client)1 Invocation (jakarta.ws.rs.client.Invocation)1 IOException (java.io.IOException)1