Search in sources :

Example 26 with CatalogSchemaTableName

use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.

the class TestFileBasedSystemAccessControl method testTableRulesForCheckCanDenyTablePrivilege.

@Test
public void testTableRulesForCheckCanDenyTablePrivilege() {
    SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
    accessControl.checkCanDenyTablePrivilege(ADMIN, Privilege.DELETE, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), null);
    assertAccessDenied(() -> accessControl.checkCanDenyTablePrivilege(BOB, Privilege.DELETE, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), null), DENY_DELETE_PRIVILEGE_ACCESS_DENIED_MESSAGE);
}
Also used : SystemAccessControl(io.trino.spi.security.SystemAccessControl) CatalogSchemaTableName(io.trino.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Example 27 with CatalogSchemaTableName

use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.

the class TestFileBasedSystemAccessControl method testCheckCanSetViewAuthorizationForNonOwner.

@Test
public void testCheckCanSetViewAuthorizationForNonOwner() {
    SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
    assertAccessDenied(() -> accessControl.checkCanSetViewAuthorization(ALICE, new CatalogSchemaTableName("some-catalog", "test", "test"), new TrinoPrincipal(PrincipalType.ROLE, "some_role")), AUTH_VIEW_ACCESS_DENIED_MESSAGE);
    assertAccessDenied(() -> accessControl.checkCanSetViewAuthorization(ALICE, new CatalogSchemaTableName("some-catalog", "test", "test"), new TrinoPrincipal(PrincipalType.USER, "some_user")), AUTH_VIEW_ACCESS_DENIED_MESSAGE);
}
Also used : SystemAccessControl(io.trino.spi.security.SystemAccessControl) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) CatalogSchemaTableName(io.trino.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Example 28 with CatalogSchemaTableName

use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.

the class TestFileBasedSystemAccessControl method testTableRulesForCheckCanRefreshMaterializedView.

@Test
public void testTableRulesForCheckCanRefreshMaterializedView() {
    SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
    accessControl.checkCanRefreshMaterializedView(ADMIN, new CatalogSchemaTableName("some-catalog", "bobschema", "bob-materialized-view"));
    assertAccessDenied(() -> accessControl.checkCanRefreshMaterializedView(UNKNOWN, new CatalogSchemaTableName("some-catalog", "bobschema", "bob-materialized-view")), REFRESH_MATERIALIZED_VIEW_ACCESS_DENIED_MESSAGE);
}
Also used : SystemAccessControl(io.trino.spi.security.SystemAccessControl) CatalogSchemaTableName(io.trino.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Example 29 with CatalogSchemaTableName

use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.

the class TestFileBasedSystemAccessControl method testCheckCanSetViewAuthorizationForAdmin.

@Test
public void testCheckCanSetViewAuthorizationForAdmin() {
    SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
    accessControl.checkCanSetViewAuthorization(ADMIN, new CatalogSchemaTableName("some-catalog", "test", "test"), new TrinoPrincipal(PrincipalType.ROLE, "some_role"));
    accessControl.checkCanSetViewAuthorization(ADMIN, new CatalogSchemaTableName("some-catalog", "test", "test"), new TrinoPrincipal(PrincipalType.USER, "some_user"));
}
Also used : SystemAccessControl(io.trino.spi.security.SystemAccessControl) TrinoPrincipal(io.trino.spi.security.TrinoPrincipal) CatalogSchemaTableName(io.trino.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Example 30 with CatalogSchemaTableName

use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.

the class TestFileBasedSystemAccessControl method testTableRulesForCheckCanRenameTable.

@Test
public void testTableRulesForCheckCanRenameTable() {
    SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
    accessControl.checkCanRenameTable(ADMIN, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), new CatalogSchemaTableName("some-catalog", "aliceschema", "newbobtable"));
    accessControl.checkCanRenameTable(ALICE, new CatalogSchemaTableName("some-catalog", "aliceschema", "alicetable"), new CatalogSchemaTableName("some-catalog", "aliceschema", "newalicetable"));
    assertAccessDenied(() -> accessControl.checkCanRenameTable(BOB, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), new CatalogSchemaTableName("some-catalog", "bobschema", "newbobtable")), RENAME_TABLE_ACCESS_DENIED_MESSAGE);
    assertAccessDenied(() -> accessControl.checkCanRenameTable(ALICE, new CatalogSchemaTableName("some-catalog", "aliceschema", "alicetable"), new CatalogSchemaTableName("some-catalog", "bobschema", "newalicetable")), RENAME_TABLE_ACCESS_DENIED_MESSAGE);
}
Also used : SystemAccessControl(io.trino.spi.security.SystemAccessControl) CatalogSchemaTableName(io.trino.spi.connector.CatalogSchemaTableName) Test(org.testng.annotations.Test)

Aggregations

CatalogSchemaTableName (io.trino.spi.connector.CatalogSchemaTableName)68 Test (org.testng.annotations.Test)48 SystemAccessControl (io.trino.spi.security.SystemAccessControl)38 SchemaTableName (io.trino.spi.connector.SchemaTableName)18 Optional (java.util.Optional)13 TrinoPrincipal (io.trino.spi.security.TrinoPrincipal)12 Type (io.trino.spi.type.Type)11 Map (java.util.Map)11 ImmutableList (com.google.common.collect.ImmutableList)9 ImmutableMap (com.google.common.collect.ImmutableMap)9 TrinoException (io.trino.spi.TrinoException)9 List (java.util.List)8 Objects.requireNonNull (java.util.Objects.requireNonNull)8 ImmutableSet (com.google.common.collect.ImmutableSet)7 Session (io.trino.Session)7 Logger (io.airlift.log.Logger)6 ViewExpression (io.trino.spi.security.ViewExpression)6 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)5 CatalogSchemaName (io.trino.spi.connector.CatalogSchemaName)5 ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)5