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()));
}
use of org.apereo.cas.web.support.mgmr.DefaultCasCookieValueManager in project cas by apereo.
the class DefaultCasCookieValueManagerTests method verifyMissingClientInfo.
@Test
public void verifyMissingClientInfo() {
val props = new TicketGrantingCookieProperties();
val mgr = new DefaultCasCookieValueManager(CipherExecutor.noOp(), props);
ClientInfoHolder.clear();
assertThrows(InvalidCookieException.class, () -> mgr.obtainCookieValue("something@" + CLIENT_IP + '@' + USER_AGENT, new MockHttpServletRequest()));
}
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()));
}
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));
}
Aggregations