### Question:
ConvertAuthTokenInUriToCookieFilter extends ZuulFilter { public Object run() { RequestContext context = RequestContext.getCurrentContext(); AuthConfigurationProperties.CookieProperties cp = authConfigurationProperties.getCookieProperties(); if ((context.getRequestQueryParams() != null) && context.getRequestQueryParams().containsKey(cp.getCookieName())) { HttpServletResponse servletResponse = context.getResponse(); Cookie cookie = new Cookie(cp.getCookieName(), context.getRequestQueryParams().get(cp.getCookieName()).get(0)); cookie.setPath(cp.getCookiePath()); cookie.setSecure(true); cookie.setHttpOnly(true); cookie.setMaxAge(cp.getCookieMaxAge()); cookie.setComment(cp.getCookieComment()); servletResponse.addCookie(cookie); String url = context.getRequest().getRequestURL().toString(); String newUrl; if (url.endsWith("/apicatalog/")) { newUrl = url + "#/dashboard"; } else { newUrl = url; } context.addZuulResponseHeader("Location", newUrl); context.setResponseStatusCode(HttpServletResponse.SC_MOVED_TEMPORARILY); } return null; } ConvertAuthTokenInUriToCookieFilter(AuthConfigurationProperties authConfigurationProperties); String filterType(); int filterOrder(); boolean shouldFilter(); Object run();  }### Answer:
@Test void doesNotDoAnythingWhenThereIsNoParam() { this.filter.run(); assertFalse(ctx.getResponse().getHeaderNames().contains("Set-Cookie")); }
@Test void doesNotDoAnythingWhenThereIsAnotherParam() { Map<String, List<String>> params = new HashMap<>(); params.put("someParameter", Collections.singletonList("value")); ctx.setRequestQueryParams(params); this.filter.run(); assertFalse(ctx.getResponse().getHeaderNames().contains("Set-Cookie")); }
@Test void setsCookieForCorrectParameter() { ctx.setRequest(new MockHttpServletRequest("GET", "/api/v1/service")); Map<String, List<String>> params = new HashMap<>(); params.put(authConfigurationProperties.getCookieProperties().getCookieName(), Collections.singletonList("token")); ctx.setRequestQueryParams(params); this.filter.run(); assertTrue(ctx.getResponse().getHeaders("Set-Cookie").toString().contains("apimlAuthenticationToken=token")); assertEquals("Location", ctx.getZuulResponseHeaders().get(0).first()); assertEquals("http: }
@Test void setsLocationToDashboardForApiCatalog() { ctx.setRequest(new MockHttpServletRequest("GET", "/api/v1/apicatalog/")); Map<String, List<String>> params = new HashMap<>(); params.put(authConfigurationProperties.getCookieProperties().getCookieName(), Collections.singletonList("token")); ctx.setRequestQueryParams(params); this.filter.run(); assertTrue(ctx.getResponse().getHeaders("Set-Cookie").toString().contains("apimlAuthenticationToken=token")); assertEquals("Location", ctx.getZuulResponseHeaders().get(0).first()); assertEquals("http: }