use of org.springframework.security.test.context.support.WithMockUser in project spring-security by spring-projects.
the class SecurityConfigTests method composeMessageRequiresCsrfToken.
@Test
@WithMockUser
public void composeMessageRequiresCsrfToken() throws Exception {
MockHttpServletRequestBuilder composeMessage = post("/").param("summary", "New Message").param("text", "This is a new message");
mvc.perform(composeMessage).andExpect(status().isForbidden());
}
use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.
the class RangerKylinAuthorizerTest method readProjectKylinWithQueryPermission.
/**
* yuwen read kylin_project success
*/
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void readProjectKylinWithQueryPermission() {
ProjectInstance project = name2Projects.get(KYLIN_PROJECT);
boolean result = aclEvaluate.hasProjectReadPermission(project);
Assert.assertTrue(result);
}
use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.
the class RangerKylinAuthorizerTest method adminProjectTestWithoutPermission.
/**
* yuwen admin test_project failed
*/
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void adminProjectTestWithoutPermission() {
ProjectInstance project = name2Projects.get(TEST_PROJECT);
boolean result = aclEvaluate.hasProjectAdminPermission(project);
Assert.assertFalse(result);
}
use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.
the class RangerKylinAuthorizerTest method readProjectAllWithAdminPermission.
/**
* kylin read all projects success
*/
@Test
@WithMockUser(username = KYLIN, roles = { ROLE_USER })
public void readProjectAllWithAdminPermission() {
for (ProjectInstance project : uuid2Projects.values()) {
boolean result = aclEvaluate.hasProjectReadPermission(project);
Assert.assertTrue(result);
}
}
use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.
the class RangerKylinAuthorizerTest method writeProjectAllAsRoleAdmin.
/**
* admin write all projects sueecss
*/
@Test
@WithMockUser(username = ADMIN, roles = { ROLE_ADMIN })
public void writeProjectAllAsRoleAdmin() {
for (ProjectInstance project : uuid2Projects.values()) {
boolean result = aclEvaluate.hasProjectWritePermission(project);
Assert.assertTrue(result);
}
}
Aggregations