Search in sources :

Example 6 with WithAnonymousUser

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

the class GlobalControllerTests method googleAnalyticsAnonymousUserTest.

@Test
@WithAnonymousUser
public void googleAnalyticsAnonymousUserTest() throws Exception {
    RequestBuilder request = get("/").with(csrf());
    MvcResult result = mockMvc.perform(request).andReturn();
    assertTrue(result.getResponse().getContentAsString().contains(TRACKING_ID));
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) MvcResult(org.springframework.test.web.servlet.MvcResult) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test)

Example 7 with WithAnonymousUser

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

the class UserPasswordControllerTests method resetPasswordFromEmail.

@Test
@WithAnonymousUser
public void resetPasswordFromEmail() throws Exception {
    UserToken userToken = userService.createUserToken(erwin);
    RequestBuilder request = post("/users/resetpassword").param("userId", "-400").param("verificationToken", userToken.getToken()).param("password", "password").param("repeatedPassword", "password").with(csrf());
    mvc.perform(request).andExpect(model().attribute("feedbackMessage", containsString("login")));
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) UserToken(com.nixmash.blog.jpa.model.UserToken) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test)

Example 8 with WithAnonymousUser

use of org.springframework.security.test.context.support.WithAnonymousUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class HomeControllerTest method groupingsViaAnonymous.

@Test
@WithAnonymousUser
public void groupingsViaAnonymous() throws Exception {
    // Anonymous users not allowed into admin area.
    ResultActions result = mockMvc.perform(get("/groupings")).andExpect(status().is3xxRedirection()).andExpect(redirectedUrlPattern(casLoginUrl + "**"));
    assertNotNull(result);
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with WithAnonymousUser

use of org.springframework.security.test.context.support.WithAnonymousUser in project uhgroupings by uhawaii-system-its-ti-iam.

the class HomeControllerTest method adminViaAnonymous.

@Test
@WithAnonymousUser
public void adminViaAnonymous() throws Exception {
    // Anonymous users not allowed into admin area.
    MvcResult mvcResult = mockMvc.perform(get("/admin")).andExpect(status().is3xxRedirection()).andExpect(redirectedUrlPattern(casLoginUrl + "**")).andReturn();
    assertNotNull(mvcResult);
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) WithAnonymousUser(org.springframework.security.test.context.support.WithAnonymousUser) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with WithAnonymousUser

use of org.springframework.security.test.context.support.WithAnonymousUser in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method view.

@Test
@WithAnonymousUser
public void view() {
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    ViewCclaPage signPage = ViewCclaPage.go(getDriver(), cla.getName());
    assertThat(signPage.getCorporate()).isEqualTo(cla.getCorporateContent().getHtml());
}
Also used : ViewCclaPage(io.pivotal.cla.webdriver.pages.ViewCclaPage) 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