@Test
 public void customizeSessionProperties() throws Exception {
   Map<String, String> map = new HashMap<String, String>();
   map.put("server.session.timeout", "123");
   map.put("server.session.tracking-modes", "cookie,url");
   map.put("server.session.cookie.name", "testname");
   map.put("server.session.cookie.domain", "testdomain");
   map.put("server.session.cookie.path", "/testpath");
   map.put("server.session.cookie.comment", "testcomment");
   map.put("server.session.cookie.http-only", "true");
   map.put("server.session.cookie.secure", "true");
   map.put("server.session.cookie.max-age", "60");
   bindProperties(map);
   ConfigurableEmbeddedServletContainer factory = mock(ConfigurableEmbeddedServletContainer.class);
   ServletContext servletContext = mock(ServletContext.class);
   SessionCookieConfig sessionCookieConfig = mock(SessionCookieConfig.class);
   given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
   this.properties.customize(factory);
   triggerInitializers(factory, servletContext);
   verify(factory).setSessionTimeout(123);
   verify(servletContext)
       .setSessionTrackingModes(EnumSet.of(SessionTrackingMode.COOKIE, SessionTrackingMode.URL));
   verify(sessionCookieConfig).setName("testname");
   verify(sessionCookieConfig).setDomain("testdomain");
   verify(sessionCookieConfig).setPath("/testpath");
   verify(sessionCookieConfig).setComment("testcomment");
   verify(sessionCookieConfig).setHttpOnly(true);
   verify(sessionCookieConfig).setSecure(true);
   verify(sessionCookieConfig).setMaxAge(60);
 }
Ejemplo n.º 2
0
 @Override
 public void onStartup(ServletContext servletContext) throws ServletException {
   if (this.session.getTrackingModes() != null) {
     servletContext.setSessionTrackingModes(this.session.getTrackingModes());
   }
   configureSessionCookie(servletContext.getSessionCookieConfig());
 }
Ejemplo n.º 3
0
 @Override
 public SessionCookieConfig getSessionCookieConfig() {
   return proxy.getSessionCookieConfig();
 }
 public SessionCookieConfig getSessionCookieConfig() {
   return servletContext.getSessionCookieConfig();
 }