* user can't create table in DB where he doesn't have ALL permissions
* @throws Exception
*/
@Test
public void testTablePrivileges() throws Exception {
HiveMetaStoreClient client = context.getMetaStoreClient(ADMIN1);
createMetastoreTable(client, dbName, tabName1,
Lists.newArrayList(new FieldSchema("col1", "int", "")));
client.close();
client = context.getMetaStoreClient(USER1_1);
createMetastoreTable(client, dbName, tabName2,
Lists.newArrayList(new FieldSchema("col1", "int", "")));
assertEquals(1, client.getTables(dbName, tabName2).size());
client.dropTable(dbName, tabName1);
createMetastoreTable(client, dbName, tabName1,
Lists.newArrayList(new FieldSchema("col1", "int", "")));
client.close();
// group2 users can't create the table, but can drop it
client = context.getMetaStoreClient(USER2_1);
try {
createMetastoreTable(client, dbName, "barTab",
Lists.newArrayList(new FieldSchema("col1", "int", "")));
fail("Create table should have failed for non-privilege user");
} catch (MetaException e) {
Context.verifyMetastoreAuthException(e);
}
client.dropTable(dbName, tabName2);
client.close();
// group3 users can't create or drop it
client = context.getMetaStoreClient(USER3_1);
try {
createMetastoreTable(client, dbName, "barTab",
Lists.newArrayList(new FieldSchema("col1", "int", "")));
fail("Create table should have failed for non-privilege user");
} catch (MetaException e) {
Context.verifyMetastoreAuthException(e);
}
try {
client.dropTable(dbName, tabName1);
fail("drop table should have failed for non-privilege user");
} catch (MetaException e) {
Context.verifyMetastoreAuthException(e);
}
client.close();
}