Search in sources :

Example 1 with WithMockUser

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());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 2 with WithMockUser

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);
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 3 with WithMockUser

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);
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 4 with WithMockUser

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);
    }
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 5 with WithMockUser

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);
    }
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

WithMockUser (org.springframework.security.test.context.support.WithMockUser)667 Test (org.junit.Test)476 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)115 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)108 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)102 Test (org.junit.jupiter.api.Test)99 Transactional (org.springframework.transaction.annotation.Transactional)94 Test (org.testng.annotations.Test)86 Project (ca.corefacility.bioinformatics.irida.model.project.Project)80 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)72 User (io.github.jhipster.sample.domain.User)60 User (ca.corefacility.bioinformatics.irida.model.user.User)54 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)51 EntityType (org.molgenis.data.meta.model.EntityType)40 Path (java.nio.file.Path)36 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)36 URI (java.net.URI)33 ProjectInstance (org.apache.kylin.metadata.project.ProjectInstance)28 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)24 PasswordChangeDTO (io.github.jhipster.sample.service.dto.PasswordChangeDTO)24