Search in sources :

Example 1 with MockCookie

use of org.springframework.mock.web.MockCookie in project cas by apereo.

the class CookieRetrievingCookieGeneratorTests method verifyCookieSameSiteLax.

@Test
public void verifyCookieSameSiteLax() {
    val ctx = getCookieGenerationContext();
    ctx.setSameSitePolicy("lax");
    val gen = new CookieRetrievingCookieGenerator(ctx);
    val context = new MockRequestContext();
    val request = new MockHttpServletRequest();
    val response = new MockHttpServletResponse();
    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
    gen.addCookie(request, response, false, "CAS-Cookie-Value");
    val cookie = (MockCookie) response.getCookie(ctx.getName());
    assertNotNull(cookie);
    assertEquals("Lax", cookie.getSameSite());
}
Also used : lombok.val(lombok.val) CookieRetrievingCookieGenerator(org.apereo.cas.web.support.gen.CookieRetrievingCookieGenerator) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) MockCookie(org.springframework.mock.web.MockCookie) MockRequestContext(org.springframework.webflow.test.MockRequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)1 CookieRetrievingCookieGenerator (org.apereo.cas.web.support.gen.CookieRetrievingCookieGenerator)1 Test (org.junit.jupiter.api.Test)1 MockCookie (org.springframework.mock.web.MockCookie)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)1 MockRequestContext (org.springframework.webflow.test.MockRequestContext)1