Search in sources :

Example 91 with DDLWork

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());
    }
}
Also used : PrincipalDesc(org.apache.hadoop.hive.ql.plan.PrincipalDesc) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) GrantRevokeRoleDDL(org.apache.hadoop.hive.ql.plan.GrantRevokeRoleDDL) Test(org.junit.Test)

Example 92 with DDLWork

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());
}
Also used : DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) RoleDDLDesc(org.apache.hadoop.hive.ql.plan.RoleDDLDesc) Test(org.junit.Test)

Example 93 with DDLWork

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());
}
Also used : DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) RoleDDLDesc(org.apache.hadoop.hive.ql.plan.RoleDDLDesc) Test(org.junit.Test)

Example 94 with DDLWork

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());
}
Also used : DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) RoleDDLDesc(org.apache.hadoop.hive.ql.plan.RoleDDLDesc) Test(org.junit.Test)

Example 95 with DDLWork

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());
    }
}
Also used : PrincipalDesc(org.apache.hadoop.hive.ql.plan.PrincipalDesc) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) GrantRevokeRoleDDL(org.apache.hadoop.hive.ql.plan.GrantRevokeRoleDDL) Test(org.junit.Test)

Aggregations

DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)104 ReadEntity (org.apache.hadoop.hive.ql.hooks.ReadEntity)23 Table (org.apache.hadoop.hive.ql.metadata.Table)20 AlterTableDesc (org.apache.hadoop.hive.ql.plan.AlterTableDesc)20 Test (org.junit.Test)20 PrincipalDesc (org.apache.hadoop.hive.ql.plan.PrincipalDesc)17 LinkedHashMap (java.util.LinkedHashMap)15 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)13 WriteEntity (org.apache.hadoop.hive.ql.hooks.WriteEntity)12 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)12 PrivilegeDesc (org.apache.hadoop.hive.ql.plan.PrivilegeDesc)9 RoleDDLDesc (org.apache.hadoop.hive.ql.plan.RoleDDLDesc)9 Map (java.util.Map)8 Path (org.apache.hadoop.fs.Path)8 FileNotFoundException (java.io.FileNotFoundException)7 LinkedList (java.util.LinkedList)7 List (java.util.List)7 GrantRevokeRoleDDL (org.apache.hadoop.hive.ql.plan.GrantRevokeRoleDDL)7 ShowGrantDesc (org.apache.hadoop.hive.ql.plan.ShowGrantDesc)7