use of org.ff4j.web.api.security.FF4jSecurityContextFilter 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.api.security.FF4jSecurityContextFilter in project ff4j by ff4j.
the class SecurityFilterTest method testContextFilterGetWadl.
@Test
public void testContextFilterGetWadl() {
FF4jSecurityContextFilter fscf = new FF4jSecurityContextFilter();
ContainerRequest mockRequest = mock(ContainerRequest.class);
when(mockRequest.getMethod()).thenReturn("GET");
when(mockRequest.getPath(true)).thenReturn("application.wadl");
fscf.filter(mockRequest);
}
use of org.ff4j.web.api.security.FF4jSecurityContextFilter in project ff4j by ff4j.
the class SecurityFilterTest method testUnAuthorizedInvalidValue.
@Test(expected = WebApplicationException.class)
public void testUnAuthorizedInvalidValue() 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("12");
Assert.assertNotNull(faf);
faf.filter(mockRequest);
}
use of org.ff4j.web.api.security.FF4jSecurityContextFilter in project ff4j by ff4j.
the class SecurityFilterTest method testNoAuthorizationAttributeInHeader.
@Test(expected = WebApplicationException.class)
public void testNoAuthorizationAttributeInHeader() 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(null);
Assert.assertNotNull(faf);
faf.filter(mockRequest);
}
use of org.ff4j.web.api.security.FF4jSecurityContextFilter in project ff4j by ff4j.
the class SecurityFilterTest method testUnAuthorized1NoAuthorization.
@Test(expected = WebApplicationException.class)
public void testUnAuthorized1NoAuthorization() throws IOException {
// Given
FF4jSecurityContextFilter faf = new FF4jSecurityContextFilter();
ContainerRequest mockRequest = mock(ContainerRequest.class);
when(mockRequest.getMethod()).thenReturn("GET");
when(mockRequest.getPath(true)).thenReturn("someURLl");
Assert.assertNotNull(faf);
faf.filter(mockRequest);
}
Aggregations