BaseAuthFilter extends ModalityFilter { protected void processForbiddenRequest(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { logger.debug("unauthorized request towards {}", request.getRequestURI()); response.sendError(HttpServletResponse.SC_FORBIDDEN); }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain); @Override void destroy(); static final String REALM; static final String PROTECTED_RESOURCES; static final String PUBLIC_RESOURCES; }
@Test public void processForbiddenRequest() throws Exception { recordConfig(); expect(request.getRequestURI()).andAnswer(eval("/some-uri")); expect(request.getParameter("Good-Login")).andAnswer(eval(null)); expect(request.getRequestURI()).andAnswer(eval("/some-uri")); response.sendError(HttpServletResponse.SC_FORBIDDEN); replayAll(); authFilter = new AuthFilter(); authFilter.init(filterConfig); authFilter.doFilter(request, response, filterChain); }