### Question:
CatalogRestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (!GeoServerExtensions.bean(GeoServerSecurityManager.class).checkAuthenticationForAdminRole()) { response.sendError(HttpStatus.UNAUTHORIZED.value(), "Full authentication is required to access this resource"); return false; } return true; }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); final static String[] PATHS; }### Answer:
@Test @WithMockUser(username = ADMIN_USERNAME, password = ADMIN_PASSWORD, roles = ADMIN_ROLES) public void testInterceptor() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(RequestMethod.GET.toString(), TEST_URL); MockHttpServletResponse response = new MockHttpServletResponse(); boolean grantAccess = interceptor.preHandle(request, response, null); assertTrue(grantAccess); }
@Test @WithMockUser(username = USER_USERNAME, password = USER_PASSWORD, roles = USER_ROLES) public void testUnauthorizedInterceptor() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(RequestMethod.GET.toString(), TEST_URL); MockHttpServletResponse response = new MockHttpServletResponse(); boolean grantAccess = interceptor.preHandle(request, response, null); assertFalse(grantAccess); }