use of com.facebook.presto.security.AllowAllAccessControl in project presto by prestodb.
the class TestHttpRequestSessionFactory method testInvalidTimeZone.
@Test(expectedExceptions = PrestoException.class)
public void testInvalidTimeZone() throws Exception {
HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_TIME_ZONE, "unknown_timezone").build(), "testRemote");
HttpRequestSessionFactory sessionFactory = new HttpRequestSessionFactory(request);
sessionFactory.createSession(new QueryId("test_query_id"), createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager());
}
use of com.facebook.presto.security.AllowAllAccessControl in project presto by prestodb.
the class TestHttpRequestSessionFactory method testCreateSession.
@Test
public void testCreateSession() throws Exception {
HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_SOURCE, "testSource").put(PRESTO_CATALOG, "testCatalog").put(PRESTO_SCHEMA, "testSchema").put(PRESTO_LANGUAGE, "zh-TW").put(PRESTO_TIME_ZONE, "Asia/Taipei").put(PRESTO_CLIENT_INFO, "client-info").put(PRESTO_SESSION, QUERY_MAX_MEMORY + "=1GB").put(PRESTO_SESSION, DISTRIBUTED_JOIN + "=true," + HASH_PARTITION_COUNT + " = 43").put(PRESTO_PREPARED_STATEMENT, "query1=select * from foo,query2=select * from bar").build(), "testRemote");
HttpRequestSessionFactory sessionFactory = new HttpRequestSessionFactory(request);
Session session = sessionFactory.createSession(new QueryId("test_query_id"), createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager());
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.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(DISTRIBUTED_JOIN, "true").put(HASH_PARTITION_COUNT, "43").build());
assertEquals(session.getPreparedStatements(), ImmutableMap.<String, String>builder().put("query1", "select * from foo").put("query2", "select * from bar").build());
}
use of com.facebook.presto.security.AllowAllAccessControl in project presto by prestodb.
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 TestMinimalFunctionality method testTopicExists.
@Test
public void testTopicExists() {
QualifiedObjectName name = new QualifiedObjectName("kafka", "default", topicName);
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 TestRollbackTask method testNoTransactionRollback.
@Test
public void testNoTransactionRollback() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().build();
QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, true, transactionManager, executor, metadata);
RollbackTask rollbackTask = new RollbackTask();
try {
getFutureValue(rollbackTask.execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_IN_TRANSACTION.toErrorCode());
}
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Aggregations