### Question:
WebSSOResource { @PostConstruct public void init() { clusterName = String.valueOf(context.getAttribute(GATEWAY_CLUSTER_ATTRIBUTE)); handleCookieSetup(); String enableSessionStr = context.getInitParameter(SSO_ENABLE_SESSION_PARAM); this.enableSession = Boolean.parseBoolean(enableSessionStr); String sigAlg = context.getInitParameter(SSO_COOKIE_TOKEN_SIG_ALG); if (sigAlg != null) { signatureAlgorithm = sigAlg; } final String expectedParams = context.getInitParameter(SSO_EXPECTED_PARAM); if (expectedParams != null) { ssoExpectedparams = Arrays.asList(expectedParams.split(",")); } }  @PostConstruct void init(); @GET @Produces({APPLICATION_JSON, APPLICATION_XML}) Response doGet(); @POST @Produces({APPLICATION_JSON, APPLICATION_XML}) Response doPost();  }### Answer:
@Test public void testTopologyDefinedWhitelist() throws Exception { final String testServiceRole = "TEST"; ServletContext context = EasyMock.createNiceMock(ServletContext.class); EasyMock.expect(context.getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE)).andReturn(expectGatewayConfig()).anyTimes(); EasyMock.expect(context.getInitParameter("knoxsso.cookie.name")).andReturn(null); EasyMock.expect(context.getInitParameter("knoxsso.cookie.secure.only")).andReturn(null); EasyMock.expect(context.getInitParameter("knoxsso.cookie.max.age")).andReturn(null); EasyMock.expect(context.getInitParameter("knoxsso.cookie.domain.suffix")).andReturn(null); EasyMock.expect(context.getInitParameter("knoxsso.redirect.whitelist.regex")).andReturn("^.*$"); EasyMock.expect(context.getInitParameter("knoxsso.token.audiences")).andReturn(null); EasyMock.expect(context.getInitParameter("knoxsso.token.ttl")).andReturn("60000"); EasyMock.expect(context.getInitParameter("knoxsso.enable.session")).andReturn(null); HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class); EasyMock.expect(request.getParameter("originalUrl")).andReturn("http: EasyMock.expect(request.getParameterMap()).andReturn(Collections.emptyMap()); EasyMock.expect(request.getServletContext()).andReturn(context).anyTimes(); EasyMock.expect(request.getAttribute("targetServiceRole")).andReturn(testServiceRole).anyTimes(); EasyMock.expect(request.getServerName()).andReturn("localhost").anyTimes(); Principal principal = EasyMock.createNiceMock(Principal.class); EasyMock.expect(principal.getName()).andReturn("alice").anyTimes(); EasyMock.expect(request.getUserPrincipal()).andReturn(principal).anyTimes(); GatewayServices services = EasyMock.createNiceMock(GatewayServices.class); EasyMock.expect(context.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE)).andReturn(services); JWTokenAuthority authority = new TestJWTokenAuthority(gatewayPublicKey, gatewayPrivateKey); EasyMock.expect(services.getService(ServiceType.TOKEN_SERVICE)).andReturn(authority); HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class); ServletOutputStream outputStream = EasyMock.createNiceMock(ServletOutputStream.class); CookieResponseWrapper responseWrapper = new CookieResponseWrapper(response, outputStream); EasyMock.replay(principal, services, context, request); WebSSOResource webSSOResponse = new WebSSOResource(); webSSOResponse.request = request; webSSOResponse.response = responseWrapper; webSSOResponse.context = context; webSSOResponse.init(); Field whitelistField = webSSOResponse.getClass().getDeclaredField("whitelist"); whitelistField.setAccessible(true); String whitelistValue = (String) whitelistField.get(webSSOResponse); assertNotNull(whitelistValue); assertEquals("^.*$", whitelistValue); }