mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 14:52:24 +00:00
added test
This commit is contained in:
parent
0591403dea
commit
1ab05dae02
@ -26,6 +26,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockHttpSession;
|
import org.springframework.mock.web.MockHttpSession;
|
||||||
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
@ -45,6 +46,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,6 +264,21 @@ public class RequestCacheConfigurerTests {
|
|||||||
.andExpect(redirectedUrl("/"));
|
.andExpect(redirectedUrl("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SEC-7060
|
||||||
|
@Test
|
||||||
|
public void postWhenRequestIsMultipartThenPostAuthenticationRedirectsToRoot() throws Exception {
|
||||||
|
this.spring.register(RequestCacheDefaultsConfig.class, DefaultSecurityConfig.class).autowire();
|
||||||
|
|
||||||
|
MockMultipartFile aFile = new MockMultipartFile("aFile", "A_FILE".getBytes());
|
||||||
|
|
||||||
|
MockHttpSession session = (MockHttpSession)
|
||||||
|
this.mvc.perform(multipart("/upload")
|
||||||
|
.file(aFile))
|
||||||
|
.andReturn().getRequest().getSession();
|
||||||
|
|
||||||
|
this.mvc.perform(formLogin(session)).andExpect(redirectedUrl("/"));
|
||||||
|
}
|
||||||
|
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter {
|
static class RequestCacheDisabledConfig extends WebSecurityConfigurerAdapter {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user