Search in sources :

Example 66 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)

Example 67 with WithMockUser

use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.

the class RangerKylinAuthorizerTest method operationProjectAllAsRoleAdmin.

/**
 * admin operation all projects sueecss
 */
@Test
@WithMockUser(username = ADMIN, roles = { ROLE_ADMIN })
public void operationProjectAllAsRoleAdmin() {
    for (ProjectInstance project : uuid2Projects.values()) {
        boolean result = aclEvaluate.hasProjectOperationPermission(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 68 with WithMockUser

use of org.springframework.security.test.context.support.WithMockUser in project ranger by apache.

the class RangerKylinAuthorizerTest method operationProjectKylinWithOperationPermission.

/**
 * zhangqiang operation kylin_project success
 */
@Test
@WithMockUser(username = ZHANGQIANG, roles = { ROLE_USER })
public void operationProjectKylinWithOperationPermission() {
    ProjectInstance project = name2Projects.get(KYLIN_PROJECT);
    boolean result = aclEvaluate.hasProjectOperationPermission(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 69 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 70 with WithMockUser

use of org.springframework.security.test.context.support.WithMockUser in project hub-alert by blackducksoftware.

the class UserControllerTestIT method testGetOne.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testGetOne() throws Exception {
    UserConfig userConfig = createDefaultUserConfig().orElseThrow(AssertionFailedError::new);
    String url = UserController.USER_BASE_PATH + String.format("/%s", userConfig.getId());
    MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
    mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) AssertionFailedError(junit.framework.AssertionFailedError) URI(java.net.URI) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

WithMockUser (org.springframework.security.test.context.support.WithMockUser)3415 Test (org.junit.jupiter.api.Test)2107 Test (org.junit.Test)1226 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)865 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)427 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)409 MvcResult (org.springframework.test.web.servlet.MvcResult)304 ResultActions (org.springframework.test.web.servlet.ResultActions)278 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)275 Transactional (org.springframework.transaction.annotation.Transactional)220 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)179 User (io.github.jhipster.sample.domain.User)149 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)136 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)130 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)130 Course (de.tum.in.www1.artemis.domain.Course)124 ArrayList (java.util.ArrayList)124 Exam (de.tum.in.www1.artemis.domain.exam.Exam)114 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)103 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)102