use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestFileBasedSystemAccessControl method testTableOperations.
@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);
}));
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestFileBasedSystemAccessControl method testSchemaOperations.
@Test
public void testSchemaOperations() {
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = newAccessControlManager(transactionManager, "catalog.json");
transaction(transactionManager, accessControlManager).execute(transactionId -> {
Set<String> aliceSchemas = ImmutableSet.of("schema");
assertEquals(accessControlManager.filterSchemas(transactionId, alice, "alice-catalog", aliceSchemas), aliceSchemas);
assertEquals(accessControlManager.filterSchemas(transactionId, bob, "alice-catalog", aliceSchemas), ImmutableSet.of());
accessControlManager.checkCanCreateSchema(transactionId, alice, aliceSchema);
accessControlManager.checkCanDropSchema(transactionId, alice, aliceSchema);
accessControlManager.checkCanRenameSchema(transactionId, alice, aliceSchema, "new-schema");
accessControlManager.checkCanShowSchemas(transactionId, alice, "alice-catalog");
});
assertThrows(AccessDeniedException.class, () -> transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanCreateSchema(transactionId, bob, aliceSchema);
}));
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestFileBasedSystemAccessControl method testCanSetUserOperations.
@Test
public void testCanSetUserOperations() {
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = newAccessControlManager(transactionManager, "catalog_principal.json");
try {
accessControlManager.checkCanSetUser(Optional.empty(), alice.getUser());
throw new AssertionError("expected AccessDeniedExeption");
} catch (AccessDeniedException expected) {
}
accessControlManager.checkCanSetUser(kerberosValidAlice.getPrincipal(), kerberosValidAlice.getUser());
accessControlManager.checkCanSetUser(kerberosValidNonAsciiUser.getPrincipal(), kerberosValidNonAsciiUser.getUser());
try {
accessControlManager.checkCanSetUser(kerberosInvalidAlice.getPrincipal(), kerberosInvalidAlice.getUser());
throw new AssertionError("expected AccessDeniedExeption");
} catch (AccessDeniedException expected) {
}
accessControlManager.checkCanSetUser(kerberosValidShare.getPrincipal(), kerberosValidShare.getUser());
try {
accessControlManager.checkCanSetUser(kerberosInValidShare.getPrincipal(), kerberosInValidShare.getUser());
throw new AssertionError("expected AccessDeniedExeption");
} catch (AccessDeniedException expected) {
}
accessControlManager.checkCanSetUser(validSpecialRegexWildDot.getPrincipal(), validSpecialRegexWildDot.getUser());
accessControlManager.checkCanSetUser(validSpecialRegexEndQuote.getPrincipal(), validSpecialRegexEndQuote.getUser());
try {
accessControlManager.checkCanSetUser(invalidSpecialRegex.getPrincipal(), invalidSpecialRegex.getUser());
throw new AssertionError("expected AccessDeniedExeption");
} catch (AccessDeniedException expected) {
}
TransactionManager transactionManagerNoPatterns = createTestTransactionManager();
AccessControlManager accessControlManagerNoPatterns = newAccessControlManager(transactionManager, "catalog.json");
accessControlManagerNoPatterns.checkCanSetUser(kerberosValidAlice.getPrincipal(), kerberosValidAlice.getUser());
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestFileBasedSystemAccessControl method testNodeOperations.
@Test
public void testNodeOperations() {
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = newAccessControlManager(transactionManager, "server.json");
accessControlManager.checkCanAccessNodeInfo(alice);
try {
accessControlManager.checkCanAccessNodeInfo(bob);
} catch (AccessDeniedException expected) {
}
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestCreateTableTask method setUp.
@BeforeMethod
public void setUp() {
CatalogManager catalogManager = new CatalogManager();
TransactionManager transactionManager = createTestTransactionManager(catalogManager);
TablePropertyManager tablePropertyManager = new TablePropertyManager();
ColumnPropertyManager columnPropertyManager = new ColumnPropertyManager();
Catalog testCatalog = createBogusTestingCatalog(CATALOG_NAME);
catalogManager.registerCatalog(testCatalog);
tablePropertyManager.addProperties(testCatalog.getConnectorCatalogName(), ImmutableList.of(stringProperty("baz", "test property", null, false)));
columnPropertyManager.addProperties(testCatalog.getConnectorCatalogName(), ImmutableList.of());
testSession = testSessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).build();
metadata = new MockMetadata(tablePropertyManager, columnPropertyManager, testCatalog.getConnectorCatalogName(), emptySet());
}
Aggregations