Search in sources :

Example 6 with Expression

use of com.yahoo.elide.core.security.permissions.expressions.Expression in project elide by yahoo.

the class PermissionExpressionVisitorTest method testAndExpression.

@Test
public void testAndExpression() {
    Expression expression = getExpressionForPermission(ReadPermission.class);
    assertEquals(ExpressionResult.PASS, expression.evaluate(Expression.EvaluationMode.ALL_CHECKS));
}
Also used : Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) Test(org.junit.jupiter.api.Test)

Example 7 with Expression

use of com.yahoo.elide.core.security.permissions.expressions.Expression in project elide by yahoo.

the class PermissionExpressionVisitorTest method testComplexModelCreate.

@Test
public void testComplexModelCreate() {
    Expression expression = getExpressionForPermission(CreatePermission.class, ClassType.of(ComplexEntity.class));
    assertEquals(ExpressionResult.PASS, expression.evaluate(Expression.EvaluationMode.ALL_CHECKS));
}
Also used : Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) Test(org.junit.jupiter.api.Test)

Example 8 with Expression

use of com.yahoo.elide.core.security.permissions.expressions.Expression in project elide by yahoo.

the class PermissionExpressionVisitorTest method testNamesWithSpaces.

@Test
public void testNamesWithSpaces() {
    Expression expression = getExpressionForPermission(DeletePermission.class, ClassType.of(ComplexEntity.class));
    Expression expression2 = getExpressionForPermission(UpdatePermission.class, ClassType.of(ComplexEntity.class));
    assertEquals(ExpressionResult.PASS, expression.evaluate(Expression.EvaluationMode.ALL_CHECKS));
    assertEquals(ExpressionResult.PASS, expression2.evaluate(Expression.EvaluationMode.ALL_CHECKS));
}
Also used : Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) Test(org.junit.jupiter.api.Test)

Example 9 with Expression

use of com.yahoo.elide.core.security.permissions.expressions.Expression in project elide by yahoo.

the class PermissionExpressionVisitorTest method testOrExpression.

@Test
public void testOrExpression() {
    Expression expression = getExpressionForPermission(UpdatePermission.class);
    assertEquals(ExpressionResult.PASS, expression.evaluate(Expression.EvaluationMode.ALL_CHECKS));
}
Also used : Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) Test(org.junit.jupiter.api.Test)

Example 10 with Expression

use of com.yahoo.elide.core.security.permissions.expressions.Expression in project elide by yahoo.

the class PermissionExpressionVisitorTest method testNotExpression.

@Test
public void testNotExpression() {
    Expression expression = getExpressionForPermission(DeletePermission.class);
    assertEquals(ExpressionResult.PASS, expression.evaluate(Expression.EvaluationMode.ALL_CHECKS));
}
Also used : Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) Test(org.junit.jupiter.api.Test)

Aggregations

Expression (com.yahoo.elide.core.security.permissions.expressions.Expression)24 Test (org.junit.jupiter.api.Test)12 CheckExpression (com.yahoo.elide.core.security.permissions.expressions.CheckExpression)11 AndExpression (com.yahoo.elide.core.security.permissions.expressions.AndExpression)8 OrExpression (com.yahoo.elide.core.security.permissions.expressions.OrExpression)8 ParseTree (org.antlr.v4.runtime.tree.ParseTree)8 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)7 ReadPermission (com.yahoo.elide.annotation.ReadPermission)5 PersistentResource (com.yahoo.elide.core.PersistentResource)5 RequestScope (com.yahoo.elide.core.RequestScope)5 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)5 ChangeSpec (com.yahoo.elide.core.security.ChangeSpec)5 Type (com.yahoo.elide.core.type.Type)5 Function (java.util.function.Function)5 ForbiddenAccessException (com.yahoo.elide.core.exceptions.ForbiddenAccessException)4 ExpressionResult (com.yahoo.elide.core.security.permissions.ExpressionResult)4 AnyFieldExpression (com.yahoo.elide.core.security.permissions.expressions.AnyFieldExpression)4 SpecificFieldExpression (com.yahoo.elide.core.security.permissions.expressions.SpecificFieldExpression)4 Annotation (java.lang.annotation.Annotation)4 Set (java.util.Set)4