Search in sources :

Example 1 with DefaultCasCookieValueManager

use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.

the class DefaultCasCookieValueManagerTests method verifyNoPinning.

@Test
public void verifyNoPinning() {
    val props = new TicketGrantingCookieProperties();
    props.setPinToSession(false);
    val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
    assertEquals("something", mgr.obtainCookieValue("something", new MockHttpServletRequest()));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) DefaultCasCookieValueManager(org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultCasCookieValueManager

use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.

the class DefaultCasCookieValueManagerTests method verifyBadIp.

@Test
public void verifyBadIp() {
    val props = new TicketGrantingCookieProperties();
    val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
    assertThrows(InvalidCookieException.class, () -> mgr.obtainCookieValue("something@1@agent", new MockHttpServletRequest()));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) DefaultCasCookieValueManager(org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultCasCookieValueManager

use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.

the class DefaultCasCookieValueManagerTests method verifyBadValue.

@Test
public void verifyBadValue() {
    val props = new TicketGrantingCookieProperties();
    val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
    assertThrows(InvalidCookieException.class, () -> mgr.obtainCookieValue("something", new MockHttpServletRequest()));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) DefaultCasCookieValueManager(org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultCasCookieValueManager

use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.

the class DefaultCasCookieValueManagerTests method verifyBadAgent.

@Test
public void verifyBadAgent() {
    val props = new TicketGrantingCookieProperties();
    val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
    assertThrows(InvalidCookieException.class, () -> mgr.obtainCookieValue("something@" + ClientInfoHolder.getClientInfo().getClientIpAddress() + "@agent", new MockHttpServletRequest()));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) DefaultCasCookieValueManager(org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultCasCookieValueManager

use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.

the class DefaultCasCookieValueManagerTests method verifySessionPinning.

@Test
public void verifySessionPinning() {
    val request = new MockHttpServletRequest();
    request.setRemoteAddr(CLIENT_IP);
    request.setLocalAddr(CLIENT_IP);
    request.removeHeader("User-Agent");
    ClientInfoHolder.setClientInfo(new ClientInfo(request));
    val props = new TicketGrantingCookieProperties();
    assertThrows(IllegalStateException.class, () -> new DefaultCasCookieValueManager(CipherExecutor.noOp(), props).buildCookieValue(VALUE, request));
    props.setPinToSession(false);
    assertNotNull(new DefaultCasCookieValueManager(CipherExecutor.noOp(), props).buildCookieValue(VALUE, request));
}
Also used : lombok.val(lombok.val) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) TicketGrantingCookieProperties(org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties) ClientInfo(org.apereo.inspektr.common.web.ClientInfo) DefaultCasCookieValueManager(org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)9 TicketGrantingCookieProperties (org.apereo.cas.configuration.model.support.cookie.TicketGrantingCookieProperties)9 DefaultCasCookieValueManager (org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager)9 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)9 Test (org.junit.jupiter.api.Test)8 ClientInfo (org.apereo.inspektr.common.web.ClientInfo)3 BeforeEach (org.junit.jupiter.api.BeforeEach)1