Search in sources :

Example 6 with FF4jSecurityContextFilter

use of org.ff4j.web.api.security.FF4jSecurityContextFilter in project ff4j by ff4j.

the class SecurityFilterTest method testUnAuthorizedApiKey.

@Test(expected = WebApplicationException.class)
public void testUnAuthorizedApiKey() throws IOException {
    FF4jSecurityContextFilter faf = new FF4jSecurityContextFilter();
    ContainerRequest mockRequest = mock(ContainerRequest.class);
    when(mockRequest.getMethod()).thenReturn("GET");
    when(mockRequest.getPath(true)).thenReturn("someURLl");
    when(mockRequest.getHeaderValue("Authorization")).thenReturn("apiKey=12");
    FF4jSecurityContextFilter.setSecurityConfig(new ApiConfig());
    Assert.assertNotNull(faf);
    faf.filter(mockRequest);
}
Also used : ContainerRequest(com.sun.jersey.spi.container.ContainerRequest) ApiConfig(org.ff4j.web.ApiConfig) FF4jSecurityContextFilter(org.ff4j.web.api.security.FF4jSecurityContextFilter) Test(org.junit.Test)

Aggregations

ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)6 FF4jSecurityContextFilter (org.ff4j.web.api.security.FF4jSecurityContextFilter)6 Test (org.junit.Test)6 ApiConfig (org.ff4j.web.ApiConfig)2