Search in sources :

Example 11 with WithAnonymousUser

use of org.springframework.security.test.context.support.WithAnonymousUser in project nixmash-blog by mintster.

the class UserPasswordControllerTests method anonymousUserCannotAccessResetPasswordPage.

@Test
@WithAnonymousUser
public void anonymousUserCannotAccessResetPasswordPage() throws Exception {
    RequestBuilder request = get("/users/resetpassword").with(csrf());
    mvc.perform(request).andExpect(status().is3xxRedirection()).andExpect(loginPage());
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test)

Example 12 with WithAnonymousUser

use of org.springframework.security.test.context.support.WithAnonymousUser in project nixmash-blog by mintster.

the class UserPasswordControllerTests method resetPasswordPageWithTokenReturnsChangePasswordView.

@Test
@WithAnonymousUser
public void resetPasswordPageWithTokenReturnsChangePasswordView() throws Exception {
    RequestBuilder request = get("/users/resetpassword/" + UUID.randomUUID().toString()).with(csrf());
    mvc.perform(request).andExpect(status().isOk()).andExpect(model().attributeExists("userPasswordDTO")).andExpect(view().name(USER_CHANGEPASSWORD_VIEW));
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 WithAnonymousUser (org.springframework.security.test.context.support.WithAnonymousUser)12 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 MvcResult (org.springframework.test.web.servlet.MvcResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 UserToken (com.nixmash.blog.jpa.model.UserToken)1 JwtAuthenticationRequest (fr.codechill.spring.security.JwtAuthenticationRequest)1 AccessToken (io.pivotal.cla.data.AccessToken)1 User (io.pivotal.cla.data.User)1 WithSigningUser (io.pivotal.cla.security.WithSigningUser)1 PullRequestStatus (io.pivotal.cla.service.github.PullRequestStatus)1 SignClaPage (io.pivotal.cla.webdriver.pages.SignClaPage)1 ViewCclaPage (io.pivotal.cla.webdriver.pages.ViewCclaPage)1 ViewIclaPage (io.pivotal.cla.webdriver.pages.ViewIclaPage)1 ResultActions (org.springframework.test.web.servlet.ResultActions)1