Search in sources :

Example 1 with EventListenerConfig

use of io.trino.eventlistener.EventListenerConfig in project trino by trinodb.

the class TestCreateTableTask method testCreateLikeDenyPermission.

@Test
public void testCreateLikeDenyPermission() {
    CreateTable statement = getCreatleLikeStatement(false);
    TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig()));
    accessControl.deny(privilege("parent_table", SELECT_COLUMN));
    CreateTableTask createTableTask = new CreateTableTask(plannerContext, accessControl, columnPropertyManager, tablePropertyManager);
    assertThatThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
    }))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot reference columns of table");
}
Also used : AccessDeniedException(io.trino.spi.security.AccessDeniedException) CreateTable(io.trino.sql.tree.CreateTable) EventListenerManager(io.trino.eventlistener.EventListenerManager) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) Test(org.testng.annotations.Test)

Example 2 with EventListenerConfig

use of io.trino.eventlistener.EventListenerConfig in project trino by trinodb.

the class TestCreateTableTask method testCreateLikeWithPropertiesDenyPermission.

@Test
public void testCreateLikeWithPropertiesDenyPermission() {
    CreateTable statement = getCreatleLikeStatement(true);
    TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, new EventListenerManager(new EventListenerConfig()));
    accessControl.deny(privilege("parent_table", SHOW_CREATE_TABLE));
    CreateTableTask createTableTask = new CreateTableTask(plannerContext, accessControl, columnPropertyManager, tablePropertyManager);
    assertThatThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
    }))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot reference properties of table");
}
Also used : AccessDeniedException(io.trino.spi.security.AccessDeniedException) CreateTable(io.trino.sql.tree.CreateTable) EventListenerManager(io.trino.eventlistener.EventListenerManager) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) Test(org.testng.annotations.Test)

Aggregations

EventListenerConfig (io.trino.eventlistener.EventListenerConfig)2 EventListenerManager (io.trino.eventlistener.EventListenerManager)2 AccessDeniedException (io.trino.spi.security.AccessDeniedException)2 CreateTable (io.trino.sql.tree.CreateTable)2 TestingAccessControlManager (io.trino.testing.TestingAccessControlManager)2 Test (org.testng.annotations.Test)2