use of org.apereo.cas.pac4j.DistributedJEESessionStore in project cas by apereo.
the class DistributedJEESessionStoreTests method verifyTracking.
@Test
public void verifyTracking() {
val cookie = casProperties.getSessionReplication().getCookie();
val cookieGenerator = CookieUtils.buildCookieRetrievingGenerator(cookie);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val store = new DistributedJEESessionStore(centralAuthenticationService, ticketFactory, cookieGenerator);
val context = new JEEContext(request, response);
assertNotNull(request.getSession());
assertFalse(store.renewSession(context));
assertTrue(store.buildFromTrackableSession(context, "trackable-session").isPresent());
assertTrue(store.getTrackableSession(context).isPresent());
}
use of org.apereo.cas.pac4j.DistributedJEESessionStore in project cas by apereo.
the class DistributedJEESessionStoreTests method verifySetGet.
@Test
public void verifySetGet() {
val cookie = casProperties.getSessionReplication().getCookie();
val cookieGenerator = CookieUtils.buildCookieRetrievingGenerator(cookie);
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
val store = new DistributedJEESessionStore(centralAuthenticationService, ticketFactory, cookieGenerator);
val context = new JEEContext(request, response);
assertTrue(store.getSessionId(context, false).isEmpty());
store.set(context, "attribute", "test");
assertTrue(store.getSessionId(context, false).isPresent());
var value = store.get(context, "attribute");
assertTrue(value.isPresent());
assertEquals("test", value.get());
store.set(context, "attribute", "test2");
value = store.get(context, "attribute");
assertTrue(value.isPresent());
assertEquals("test2", value.get());
store.set(context, "attribute", null);
store.set(context, "attribute2", "test3");
assertFalse(store.get(context, "attribute").isPresent());
value = store.get(context, "attribute2");
assertTrue(value.isPresent());
assertEquals("test3", value.get());
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
store.set(context, "not-serializable", new NoSerializable());
}
});
store.destroySession(context);
value = store.get(context, "attribute");
assertTrue(value.isEmpty());
assertTrue(store.getSessionId(context, false).isPresent());
}
Aggregations