use of io.trino.client.QueryError in project trino by trinodb.
the class TestUserImpersonationAccessControl method testReadAccessControl.
// On the tpch catalog Alice has allow all permissions, Bob has no permissions, and Charlie has read only permissions.
@Test
public void testReadAccessControl() {
QueryError aliceQueryError = trySelectQuery("alice");
assertNull(aliceQueryError);
QueryError bobQueryError = trySelectQuery("bob");
assertNotNull(bobQueryError);
assertEquals(bobQueryError.getErrorType(), "USER_ERROR");
assertEquals(bobQueryError.getErrorName(), "PERMISSION_DENIED");
QueryError charlieQueryError = trySelectQuery("charlie");
assertNull(charlieQueryError);
}
use of io.trino.client.QueryError in project trino by trinodb.
the class TestServer method checkVersionOnError.
private void checkVersionOnError(String query, @Language("RegExp") String proofOfOrigin) {
QueryResults queryResults = postQuery(request -> request.setBodyGenerator(createStaticBodyGenerator(query, UTF_8))).map(JsonResponse::getValue).filter(result -> result.getError() != null).findFirst().orElseThrow(() -> new RuntimeException("Error expected"));
assertNull(queryResults.getNextUri());
QueryError queryError = queryResults.getError();
String stackTrace = getStackTraceAsString(queryError.getFailureInfo().toException());
assertThat(stackTrace).containsPattern(proofOfOrigin);
long versionLines = Splitter.on("\n").splitToStream(stackTrace).filter(line -> line.contains("at io.trino.$gen.Trino_testversion____")).count();
if (versionLines != 1) {
fail(format("Expected version embedded in the stacktrace exactly once, but was %s: %s", versionLines, stackTrace));
}
}
Aggregations