Search in sources :

Example 26 with ProjectInstance

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

the class RangerKylinAuthorizerTest method writeProjectLearnWithoutPermission.

/**
 * yuwen write learn_project failed
 */
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void writeProjectLearnWithoutPermission() {
    ProjectInstance project = name2Projects.get(LEARN_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)

Example 27 with ProjectInstance

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

the class RangerKylinAuthorizerTest method operationProjectAnyWithoutCredentials.

// No.1 hasProjectReadPermission test end
// No.2 hasProjectOperationPermission test start
/**
 * no credentials operation any project failed
 */
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void operationProjectAnyWithoutCredentials() {
    ProjectInstance project = getRandomProjectInstance();
    aclEvaluate.hasProjectOperationPermission(project);
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) Test(org.junit.Test)

Example 28 with ProjectInstance

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

the class RangerKylinAuthorizerTest method adminProjectKylinWithoutPermission.

/**
 * zhangqiang admin kylin_project failed
 */
@Test
@WithMockUser(username = ZHANGQIANG, roles = { ROLE_USER })
public void adminProjectKylinWithoutPermission() {
    ProjectInstance project = name2Projects.get(KYLIN_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 29 with ProjectInstance

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

the class RangerKylinAuthorizerTest method writeProjectTestWithManagementPermission.

/**
 * yuwen write test_project success
 */
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void writeProjectTestWithManagementPermission() {
    ProjectInstance project = name2Projects.get(TEST_PROJECT);
    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 30 with ProjectInstance

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

the class RangerKylinAuthorizerTest method readProjectAnyWithoutCredentials.

// No.1 hasProjectReadPermission test start
/**
 * no credentials read any project failed
 */
@Test(expected = AuthenticationCredentialsNotFoundException.class)
public void readProjectAnyWithoutCredentials() {
    ProjectInstance project = getRandomProjectInstance();
    aclEvaluate.hasProjectReadPermission(project);
}
Also used : ProjectInstance(org.apache.kylin.metadata.project.ProjectInstance) 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