|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2013 the original author or authors. |
| 2 | + * Copyright 2002-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -161,4 +161,34 @@ public void sessionIsCreatedIfAlwaysCreateTrue() {
|
161 | 161 | assertThat(request.getSession(false)).isNotNull();
|
162 | 162 | }
|
163 | 163 |
|
| 164 | + @Test |
| 165 | + public void onAuthenticationWhenMigrateSessionAttributesTrueThenMaxInactiveIntervalIsMigrated() { |
| 166 | + SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); |
| 167 | + HttpServletRequest request = new MockHttpServletRequest(); |
| 168 | + HttpSession session = request.getSession(); |
| 169 | + session.setMaxInactiveInterval(1); |
| 170 | + |
| 171 | + Authentication mockAuthentication = mock(Authentication.class); |
| 172 | + |
| 173 | + strategy.onAuthentication(mockAuthentication, request, |
| 174 | + new MockHttpServletResponse()); |
| 175 | + |
| 176 | + assertThat(request.getSession().getMaxInactiveInterval()).isEqualTo(1); |
| 177 | + } |
| 178 | + |
| 179 | + @Test |
| 180 | + public void onAuthenticationWhenMigrateSessionAttributesFalseThenMaxInactiveIntervalIsNotMigrated() { |
| 181 | + SessionFixationProtectionStrategy strategy = new SessionFixationProtectionStrategy(); |
| 182 | + strategy.setMigrateSessionAttributes(false); |
| 183 | + HttpServletRequest request = new MockHttpServletRequest(); |
| 184 | + HttpSession session = request.getSession(); |
| 185 | + session.setMaxInactiveInterval(1); |
| 186 | + |
| 187 | + Authentication mockAuthentication = mock(Authentication.class); |
| 188 | + |
| 189 | + strategy.onAuthentication(mockAuthentication, request, |
| 190 | + new MockHttpServletResponse()); |
| 191 | + |
| 192 | + assertThat(request.getSession().getMaxInactiveInterval()).isNotEqualTo(1); |
| 193 | + } |
164 | 194 | }
|
0 commit comments