use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestQuerySessionSupplier method testCreateSession.
@Test
public void testCreateSession() {
HttpRequestSessionContext context = new HttpRequestSessionContext(TEST_REQUEST, new SqlParserOptions());
QuerySessionSupplier sessionSupplier = new QuerySessionSupplier(createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager(), new SqlEnvironmentConfig());
Session session = sessionSupplier.createSession(new QueryId("test_query_id"), context);
assertEquals(session.getQueryId(), new QueryId("test_query_id"));
assertEquals(session.getUser(), "testUser");
assertEquals(session.getSource().get(), "testSource");
assertEquals(session.getCatalog().get(), "testCatalog");
assertEquals(session.getSchema().get(), "testSchema");
assertEquals(session.getLocale(), Locale.TAIWAN);
assertEquals(session.getTimeZoneKey(), getTimeZoneKey("Asia/Taipei"));
assertEquals(session.getRemoteUserAddress().get(), "testRemote");
assertEquals(session.getClientInfo().get(), "client-info");
assertEquals(session.getClientTags(), ImmutableSet.of("tag1", "tag2", "tag3"));
assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(JOIN_DISTRIBUTION_TYPE, "partitioned").put(HASH_PARTITION_COUNT, "43").build());
assertEquals(session.getPreparedStatements(), ImmutableMap.<String, String>builder().put("query1", "select * from foo").put("query2", "select * from bar").build());
assertEquals(session.getSessionFunctions(), ImmutableMap.of(SQL_FUNCTION_ID_ADD, SQL_FUNCTION_ADD));
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestMinimalFunctionality method testTableExists.
@Test
public void testTableExists() {
QualifiedObjectName name = new QualifiedObjectName("redis", "default", tableName);
transaction(queryRunner.getTransactionManager(), new AllowAllAccessControl()).singleStatement().execute(SESSION, session -> {
Optional<TableHandle> handle = queryRunner.getServer().getMetadata().getTableHandle(session, name);
assertTrue(handle.isPresent());
});
}
use of com.facebook.presto.security.AllowAllAccessControl in project presto by prestodb.
the class Analysis method buildMaterializedViewAccessControl.
/**
* For a query on materialized view, only check the actual required access controls for its base tables. For the materialized view,
* will not check access control by replacing with AllowAllAccessControl.
*/
private Map<AccessControlInfo, Map<QualifiedObjectName, Set<String>>> buildMaterializedViewAccessControl(Map<AccessControlInfo, Map<QualifiedObjectName, Set<String>>> tableColumnReferences) {
if (!(getStatement() instanceof Query) || materializedViews.isEmpty()) {
return tableColumnReferences;
}
Map<AccessControlInfo, Map<QualifiedObjectName, Set<String>>> newTableColumnReferences = new LinkedHashMap<>();
tableColumnReferences.forEach((accessControlInfo, references) -> {
AccessControlInfo allowAllAccessControlInfo = new AccessControlInfo(new AllowAllAccessControl(), accessControlInfo.getIdentity());
Map<QualifiedObjectName, Set<String>> newAllowAllReferences = newTableColumnReferences.getOrDefault(allowAllAccessControlInfo, new LinkedHashMap<>());
Map<QualifiedObjectName, Set<String>> newOtherReferences = new LinkedHashMap<>();
references.forEach((table, columns) -> {
if (materializedViews.containsKey(table)) {
newAllowAllReferences.computeIfAbsent(table, key -> new HashSet<>()).addAll(columns);
} else {
newOtherReferences.put(table, columns);
}
});
if (!newAllowAllReferences.isEmpty()) {
newTableColumnReferences.put(allowAllAccessControlInfo, newAllowAllReferences);
}
if (!newOtherReferences.isEmpty()) {
newTableColumnReferences.put(accessControlInfo, newOtherReferences);
}
});
return newTableColumnReferences;
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestStartTransactionTask method testStartTransactionExplicitModes.
@Test
public void testStartTransactionExplicitModes() {
Session session = sessionBuilder().setClientTransactionSupport().build();
TransactionManager transactionManager = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, true, transactionManager, executor, metadata);
assertFalse(stateMachine.getSession().getTransactionId().isPresent());
StartTransactionTask startTransactionTask = new StartTransactionTask();
getFutureValue(startTransactionTask.execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
assertTrue(transactionInfo.isReadOnly());
assertFalse(transactionInfo.isAutoCommitContext());
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestStartTransactionTask method testNestedTransaction.
@Test
public void testNestedTransaction() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().setTransactionId(TransactionId.create()).setClientTransactionSupport().build();
QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, true, transactionManager, executor, metadata);
StartTransactionTask startTransactionTask = new StartTransactionTask();
try {
getFutureValue(startTransactionTask.execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode());
}
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
}
Aggregations