|
@@ -16,6 +16,7 @@
|
|
package org.springframework.security.test.web.servlet.showcase.login;
|
|
package org.springframework.security.test.web.servlet.showcase.login;
|
|
|
|
|
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.*;
|
|
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.*;
|
|
|
|
+import static org.springframework.security.test.web.servlet.response.RedirectMatcher.redirectUrl;
|
|
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.*;
|
|
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.*;
|
|
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
|
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
@@ -67,7 +68,7 @@ public class AuthenticationTests {
|
|
@Test
|
|
@Test
|
|
public void authenticationSuccess() throws Exception {
|
|
public void authenticationSuccess() throws Exception {
|
|
mvc.perform(formLogin()).andExpect(status().isFound())
|
|
mvc.perform(formLogin()).andExpect(status().isFound())
|
|
- .andExpect(redirectedUrl("/"))
|
|
|
|
|
|
+ .andExpect(redirectUrl("/"))
|
|
.andExpect(authenticated().withUsername("user"));
|
|
.andExpect(authenticated().withUsername("user"));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -75,7 +76,8 @@ public class AuthenticationTests {
|
|
public void authenticationFailed() throws Exception {
|
|
public void authenticationFailed() throws Exception {
|
|
mvc.perform(formLogin().user("user").password("invalid"))
|
|
mvc.perform(formLogin().user("user").password("invalid"))
|
|
.andExpect(status().isFound())
|
|
.andExpect(status().isFound())
|
|
- .andExpect(redirectedUrl("/login?error")).andExpect(unauthenticated());
|
|
|
|
|
|
+ .andExpect(redirectUrl("/login?error"))
|
|
|
|
+ .andExpect(unauthenticated());
|
|
}
|
|
}
|
|
|
|
|
|
@EnableWebSecurity
|
|
@EnableWebSecurity
|