parent
52c6e3cf89
commit
6a3a5f7beb
|
@ -17,6 +17,7 @@ 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.SecurityMockMvcRequestPostProcessors.*;
|
||||
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.setup.SecurityMockMvcConfigurers.springSecurity;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
@ -70,7 +71,8 @@ public class CustomConfigAuthenticationTests {
|
|||
|
||||
@Test
|
||||
public void withUserSuccess() throws Exception {
|
||||
mvc.perform(get("/").with(user("user"))).andExpect(status().isNotFound())
|
||||
mvc.perform(get("/").with(user("user")))
|
||||
.andExpect(status().isNotFound())
|
||||
.andExpect(authenticated().withUsername("user"));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ public class CustomLoginRequestBuilderAuthenticationTests {
|
|||
|
||||
@Test
|
||||
public void authenticationSuccess() throws Exception {
|
||||
mvc.perform(login()).andExpect(status().isMovedTemporarily())
|
||||
mvc.perform(login())
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(redirectUrl("/"))
|
||||
.andExpect(authenticated().withUsername("user"));
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ public class CustomLoginRequestBuilderAuthenticationTests {
|
|||
@Test
|
||||
public void authenticationFailed() throws Exception {
|
||||
mvc.perform(login().user("notfound").password("invalid"))
|
||||
.andExpect(status().isMovedTemporarily())
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(redirectUrl("/authenticate?error"))
|
||||
.andExpect(unauthenticated());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue