Search in sources :

Example 6 with RequestBuilder

use of org.springframework.test.web.servlet.RequestBuilder in project gs-spring-security-3.2 by rwinch.

the class SecurityTests method robCannotAccessLukesMessage.

@Test
public void robCannotAccessLukesMessage() throws Exception {
    RequestBuilder request = get("/110").with(user(rob).roles("USER"));
    mvc.perform(request).andExpect(status().isForbidden());
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) Test(org.junit.Test)

Example 7 with RequestBuilder

use of org.springframework.test.web.servlet.RequestBuilder in project gs-spring-security-3.2 by rwinch.

the class SecurityTests method robCanAccessOwnMessage.

@Test
public void robCanAccessOwnMessage() throws Exception {
    RequestBuilder request = get("/100").with(user(rob).roles("USER"));
    mvc.perform(request).andExpect(status().isOk());
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) Test(org.junit.Test)

Example 8 with RequestBuilder

use of org.springframework.test.web.servlet.RequestBuilder in project gs-spring-security-3.2 by rwinch.

the class SecurityTests method composeRequiresCsrf.

@Test
public void composeRequiresCsrf() throws Exception {
    RequestBuilder request = post("/").with(user(rob).roles("USER"));
    mvc.perform(request).andExpect(invalidCsrf());
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) Test(org.junit.Test)

Example 9 with RequestBuilder

use of org.springframework.test.web.servlet.RequestBuilder in project gs-spring-security-3.2 by rwinch.

the class SecurityTests method invalidUsernamePassword.

@Test
public void invalidUsernamePassword() throws Exception {
    RequestBuilder request = post("/login").param("username", "rob@example.com").param("password", "invalid").with(csrf());
    mvc.perform(request).andExpect(invalidLogin());
}
Also used : RequestBuilder(org.springframework.test.web.servlet.RequestBuilder) Test(org.junit.Test)

Aggregations

RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)9 Test (org.junit.Test)7 List (java.util.List)1 ServletContext (javax.servlet.ServletContext)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 SmartRequestBuilder (org.springframework.test.web.servlet.SmartRequestBuilder)1 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)1 Message (sample.data.Message)1