I have a very simple REST application created using Spring MVC. (Code is available at GitHub.) It has a simple WebSecurityConfigurer as follows:
@Override
pr
You could use spring security testing classes to test form based login. You need to do the following to test form based login.
Maven dependency:
org.springframework.security
spring-security-test
4.0.0.M1
test
spring-snasphot
https://repo.spring.io/libs-snapshot
Test class:
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin;
RequestBuilder requestBuilder = formLogin().user("username").password("passowrd");
mockMvc.perform(requestBuilder)
.andDo(print())
.andExpect(status().isOk())
.andExpect(cookie().exists("JSESSIONID"));