|
44 | 44 | import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServicesTests;
|
45 | 45 | import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
|
46 | 46 | import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
| 47 | +import org.springframework.security.web.context.RequestAttributeSecurityContextRepository; |
47 | 48 | import org.springframework.security.web.context.SecurityContextRepository;
|
48 | 49 | import org.springframework.security.web.firewall.DefaultHttpFirewall;
|
49 | 50 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
@@ -188,6 +189,8 @@ public void testNormalOperationWithDefaultFilterProcessesUrl() throws Exception
|
188 | 189 | assertThat(response.getRedirectedUrl()).isEqualTo("/mycontext/logged_in.jsp");
|
189 | 190 | assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull();
|
190 | 191 | assertThat(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()).isEqualTo("test");
|
| 192 | + assertThat(request.getAttribute(RequestAttributeSecurityContextRepository.DEFAULT_REQUEST_ATTR_NAME)) |
| 193 | + .isNotNull(); |
191 | 194 | // Should still have the same session
|
192 | 195 | assertThat(request.getSession()).isEqualTo(sessionPreAuth);
|
193 | 196 | }
|
@@ -215,6 +218,8 @@ public void testNormalOperationWithDefaultFilterProcessesUrlAndAuthenticationMan
|
215 | 218 | assertThat(response.getRedirectedUrl()).isEqualTo("/mycontext/logged_in.jsp");
|
216 | 219 | assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull();
|
217 | 220 | assertThat(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()).isEqualTo("test");
|
| 221 | + assertThat(request.getAttribute(RequestAttributeSecurityContextRepository.DEFAULT_REQUEST_ATTR_NAME)) |
| 222 | + .isNotNull(); |
218 | 223 | // Should still have the same session
|
219 | 224 | assertThat(request.getSession()).isEqualTo(sessionPreAuth);
|
220 | 225 | }
|
@@ -244,6 +249,8 @@ public void testNormalOperationWithRequestMatcherAndAuthenticationManager() thro
|
244 | 249 | assertThat(response.getRedirectedUrl()).isEqualTo("/mycontext/logged_in.jsp");
|
245 | 250 | assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull();
|
246 | 251 | assertThat(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()).isEqualTo("test");
|
| 252 | + assertThat(request.getAttribute(RequestAttributeSecurityContextRepository.DEFAULT_REQUEST_ATTR_NAME)) |
| 253 | + .isNotNull(); |
247 | 254 | // Should still have the same session
|
248 | 255 | assertThat(request.getSession()).isEqualTo(sessionPreAuth);
|
249 | 256 | }
|
@@ -323,6 +330,8 @@ public void testSuccessfulAuthenticationInvokesSuccessHandlerAndSetsContext() th
|
323 | 330 | verify(successHandler).onAuthenticationSuccess(any(HttpServletRequest.class), any(HttpServletResponse.class),
|
324 | 331 | any(Authentication.class));
|
325 | 332 | assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull();
|
| 333 | + assertThat(request.getAttribute(RequestAttributeSecurityContextRepository.DEFAULT_REQUEST_ATTR_NAME)) |
| 334 | + .isNotNull(); |
326 | 335 | }
|
327 | 336 |
|
328 | 337 | @Test
|
|
0 commit comments