use of org.ff4j.web.api.security.FF4jAuthenticationFilter in project ff4j by ff4j.
the class SecurityAuthenticationFilterTest method testUnAuthorized1NoAuthorization.
@Test(expected = WebApplicationException.class)
public void testUnAuthorized1NoAuthorization() throws IOException {
// Given
FF4jAuthenticationFilter faf = new FF4jAuthenticationFilter();
ContainerRequestContext mockRequest = mock(ContainerRequestContext.class);
when(mockRequest.getMethod()).thenReturn("GET");
UriInfo mockUriInfo = mock(UriInfo.class);
when(mockUriInfo.getPath()).thenReturn("someURL");
when(mockRequest.getUriInfo()).thenReturn(mockUriInfo);
faf.filter(mockRequest);
}
use of org.ff4j.web.api.security.FF4jAuthenticationFilter 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.api.security.FF4jAuthenticationFilter 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.api.security.FF4jAuthenticationFilter in project ff4j by ff4j.
the class SecurityAuthenticationFilterTest method testGETWadl.
@Test
public void testGETWadl() throws IOException {
// Given
FF4jAuthenticationFilter faf = new FF4jAuthenticationFilter();
ContainerRequestContext mockRequest = mock(ContainerRequestContext.class);
when(mockRequest.getMethod()).thenReturn("GET");
UriInfo mockUriInfo = mock(UriInfo.class);
when(mockUriInfo.getPath()).thenReturn("application.wadl");
when(mockRequest.getUriInfo()).thenReturn(mockUriInfo);
faf.filter(mockRequest);
}
use of org.ff4j.web.api.security.FF4jAuthenticationFilter in project ff4j by ff4j.
the class SecurityAuthenticationFilterTest method testUnAuthorizedInvalidValue.
@Test(expected = WebApplicationException.class)
public void testUnAuthorizedInvalidValue() throws IOException {
// Given
FF4jAuthenticationFilter faf = new FF4jAuthenticationFilter();
ContainerRequestContext mockRequest = mock(ContainerRequestContext.class);
when(mockRequest.getHeaderString("Authorization")).thenReturn("12");
when(mockRequest.getMethod()).thenReturn("GET");
UriInfo mockUriInfo = mock(UriInfo.class);
when(mockUriInfo.getPath()).thenReturn("someURL");
when(mockRequest.getUriInfo()).thenReturn(mockUriInfo);
faf.filter(mockRequest);
}
Aggregations