use of org.apache.hadoop.hive.ql.plan.DDLWork in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testRevokeRoleGroup.
/**
* REVOKE ROLE ... FROM GROUP ...
*/
@Test
public void testRevokeRoleGroup() throws Exception {
DDLWork work = analyze("REVOKE ROLE " + ROLE + " FROM GROUP " + GROUP);
GrantRevokeRoleDDL grantDesc = work.getGrantRevokeRoleDDL();
Assert.assertNotNull("Grant should not be null", grantDesc);
Assert.assertFalse("Did not expect grant ", grantDesc.getGrant());
Assert.assertFalse("With admin option is not specified", grantDesc.isGrantOption());
Assert.assertEquals(currentUser, grantDesc.getGrantor());
Assert.assertEquals(PrincipalType.USER, grantDesc.getGrantorType());
for (String role : ListSizeMatcher.inList(grantDesc.getRoles()).ofSize(1)) {
Assert.assertEquals(ROLE, role);
}
for (PrincipalDesc principal : ListSizeMatcher.inList(grantDesc.getPrincipalDesc()).ofSize(1)) {
Assert.assertEquals(PrincipalType.GROUP, principal.getType());
Assert.assertEquals(GROUP, principal.getName());
}
}
use of org.apache.hadoop.hive.ql.plan.DDLWork in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testDropRole.
/**
* DROP ROLE ...
*/
@Test
public void testDropRole() throws Exception {
DDLWork work = analyze("DROp ROLE " + ROLE);
RoleDDLDesc roleDesc = work.getRoleDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(RoleOperation.DROP_ROLE, roleDesc.getOperation());
Assert.assertFalse("Did not expect a group", roleDesc.getGroup());
Assert.assertEquals(ROLE, roleDesc.getName());
}
use of org.apache.hadoop.hive.ql.plan.DDLWork in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowRoleGrantGroup.
/**
* SHOW ROLE GRANT GROUP ...
*/
@Test
public void testShowRoleGrantGroup() throws Exception {
DDLWork work = analyze("SHOW ROLE GRANT GROUP " + GROUP);
RoleDDLDesc roleDesc = work.getRoleDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(RoleOperation.SHOW_ROLE_GRANT, roleDesc.getOperation());
Assert.assertEquals(PrincipalType.GROUP, roleDesc.getPrincipalType());
Assert.assertEquals(GROUP, roleDesc.getName());
}
use of org.apache.hadoop.hive.ql.plan.DDLWork in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testShowRoleGrantRole.
/**
* SHOW ROLE GRANT ROLE ...
*/
@Test
public void testShowRoleGrantRole() throws Exception {
DDLWork work = analyze("SHOW ROLE GRANT ROLE " + ROLE);
RoleDDLDesc roleDesc = work.getRoleDDLDesc();
Assert.assertNotNull("Role should not be null", roleDesc);
Assert.assertEquals(RoleOperation.SHOW_ROLE_GRANT, roleDesc.getOperation());
Assert.assertEquals(PrincipalType.ROLE, roleDesc.getPrincipalType());
Assert.assertEquals(ROLE, roleDesc.getName());
}
use of org.apache.hadoop.hive.ql.plan.DDLWork in project hive by apache.
the class TestHiveAuthorizationTaskFactory method testGrantRoleRole.
/**
* GRANT ROLE ... TO ROLE ...
*/
@Test
public void testGrantRoleRole() throws Exception {
DDLWork work = analyze("GRANT ROLE " + ROLE + " TO ROLE " + ROLE);
GrantRevokeRoleDDL grantDesc = work.getGrantRevokeRoleDDL();
Assert.assertNotNull("Grant should not be null", grantDesc);
Assert.assertTrue("Expected grant ", grantDesc.getGrant());
Assert.assertFalse("With admin option is not specified", grantDesc.isGrantOption());
Assert.assertEquals(currentUser, grantDesc.getGrantor());
Assert.assertEquals(PrincipalType.USER, grantDesc.getGrantorType());
for (String role : ListSizeMatcher.inList(grantDesc.getRoles()).ofSize(1)) {
Assert.assertEquals(ROLE, role);
}
for (PrincipalDesc principal : ListSizeMatcher.inList(grantDesc.getPrincipalDesc()).ofSize(1)) {
Assert.assertEquals(PrincipalType.ROLE, principal.getType());
Assert.assertEquals(ROLE, principal.getName());
}
}
Aggregations