Search in sources :

Example 1 with BrowserWebStorageSessionStore

use of org.apereo.cas.pac4j.BrowserWebStorageSessionStore in project cas by apereo.

the class BrowserWebStorageSessionStoreTests method verifyOperation.

@Test
public void verifyOperation() {
    val store = new BrowserWebStorageSessionStore(webflowCipherExecutor);
    val request = new MockHttpServletRequest();
    val ctx = new JEEContext(request, new MockHttpServletResponse());
    store.set(ctx, "key1", "value1");
    store.set(ctx, "key2", List.of("HelloWorld"));
    store.set(ctx, "key3", 1234567);
    store.set(ctx, "dummy", new Dummy());
    var session = store.getTrackableSession(ctx);
    assertTrue(session.isPresent());
    store.renewSession(ctx);
    val trackableSession = (BrowserSessionStorage) session.get();
    store.buildFromTrackableSession(ctx, trackableSession.getPayload());
    assertTrue(store.get(ctx, "key1").isPresent());
    assertTrue(store.get(ctx, "key2").isPresent());
    assertTrue(store.get(ctx, "key3").isPresent());
    assertTrue(store.get(ctx, "dummy").isPresent());
}
Also used : lombok.val(lombok.val) BrowserWebStorageSessionStore(org.apereo.cas.pac4j.BrowserWebStorageSessionStore) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) BrowserSessionStorage(org.apereo.cas.web.BrowserSessionStorage) JEEContext(org.pac4j.core.context.JEEContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)1 BrowserWebStorageSessionStore (org.apereo.cas.pac4j.BrowserWebStorageSessionStore)1 BrowserSessionStorage (org.apereo.cas.web.BrowserSessionStorage)1 Test (org.junit.jupiter.api.Test)1 JEEContext (org.pac4j.core.context.JEEContext)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1