use of io.trino.spi.security.ViewExpression in project trino by trinodb.
the class TestColumnMask method testMultipleMasksOnDifferentColumns.
@Test
public void testMultipleMasksOnDifferentColumns() {
accessControl.reset();
accessControl.columnMask(new QualifiedObjectName(CATALOG, "tiny", "orders"), "custkey", USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "-custkey"));
accessControl.columnMask(new QualifiedObjectName(CATALOG, "tiny", "orders"), "orderstatus", USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "'X'"));
assertThat(assertions.query("SELECT custkey, orderstatus FROM orders WHERE orderkey = 1")).matches("VALUES (BIGINT '-370', 'X')");
}
use of io.trino.spi.security.ViewExpression in project trino by trinodb.
the class TestColumnMask method testCoercibleType.
@Test
public void testCoercibleType() {
accessControl.reset();
accessControl.columnMask(new QualifiedObjectName(CATALOG, "tiny", "orders"), "clerk", USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "CAST(clerk AS VARCHAR(5))"));
assertThat(assertions.query("SELECT clerk FROM orders WHERE orderkey = 1")).matches("VALUES CAST('Clerk' AS VARCHAR(15))");
}
use of io.trino.spi.security.ViewExpression in project trino by trinodb.
the class TestColumnMask method testMultipleMasksOnSameColumn.
@Test
public void testMultipleMasksOnSameColumn() {
accessControl.reset();
accessControl.columnMask(new QualifiedObjectName(CATALOG, "tiny", "orders"), "custkey", USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "-custkey"));
accessControl.columnMask(new QualifiedObjectName(CATALOG, "tiny", "orders"), "custkey", USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "custkey * 2"));
assertThat(assertions.query("SELECT custkey FROM orders WHERE orderkey = 1")).matches("VALUES BIGINT '-740'");
}
use of io.trino.spi.security.ViewExpression in project trino by trinodb.
the class TestRowFilter method testMultipleFilters.
@Test
public void testMultipleFilters() {
accessControl.reset();
accessControl.rowFilter(new QualifiedObjectName(CATALOG, "tiny", "orders"), USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "orderkey < 10"));
accessControl.rowFilter(new QualifiedObjectName(CATALOG, "tiny", "orders"), USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "orderkey > 5"));
assertThat(assertions.query("SELECT count(*) FROM orders")).matches("VALUES BIGINT '2'");
}
use of io.trino.spi.security.ViewExpression in project trino by trinodb.
the class TestRowFilter method testTableReferenceInWithClause.
@Test
public void testTableReferenceInWithClause() {
accessControl.reset();
accessControl.rowFilter(new QualifiedObjectName(CATALOG, "tiny", "orders"), USER, new ViewExpression(USER, Optional.empty(), Optional.empty(), "orderkey = 1"));
assertThat(assertions.query("WITH t AS (SELECT count(*) FROM orders) SELECT * FROM t")).matches("VALUES BIGINT '1'");
}
Aggregations