use of javax.servlet.FilterChain in project neo4j by neo4j.
the class NoCacheHtmlFilterTest method shouldAddCacheControlHeaderToHtmlResponses.
@Test
public void shouldAddCacheControlHeaderToHtmlResponses() throws Exception {
// given
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getServletPath()).thenReturn("index.html");
HttpServletResponse response = mock(HttpServletResponse.class);
FilterChain filterChain = mock(FilterChain.class);
// when
new NoCacheHtmlFilter().doFilter(request, response, filterChain);
// then
verify(response).addHeader("Cache-Control", "no-cache");
verify(filterChain).doFilter(request, response);
}
use of javax.servlet.FilterChain in project hadoop by apache.
the class TestCheckUploadContentTypeFilter method test.
private void test(String method, String operation, String contentType, boolean upload, boolean error) throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
Mockito.reset(request);
Mockito.when(request.getMethod()).thenReturn(method);
Mockito.when(request.getParameter(HttpFSFileSystem.OP_PARAM)).thenReturn(operation);
Mockito.when(request.getParameter(HttpFSParametersProvider.DataParam.NAME)).thenReturn(Boolean.toString(upload));
Mockito.when(request.getContentType()).thenReturn(contentType);
FilterChain chain = Mockito.mock(FilterChain.class);
Filter filter = new CheckUploadContentTypeFilter();
filter.doFilter(request, response, chain);
if (error) {
Mockito.verify(response).sendError(Mockito.eq(HttpServletResponse.SC_BAD_REQUEST), Mockito.contains("Data upload"));
} else {
Mockito.verify(chain).doFilter(request, response);
}
}
use of javax.servlet.FilterChain in project OpenAM by OpenRock.
the class XUIFilterTest method loginRedirectsToXUIWithQuery.
@Test
public void loginRedirectsToXUIWithQuery() throws Exception {
String pathInfo = "/UI/Login";
String query = "locale=fr&realm=/";
String xuiLoginPath = "/XUI/#login/";
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse responseLogin = mock(HttpServletResponse.class);
FilterChain filterChain = mock(FilterChain.class);
when(request.getRequestURI()).thenReturn(pathInfo);
when(request.getQueryString()).thenReturn(query);
filter.doFilter(request, responseLogin, filterChain);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(responseLogin).sendRedirect(captor.capture());
assertThat(captor.getValue()).isEqualTo(CONTEXT + xuiLoginPath + "&" + query);
}
use of javax.servlet.FilterChain in project OpenAM by OpenRock.
the class XUIFilterTest method testLogout.
@Test
public void testLogout() throws Exception {
String xuiLogoutPath = "/XUI/#logout/";
String logoutPath = "/UI/Logout";
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse responseLogout = mock(HttpServletResponse.class);
FilterChain filterChain = mock(FilterChain.class);
when(request.getRequestURI()).thenReturn(logoutPath);
when(request.getQueryString()).thenReturn(null);
filter.doFilter(request, responseLogout, filterChain);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(responseLogout).sendRedirect(captor.capture());
assertThat(captor.getValue()).isEqualTo(CONTEXT + xuiLogoutPath);
}
use of javax.servlet.FilterChain in project OpenAM by OpenRock.
the class XUIFilterTest method testEndUserPage.
@Test
public void testEndUserPage() throws Exception {
String profilePage = "/XUI/#profile/";
String endUserPath = "/idm/EndUser";
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse responseEndUser = mock(HttpServletResponse.class);
FilterChain filterChain = mock(FilterChain.class);
when(request.getRequestURI()).thenReturn(endUserPath);
when(request.getQueryString()).thenReturn(null);
filter.doFilter(request, responseEndUser, filterChain);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verify(responseEndUser).sendRedirect(captor.capture());
assertThat(captor.getValue()).isEqualTo(CONTEXT + profilePage);
}
Aggregations