Search in sources :

Example 31 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.

the class RangerKylinAuthorizerTest method adminProjectAllAsRoleAdmin.

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

use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.

the class RangerKylinAuthorizerTest method adminProjectAnyWithoutCredentials.

// No.3 hasProjectWritePermission test end
// No.4 hasProjectAdminPermission test start
/**
 * no credentials admin any project failed
 */
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void adminProjectAnyWithoutCredentials() {
    ProjectInstance project = getRandomProjectInstance();
    aclEvaluate.hasProjectAdminPermission(project);
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) Test(org.junit.Test)

Example 33 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.

the class RangerKylinAuthorizerTest method operationProjectTestWithManagementPermission.

/**
 * yuwen operation test_project success
 */
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void operationProjectTestWithManagementPermission() {
    ProjectInstance project = name2Projects.get(TEST_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 34 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.

the class RangerKylinAuthorizerTest method operationProjectTestWithAdminPermission.

/**
 * zhangqiang operation test_project success
 */
@Test
@WithMockUser(username = ZHANGQIANG, roles = { ROLE_USER })
public void operationProjectTestWithAdminPermission() {
    ProjectInstance project = name2Projects.get(TEST_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 35 with ProjectInstance

use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.

the class RangerKylinAuthorizerTest method writeProjectKylinWithoutPermission.

/**
 * zhangqiang write kylin_project failed
 */
@Test
@WithMockUser(username = ZHANGQIANG, roles = { ROLE_USER })
public void writeProjectKylinWithoutPermission() {
    ProjectInstance project = name2Projects.get(KYLIN_PROJECT);
    boolean result = aclEvaluate.hasProjectWritePermission(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)

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