use of com.yahoo.elide.core.PersistentResource in project elide by yahoo.
the class PermissionExecutorTest method testUserCheckOnFieldSuccess.
@Test
public void testUserCheckOnFieldSuccess() {
OpenBean openBean = new OpenBean();
openBean.id = 1L;
PersistentResource resource = newResource(OpenBean.class, false);
RequestScope requestScope = resource.getRequestScope();
ExpressionResult result = requestScope.getPermissionExecutor().checkUserPermissions(ClassType.of(OpenBean.class), ReadPermission.class, "open");
assertEquals(ExpressionResult.PASS, result);
}
use of com.yahoo.elide.core.PersistentResource in project elide by yahoo.
the class PermissionExecutorTest method testReadFieldAwareFailureAll.
@Test
public void testReadFieldAwareFailureAll() {
PersistentResource resource = newResource(SampleBean.class, false);
RequestScope requestScope = resource.getRequestScope();
assertThrows(ForbiddenAccessException.class, () -> requestScope.getPermissionExecutor().checkSpecificFieldPermissions(resource, null, ReadPermission.class, "cannotSeeMe"));
requestScope.getPermissionExecutor().executeCommitChecks();
}
use of com.yahoo.elide.core.PersistentResource 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.core.PersistentResource in project elide by yahoo.
the class PermissionExecutorTest method testUpdateFieldAwareFailureAll.
@Test
public void testUpdateFieldAwareFailureAll() {
PersistentResource resource = newResource(SampleBean.class, true);
RequestScope requestScope = resource.getRequestScope();
requestScope.getPermissionExecutor().checkSpecificFieldPermissions(resource, null, UpdatePermission.class, "allVisible");
assertThrows(ForbiddenAccessException.class, () -> requestScope.getPermissionExecutor().executeCommitChecks());
}
use of com.yahoo.elide.core.PersistentResource in project elide by yahoo.
the class PermissionExecutorTest method testUserCheckOnFieldDeferred.
@Test
public void testUserCheckOnFieldDeferred() {
PersistentResource resource = newResource(SampleBean.class, false);
RequestScope requestScope = resource.getRequestScope();
ExpressionResult result = requestScope.getPermissionExecutor().checkUserPermissions(ClassType.of(SampleBean.class), ReadPermission.class, "allVisible");
assertEquals(ExpressionResult.DEFERRED, result);
}
Aggregations