Search in sources :

Example 1 with CorsFilter

use of org.opengrok.web.api.v1.filter.CorsFilter in project OpenGrok by OpenGrok.

the class CorsFilterTest method testBoth.

private void testBoth(String origin, List<Object> headerValue) {
    CorsFilter filter = new CorsFilter();
    ContainerRequestContext request = mock(ContainerRequestContext.class);
    when(request.getHeaderString(CORS_REQUEST_HEADER)).thenReturn(origin);
    ContainerResponseContext response = mock(ContainerResponseContext.class);
    MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
    when(response.getHeaders()).thenReturn(headers);
    filter.filter(request, response);
    assertEquals(headerValue, headers.get(ALLOW_CORS_HEADER));
}
Also used : CorsFilter(org.opengrok.web.api.v1.filter.CorsFilter) MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) ContainerRequestContext(jakarta.ws.rs.container.ContainerRequestContext) ContainerResponseContext(jakarta.ws.rs.container.ContainerResponseContext)

Aggregations

ContainerRequestContext (jakarta.ws.rs.container.ContainerRequestContext)1 ContainerResponseContext (jakarta.ws.rs.container.ContainerResponseContext)1 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)1 CorsFilter (org.opengrok.web.api.v1.filter.CorsFilter)1