File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
test/java/eu/webeid/example/config Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 11spring.profiles.active =dev
2- server.servlet.session.cookie.name =__Host-JSESSIONID
Original file line number Diff line number Diff line change 1+ package eu .webeid .example .config ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import jakarta .servlet .ServletContext ;
6+ import jakarta .servlet .SessionCookieConfig ;
7+ import org .junit .jupiter .api .Test ;
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .boot .test .context .SpringBootTest ;
10+ import org .springframework .boot .test .context .SpringBootTest .WebEnvironment ;
11+ import org .springframework .boot .web .servlet .context .ServletWebServerApplicationContext ;
12+ import org .springframework .test .context .TestPropertySource ;
13+
14+ @ SpringBootTest (webEnvironment = WebEnvironment .RANDOM_PORT )
15+ @ TestPropertySource (properties = {"web-eid-auth-token.validation.local-origin=http://localhost" })
16+ class CookieHttpTest {
17+
18+ @ Autowired
19+ private ServletWebServerApplicationContext context ;
20+
21+ @ Test
22+ void whenLocalOriginStartsWithHttp_thenCookeDoesNotHaveHostPrefix () {
23+ ServletContext servletContext = context .getServletContext ();
24+ SessionCookieConfig cookieConfig = servletContext .getSessionCookieConfig ();
25+ assertThat (cookieConfig .getName ()).isEqualTo ("JSESSIONID" );
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ package eu .webeid .example .config ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import jakarta .servlet .ServletContext ;
6+ import jakarta .servlet .SessionCookieConfig ;
7+ import org .junit .jupiter .api .Test ;
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .boot .test .context .SpringBootTest ;
10+ import org .springframework .boot .test .context .SpringBootTest .WebEnvironment ;
11+ import org .springframework .boot .web .servlet .context .ServletWebServerApplicationContext ;
12+ import org .springframework .test .context .TestPropertySource ;
13+
14+ @ SpringBootTest (webEnvironment = WebEnvironment .RANDOM_PORT )
15+ @ TestPropertySource (properties = {"web-eid-auth-token.validation.local-origin=https://localhost" })
16+ class CookieHttpsTest {
17+
18+ @ Autowired
19+ private ServletWebServerApplicationContext context ;
20+
21+ @ Test
22+ void whenLocalOriginStartsWithHttp_thenCookeDoesNotHaveHostPrefix () {
23+ ServletContext servletContext = context .getServletContext ();
24+ SessionCookieConfig cookieConfig = servletContext .getSessionCookieConfig ();
25+ assertThat (cookieConfig .getName ()).isEqualTo ("__Host-JSESSIONID" );
26+ }
27+
28+ }
You can’t perform that action at this time.
0 commit comments