use of com.hotels.styx.api.ResponseCookie in project styx by ExpediaGroup.
the class StickySessionCookieTest method createsCookieFromApplicationOriginAndMaxAge.
@Test
public void createsCookieFromApplicationOriginAndMaxAge() {
ResponseCookie cookie = newStickySessionCookie(id("app"), id("app-01"), 86400);
assertThat(cookie.name(), is("styx_origin_app"));
assertThat(cookie.value(), is("app-01"));
assertThat(cookie.maxAge(), isValue(86400L));
assertThat(cookie.path(), isValue("/"));
assertThat(cookie.httpOnly(), is(true));
}
use of com.hotels.styx.api.ResponseCookie in project styx by ExpediaGroup.
the class StyxToNettyResponseTranslatorTest method shouldCreateNettyResponseWithCookieWithAttributes.
@Test
public void shouldCreateNettyResponseWithCookieWithAttributes() {
ResponseCookie cookie = responseCookie("cookie-test", "cookie-value").domain("cookie-domain").path("cookie-path").maxAge(1234).httpOnly(true).secure(true).build();
LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK).cookies(cookie).build();
io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse);
String setCookie = nettyResponse.headers().get(SET_COOKIE);
Cookie nettyCookie = ClientCookieDecoder.LAX.decode(setCookie);
assertThat(nettyCookie.name(), is("cookie-test"));
assertThat(nettyCookie.value(), is("cookie-value"));
assertThat(nettyCookie.domain(), is("cookie-domain"));
assertThat(nettyCookie.maxAge(), is(1234L));
assertThat(nettyCookie.isHttpOnly(), is(true));
assertThat(nettyCookie.isSecure(), is(true));
}
Aggregations