### Question:
PermissionSensitiveCacheServlet extends SlingSafeMethodsServlet { public void doHead(SlingHttpServletRequest request, SlingHttpServletResponse response) { try{ ResourceResolver resourceResolver = request.getResourceResolver(); String requestUri = request.getParameter( "uri" ); log.debug( "Checking access for URI {}", requestUri ); if( isUriValid( requestUri ) ){ Resource requestedResource = resourceResolver.resolve( request, requestUri ); if( !ResourceUtil.isNonExistingResource( requestedResource ) ){ log.debug("Current Session has access to {}", requestUri ); response.setStatus(HttpServletResponse.SC_OK); } else { log.info("Current Session does not have access to {}", requestUri ); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } } else { log.debug( "Invalid URI {}", requestUri ); response.setStatus( HttpServletResponse.SC_UNAUTHORIZED ); } } catch(Exception e) { log.error("Authchecker servlet exception", e); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED ); } }  void doHead(SlingHttpServletRequest request, SlingHttpServletResponse response); boolean isUriValid( String requestUri );  }### Answer:
@Test public void doHeadShouldAllowAccess() throws Exception { context.create().resource( "/content/test" ); request = context.request(); Map<String,Object> requestMap = new HashMap<>(); requestMap.put( "uri", TEST_PAGE ); request.setParameterMap( requestMap ); MockSlingHttpServletResponse response = context.response(); servlet.doHead( request, response ); assertEquals( HttpServletResponse.SC_OK, response.getStatus() ); }
@Test public void doHeadShouldNotAllowAccess() throws Exception { request = context.request(); Map<String,Object> requestMap = new HashMap<>(); requestMap.put( "uri", TEST_PAGE ); request.setParameterMap( requestMap ); MockSlingHttpServletResponse response = context.response(); servlet.doHead( request, response ); assertEquals( HttpServletResponse.SC_UNAUTHORIZED, response.getStatus() ); }