Search in sources :

Example 1 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance 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 2 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance 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 3 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance 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 4 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance 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 5 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance 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)

Aggregations

ProjectInstance (org.apache.kylin.metadata.project.ProjectInstance)35 Test (org.junit.Test)32 WithMockUser (org.springframework.security.test.context.support.WithMockUser)28 KylinConfig (org.apache.kylin.common.KylinConfig)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ProjectManager (org.apache.kylin.metadata.project.ProjectManager)1 RangerAccessResult (org.apache.ranger.plugin.policyengine.RangerAccessResult)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1