Search in sources :

Example 1 with AccessDeniedException

use of io.prestosql.spi.security.AccessDeniedException in project ranger by apache.

the class RangerSystemAccessControlTest method testViewOperations.

@Test
@SuppressWarnings("PMD")
public void testViewOperations() {
    accessControlManager.checkCanCreateView(context(alice), aliceView);
    accessControlManager.checkCanDropView(context(alice), aliceView);
    accessControlManager.checkCanSelectFromColumns(context(alice), aliceView, ImmutableSet.of());
    accessControlManager.checkCanCreateViewWithSelectFromColumns(context(alice), aliceTable, ImmutableSet.of());
    accessControlManager.checkCanCreateViewWithSelectFromColumns(context(alice), aliceView, ImmutableSet.of());
    accessControlManager.checkCanSetCatalogSessionProperty(context(alice), aliceCatalog, "property");
    accessControlManager.checkCanGrantTablePrivilege(context(alice), SELECT, aliceTable, new PrestoPrincipal(USER, "grantee"), true);
    accessControlManager.checkCanRevokeTablePrivilege(context(alice), SELECT, aliceTable, new PrestoPrincipal(USER, "revokee"), true);
    try {
        accessControlManager.checkCanCreateView(context(bob), aliceView);
    } catch (AccessDeniedException expected) {
    }
}
Also used : AccessDeniedException(io.prestosql.spi.security.AccessDeniedException) PrestoPrincipal(io.prestosql.spi.security.PrestoPrincipal) Test(org.junit.Test)

Example 2 with AccessDeniedException

use of io.prestosql.spi.security.AccessDeniedException in project ranger by apache.

the class RangerSystemAccessControlTest method testSchemaOperations.

@Test
@SuppressWarnings("PMD")
public void testSchemaOperations() {
    Set<String> aliceSchemas = ImmutableSet.of("schema");
    assertEquals(accessControlManager.filterSchemas(context(alice), aliceCatalog, aliceSchemas), aliceSchemas);
    assertEquals(accessControlManager.filterSchemas(context(bob), "alice-catalog", aliceSchemas), ImmutableSet.of());
    accessControlManager.checkCanCreateSchema(context(alice), aliceSchema);
    accessControlManager.checkCanDropSchema(context(alice), aliceSchema);
    accessControlManager.checkCanRenameSchema(context(alice), aliceSchema, "new-schema");
    accessControlManager.checkCanShowSchemas(context(alice), aliceCatalog);
    try {
        accessControlManager.checkCanCreateSchema(context(bob), aliceSchema);
    } catch (AccessDeniedException expected) {
    }
    accessControlManager.checkCanSetSchemaAuthorization(context(alice), aliceSchema, new PrestoPrincipal(USER, "principal"));
    accessControlManager.checkCanShowCreateSchema(context(alice), aliceSchema);
}
Also used : AccessDeniedException(io.prestosql.spi.security.AccessDeniedException) PrestoPrincipal(io.prestosql.spi.security.PrestoPrincipal) Test(org.junit.Test)

Example 3 with AccessDeniedException

use of io.prestosql.spi.security.AccessDeniedException in project ranger by apache.

the class RangerSystemAccessControlTest method testTableOperations.

@Test
@SuppressWarnings("PMD")
public void testTableOperations() {
    Set<SchemaTableName> aliceTables = ImmutableSet.of(new SchemaTableName("schema", "table"));
    assertEquals(accessControlManager.filterTables(context(alice), aliceCatalog, aliceTables), aliceTables);
    assertEquals(accessControlManager.filterTables(context(bob), "alice-catalog", aliceTables), ImmutableSet.of());
    accessControlManager.checkCanCreateTable(context(alice), aliceTable);
    accessControlManager.checkCanDropTable(context(alice), aliceTable);
    accessControlManager.checkCanSelectFromColumns(context(alice), aliceTable, ImmutableSet.of());
    accessControlManager.checkCanInsertIntoTable(context(alice), aliceTable);
    accessControlManager.checkCanDeleteFromTable(context(alice), aliceTable);
    accessControlManager.checkCanRenameColumn(context(alice), aliceTable);
    try {
        accessControlManager.checkCanCreateTable(context(bob), aliceTable);
    } catch (AccessDeniedException expected) {
    }
}
Also used : AccessDeniedException(io.prestosql.spi.security.AccessDeniedException) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) CatalogSchemaTableName(io.prestosql.spi.connector.CatalogSchemaTableName) Test(org.junit.Test)

Aggregations

AccessDeniedException (io.prestosql.spi.security.AccessDeniedException)3 Test (org.junit.Test)3 PrestoPrincipal (io.prestosql.spi.security.PrestoPrincipal)2 CatalogSchemaTableName (io.prestosql.spi.connector.CatalogSchemaTableName)1 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)1