Search in sources :

Example 1 with ResponseCookie

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));
}
Also used : ResponseCookie(com.hotels.styx.api.ResponseCookie) Test(org.junit.jupiter.api.Test)

Example 2 with ResponseCookie

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));
}
Also used : Cookie(io.netty.handler.codec.http.cookie.Cookie) ResponseCookie(com.hotels.styx.api.ResponseCookie) ResponseCookie.responseCookie(com.hotels.styx.api.ResponseCookie.responseCookie) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) ResponseCookie(com.hotels.styx.api.ResponseCookie) Test(org.junit.jupiter.api.Test)

Aggregations

ResponseCookie (com.hotels.styx.api.ResponseCookie)2 Test (org.junit.jupiter.api.Test)2 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)1 ResponseCookie.responseCookie (com.hotels.styx.api.ResponseCookie.responseCookie)1 Cookie (io.netty.handler.codec.http.cookie.Cookie)1