Skip to content

Commit 1ab05da

Browse files
committed
added test
1 parent 0591403 commit 1ab05da

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

config/src/test/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurerTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.http.HttpHeaders;
2727
import org.springframework.http.MediaType;
2828
import org.springframework.mock.web.MockHttpSession;
29+
import org.springframework.mock.web.MockMultipartFile;
2930
import org.springframework.security.config.annotation.ObjectPostProcessor;
3031
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
3132
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@@ -45,6 +46,7 @@
4546
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
4647
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
4748
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
49+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
4850
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
4951

5052
/**
@@ -262,6 +264,21 @@ public void getWhenRequestCacheIsDisabledThenExceptionTranslationFilterDoesNotSt
262264
.andExpect(redirectedUrl("/"));
263265
}
264266

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+
265282
@EnableWebSecurity
266283
static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter {
267284
@Override

0 commit comments

Comments
 (0)