Add product tests for SHOW GRANTS
@@ -100,7 +100,28 @@ public class TestGrantRevoke
}
@Test(groups = {HIVE_CONNECTOR, AUTHORIZATION, PROFILE_SPECIFIC_TESTS})
- public void testGrantRevokeAll()
+ public void testShowGrants()
+ {
+ assertThat(aliceExecutor.executeQuery(format("SHOW GRANTS ON %s", tableName)))
+ .containsOnly(ImmutableList.of(
+ row("alice", "hive", "default", tableName, "SELECT", Boolean.TRUE),
+ row("alice", "hive", "default", tableName, "INSERT", Boolean.TRUE),
+ row("alice", "hive", "default", tableName, "UPDATE", Boolean.TRUE),
+ row("alice", "hive", "default", tableName, "DELETE", Boolean.TRUE)
+ ));
+
+ aliceExecutor.executeQuery(format("GRANT SELECT ON %s TO bob WITH GRANT OPTION", tableName));
+ aliceExecutor.executeQuery(format("GRANT INSERT ON %s TO bob", tableName));
+
+ assertThat(bobExecutor.executeQuery(format("SHOW GRANTS ON %s", tableName)))
+ .containsOnly(ImmutableList.of(
+ row("bob", "hive", "default", tableName, "SELECT", Boolean.TRUE),
+ row("bob", "hive", "default", tableName, "INSERT", Boolean.FALSE)
+ ));
+ }
+
+ @Test(groups = {HIVE_CONNECTOR, AUTHORIZATION, PROFILE_SPECIFIC_TESTS})
+ public void testAll()
{
aliceExecutor.executeQuery(format("GRANT ALL PRIVILEGES ON %s TO bob", tableName));
assertThat(bobExecutor.executeQuery(format("INSERT INTO %s VALUES (4, 13)", tableName))).hasRowsCount(1);
@@ -110,6 +131,8 @@ public class TestGrantRevoke
aliceExecutor.executeQuery(format("REVOKE ALL PRIVILEGES ON %s FROM bob", tableName));
assertAccessDeniedOnAllOperationsOnTable(bobExecutor, tableName);
+
+ assertThat(bobExecutor.executeQuery(format("SHOW GRANTS ON %s", tableName))).hasNoRows();
}
@Test(groups = {HIVE_CONNECTOR, AUTHORIZATION, PROFILE_SPECIFIC_TESTS})
