use of org.ff4j.web.ApiConfig in project ff4j by ff4j.
the class SecurityFilterTest method testAuthorizedApiKey.
@Test
public void testAuthorizedApiKey() throws IOException {
// Define ApiConfig
FF4jSecurityContextFilter.setSecurityConfig(new ApiConfig().createApiKey("12", true, true, Util.set("USER")));
// Given
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");
Assert.assertNotNull(faf);
faf.filter(mockRequest);
}
use of org.ff4j.web.ApiConfig in project ff4j by ff4j.
the class SampleFF4jJersey2Application method getWebApiConfiguration.
@Override
protected ApiConfig getWebApiConfiguration() {
ApiConfig fac = new ApiConfig(ff4j);
fac.setDocumentation(true);
fac.setPort(3388);
fac.setHost("localhost");
fac.setWebContext("webapi");
return fac;
}
use of org.ff4j.web.ApiConfig in project ff4j by ff4j.
the class SecurityAuthenticationFilterTest method testUnAuthorizedApiKey.
@Test(expected = WebApplicationException.class)
public void testUnAuthorizedApiKey() throws IOException {
// Given
FF4jAuthenticationFilter faf = new FF4jAuthenticationFilter();
ContainerRequestContext mockRequest = mock(ContainerRequestContext.class);
when(mockRequest.getHeaderString("Authorization")).thenReturn("apiKey=12");
when(mockRequest.getMethod()).thenReturn("GET");
UriInfo mockUriInfo = mock(UriInfo.class);
when(mockUriInfo.getPath()).thenReturn("someURL");
when(mockRequest.getUriInfo()).thenReturn(mockUriInfo);
// Define ApiConfig
FF4jAuthenticationFilter.setApiConfig(new ApiConfig());
// When
faf.filter(mockRequest);
}
use of org.ff4j.web.ApiConfig in project ff4j by ff4j.
the class SecurityAuthenticationFilterTest method testAuthorizedApiKey.
@Test
public void testAuthorizedApiKey() throws IOException {
// Define ApiConfig
FF4jAuthenticationFilter.setApiConfig(new ApiConfig().createApiKey("12", true, true, Util.set("USER")));
// Given
FF4jAuthenticationFilter faf = new FF4jAuthenticationFilter();
ContainerRequestContext mockRequest = mock(ContainerRequestContext.class);
when(mockRequest.getHeaderString("Authorization")).thenReturn("apiKey=12");
when(mockRequest.getMethod()).thenReturn("GET");
UriInfo mockUriInfo = mock(UriInfo.class);
when(mockUriInfo.getPath()).thenReturn("someURL");
when(mockRequest.getUriInfo()).thenReturn(mockUriInfo);
// When
faf.filter(mockRequest);
}
use of org.ff4j.web.ApiConfig in project ff4j by ff4j.
the class SecurityAuthorizationFilterTest method testAccessors.
@Test
public void testAccessors() throws IOException {
// Given
FF4jAuthorizationFilter faf = new FF4jAuthorizationFilter();
Assert.assertNull(faf.getInfo());
Assert.assertNull(FF4jAuthorizationFilter.getApiConfig());
FF4jAuthorizationFilter.setApiConfig(new ApiConfig());
Assert.assertNotNull(FF4jAuthorizationFilter.getApiConfig());
}
Aggregations