use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class PermissionExecutorTest method testSuccessfulOperationCheck.
@Test
public void testSuccessfulOperationCheck() throws Exception {
@Entity
@Include(rootLevel = false)
@UpdatePermission(expression = "sampleOperation")
class Model implements SampleOperationModel {
}
PersistentResource resource = newResource(new Model(), Model.class, false);
RequestScope requestScope = resource.getRequestScope();
assertEquals(ExpressionResult.PASS, requestScope.getPermissionExecutor().checkPermission(UpdatePermission.class, resource, ALL_FIELDS));
requestScope.getPermissionExecutor().executeCommitChecks();
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class PermissionExecutorTest method testFailAllSpecificFieldAwareSuccessOperationFailCommit.
@Test
public void testFailAllSpecificFieldAwareSuccessOperationFailCommit() {
@Entity
@Include(rootLevel = false)
@UpdatePermission(expression = "Prefab.Role.All")
class Model {
@Id
public Long id;
@UpdatePermission(expression = "Prefab.Role.All AND FailOp")
public String field = "some data";
}
PersistentResource resource = newResource(new Model(), Model.class, true);
RequestScope requestScope = resource.getRequestScope();
assertEquals(ExpressionResult.DEFERRED, requestScope.getPermissionExecutor().checkSpecificFieldPermissions(resource, null, UpdatePermission.class, "field"));
assertThrows(ForbiddenAccessException.class, () -> requestScope.getPermissionExecutor().executeCommitChecks());
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class PermissionExecutorTest method testFailOperationCheckAll.
@Test
public void testFailOperationCheckAll() throws Exception {
@Entity
@Include(rootLevel = false)
@UpdatePermission(expression = "sampleOperation AND Prefab.Role.None")
class Model implements SampleOperationModel {
}
PersistentResource resource = newResource(new Model(), Model.class, false);
RequestScope requestScope = resource.getRequestScope();
assertThrows(ForbiddenAccessException.class, () -> requestScope.getPermissionExecutor().checkPermission(UpdatePermission.class, resource));
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class EntityDictionaryTest method testGetFirstAnnotationConflict.
@Test
public void testGetFirstAnnotationConflict() {
@Exclude
@Include(rootLevel = false)
class Foo {
}
Annotation first = getFirstAnnotation(ClassType.of(Foo.class), Arrays.asList(Exclude.class, Include.class));
assertTrue(first instanceof Exclude);
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class SwaggerBuilderTest method testIncludeParam.
@Test
public void testIncludeParam() throws Exception {
List<Parameter> params = swagger.getPaths().get("/book").getGet().getParameters();
Set<String> paramNames = params.stream().map((param) -> param.getName()).collect(Collectors.toSet());
long includeParams = paramNames.stream().filter((name) -> name.startsWith("include")).count();
assertEquals(1, includeParams);
assertTrue(paramNames.contains("include"));
QueryParameter includeParam = (QueryParameter) params.stream().filter((param) -> param.getName().equals("include")).findFirst().get();
assertEquals("query", includeParam.getIn());
List<String> includeValues = Arrays.asList("authors", "publisher");
assertTrue(((StringProperty) includeParam.getItems()).getEnum().containsAll(includeValues));
assertEquals("csv", includeParam.getCollectionFormat());
}
Aggregations