@Test
public void testTableOperations()
{
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = newAccessControlManager(transactionManager, "catalog.json");
transaction(transactionManager, accessControlManager)
.execute(transactionId -> {
Set<SchemaTableName> aliceTables = ImmutableSet.of(new SchemaTableName("schema", "table"));
assertEquals(accessControlManager.filterTables(transactionId, alice, "alice-catalog", aliceTables), aliceTables);
assertEquals(accessControlManager.filterTables(transactionId, bob, "alice-catalog", aliceTables), ImmutableSet.of());
accessControlManager.checkCanCreateTable(transactionId, alice, aliceTable);
accessControlManager.checkCanDropTable(transactionId, alice, aliceTable);
accessControlManager.checkCanSelectFromColumns(transactionId, alice, aliceTable, ImmutableSet.of());
accessControlManager.checkCanInsertIntoTable(transactionId, alice, aliceTable);
accessControlManager.checkCanDeleteFromTable(transactionId, alice, aliceTable);
accessControlManager.checkCanAddColumns(transactionId, alice, aliceTable);
accessControlManager.checkCanRenameColumn(transactionId, alice, aliceTable);
});
assertThrows(AccessDeniedException.class, () -> transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanCreateTable(transactionId, bob, aliceTable);
}));
}