use of io.prestosql.spi.security.PrestoPrincipal 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) {
}
}
use of io.prestosql.spi.security.PrestoPrincipal 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);
}
use of io.prestosql.spi.security.PrestoPrincipal in project ranger by apache.
the class RangerSystemAccessControlTest method testMisc.
@Test
@SuppressWarnings("PMD")
public void testMisc() {
assertEquals(accessControlManager.filterViewQueryOwnedBy(context(alice), queryOwners), queryOwners);
// check {type} / {col} replacement
final VarcharType varcharType = VarcharType.createVarcharType(20);
Optional<ViewExpression> ret = accessControlManager.getColumnMask(context(alice), aliceTable, "cast_me", varcharType);
assertNotNull(ret.get());
assertEquals(ret.get().getExpression(), "cast cast_me as varchar(20)");
ret = accessControlManager.getColumnMask(context(alice), aliceTable, "do-not-cast-me", varcharType);
assertFalse(ret.isPresent());
ret = accessControlManager.getRowFilter(context(alice), aliceTable);
assertFalse(ret.isPresent());
accessControlManager.checkCanExecuteFunction(context(alice), functionName);
accessControlManager.checkCanGrantExecuteFunctionPrivilege(context(alice), functionName, new PrestoPrincipal(USER, "grantee"), true);
accessControlManager.checkCanExecuteProcedure(context(alice), aliceProcedure);
}
Aggregations