### Question:
FalconAuthorizationFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if (isAuthorizationEnabled) { HttpServletRequest httpRequest = (HttpServletRequest) request; RequestParts requestParts = getUserRequest(httpRequest); LOG.info("Authorizing user={} against request={}", CurrentUser.getUser(), requestParts); try { final UserGroupInformation authenticatedUGI = CurrentUser.getAuthenticatedUGI(); authorizationProvider.authorizeResource(requestParts.getResource(), requestParts.getAction(), requestParts.getEntityType(), requestParts.getEntityName(), authenticatedUGI); String doAsUser = request.getParameter(DO_AS_PARAM); tryProxy(authenticatedUGI, requestParts.getEntityType(), requestParts.getEntityName(), doAsUser); LOG.info("Authorization succeeded for user={}, proxy={}", authenticatedUGI.getShortUserName(), CurrentUser.getUser()); } catch (AuthorizationException e) { sendError((HttpServletResponse) response, HttpServletResponse.SC_FORBIDDEN, e.getMessage()); return; } catch (EntityNotRegisteredException e) { if (!httpRequest.getMethod().equals(HttpMethod.DELETE)) { sendError((HttpServletResponse) response, HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); return; } } catch (IllegalArgumentException e) { sendError((HttpServletResponse) response, HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); return; } } filterChain.doFilter(request, response); }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain filterChain); @Override void destroy();  }### Answer:
@Test (dataProvider = "resourceWithNoEntity") public void testDoFilter(String resource) throws Exception { boolean[] enabledFlags = {false, true}; for (boolean enabled : enabledFlags) { StartupProperties.get().setProperty( "falcon.security.authorization.enabled", String.valueOf(enabled)); Filter filter = new FalconAuthorizationFilter(); synchronized (StartupProperties.get()) { filter.init(mockConfig); } StringBuffer requestUrl = new StringBuffer("http: Mockito.when(mockRequest.getRequestURL()).thenReturn(requestUrl); Mockito.when(mockRequest.getRequestURI()).thenReturn("/api" + resource); Mockito.when(mockRequest.getPathInfo()).thenReturn(resource); try { filter.doFilter(mockRequest, mockResponse, mockChain); } finally { filter.destroy(); } } }