use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.
the class RangerKylinAuthorizerTest method readProjectKylinWithOperationPermission.
/**
* zhangqiang read kylin_project success
*/
@Test
@WithMockUser(username = ZHANGQIANG, roles = { ROLE_USER })
public void readProjectKylinWithOperationPermission() {
ProjectInstance project = name2Projects.get(KYLIN_PROJECT);
boolean result = aclEvaluate.hasProjectReadPermission(project);
Assert.assertTrue(result);
}
use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.
the class RangerKylinAuthorizerTest method initKylinProjects.
/**
* Help function: init kylin projects
*/
private static void initKylinProjects() {
for (String projectName : PROJECTNAMES) {
ProjectInstance projectInstance = getProjectInstance(projectName);
name2Projects.put(projectName, projectInstance);
uuid2Projects.put(projectInstance.getUuid(), projectInstance);
}
}
use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.
the class RangerKylinAuthorizerTest method mockKylinProjects.
/**
* Help function: mock kylin projects, to match projectUuid and projectName
*/
private static void mockKylinProjects() {
KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
ProjectManager projectManager = mock(ProjectManager.class);
@SuppressWarnings({ "rawtypes", "unchecked" }) Map<Class, Object> managersCache = (Map<Class, Object>) ReflectionTestUtils.getField(kylinConfig, "managersCache");
managersCache.put(ProjectManager.class, projectManager);
Answer<ProjectInstance> answer = new Answer<ProjectInstance>() {
@Override
public ProjectInstance answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
if (args == null || args.length == 0) {
return null;
}
String uuid = (String) args[0];
return uuid2Projects.get(uuid);
}
};
when(projectManager.getPrjByUuid(anyString())).thenAnswer(answer);
}
use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.
the class RangerKylinAuthorizerTest method operationProjectKylinWithoutPermission.
/**
* yuwen operation kylin_project failed
*/
@Test
@WithMockUser(username = YUWEN, roles = { ROLE_USER })
public void operationProjectKylinWithoutPermission() {
ProjectInstance project = name2Projects.get(KYLIN_PROJECT);
boolean result = aclEvaluate.hasProjectOperationPermission(project);
Assert.assertFalse(result);
}
use of org.apache.kylin.metadata.project.ProjectInstance in project ranger by apache.
the class RangerKylinAuthorizerTest method writeProjectAllWithAdminPermission.
/**
* kylin write all projects success
*/
@Test
@WithMockUser(username = KYLIN, roles = { ROLE_USER })
public void writeProjectAllWithAdminPermission() {
for (ProjectInstance project : uuid2Projects.values()) {
boolean result = aclEvaluate.hasProjectWritePermission(project);
Assert.assertTrue(result);
}
}
Aggregations