|
26 | 26 | import org.springframework.http.HttpHeaders; |
27 | 27 | import org.springframework.http.MediaType; |
28 | 28 | import org.springframework.mock.web.MockHttpSession; |
| 29 | +import org.springframework.mock.web.MockMultipartFile; |
29 | 30 | import org.springframework.security.config.annotation.ObjectPostProcessor; |
30 | 31 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
31 | 32 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
45 | 46 | import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; |
46 | 47 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
47 | 48 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
| 49 | +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; |
48 | 50 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl; |
49 | 51 |
|
50 | 52 | /** |
@@ -262,6 +264,21 @@ public void getWhenRequestCacheIsDisabledThenExceptionTranslationFilterDoesNotSt |
262 | 264 | .andExpect(redirectedUrl("/")); |
263 | 265 | } |
264 | 266 |
|
| 267 | + // SEC-7060 |
| 268 | + @Test |
| 269 | + public void postWhenRequestIsMultipartThenPostAuthenticationRedirectsToRoot() throws Exception { |
| 270 | + this.spring.register(RequestCacheDefaultsConfig.class, DefaultSecurityConfig.class).autowire(); |
| 271 | + |
| 272 | + MockMultipartFile aFile = new MockMultipartFile("aFile", "A_FILE".getBytes()); |
| 273 | + |
| 274 | + MockHttpSession session = (MockHttpSession) |
| 275 | + this.mvc.perform(multipart("/upload") |
| 276 | + .file(aFile)) |
| 277 | + .andReturn().getRequest().getSession(); |
| 278 | + |
| 279 | + this.mvc.perform(formLogin(session)).andExpect(redirectedUrl("/")); |
| 280 | + } |
| 281 | + |
265 | 282 | @EnableWebSecurity |
266 | 283 | static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter { |
267 | 284 | @Override |
|
0 commit comments