use of com.yahoo.elide.core.TestRequestScope in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionInheritedForAttributeFailureCase.
@Test
public void createPermissionInheritedForAttributeFailureCase() {
com.yahoo.elide.core.RequestScope userThreeScope = new TestRequestScope(tx, userThree, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userThreeScope)).thenReturn(updateAndCreateNewObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userThreeScope, Optional.of("5"));
assertThrows(ForbiddenAccessException.class, () -> created.updateAttribute("name", ""));
}
use of com.yahoo.elide.core.TestRequestScope in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionInheritedForAttributeSuccessCase.
// ----------------------------------------- ** Update Attribute On Create ** --------------------------------------
// Expression for field inherited from class level expression
@Test
public void createPermissionInheritedForAttributeSuccessCase() {
com.yahoo.elide.core.RequestScope userOneScope = new TestRequestScope(tx, userOne, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userOneScope)).thenReturn(updateAndCreateNewObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userOneScope, Optional.of("4"));
created.updateAttribute("name", "");
created.getRequestScope().getPermissionExecutor().executeCommitChecks();
}
use of com.yahoo.elide.core.TestRequestScope in project elide by yahoo.
the class UpdateOnCreateTest method updatePermissionOverwrittenForAttributeFailureCase.
@Test
public void updatePermissionOverwrittenForAttributeFailureCase() {
com.yahoo.elide.core.RequestScope userThreeScope = new TestRequestScope(tx, userThree, dictionary);
UpdateAndCreate updateAndCreateExistingObject = new UpdateAndCreate();
when(tx.loadObject(any(), eq(1L), any(com.yahoo.elide.core.RequestScope.class))).thenReturn(updateAndCreateExistingObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> loaded = com.yahoo.elide.core.PersistentResource.loadRecord(EntityProjection.builder().type(UpdateAndCreate.class).build(), "1", userThreeScope);
assertThrows(ForbiddenAccessException.class, () -> loaded.updateAttribute("alias", ""));
}
use of com.yahoo.elide.core.TestRequestScope in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionOverwrittenForRelationFailureCase.
@Test
public void createPermissionOverwrittenForRelationFailureCase() {
com.yahoo.elide.core.RequestScope userOneScope = new TestRequestScope(tx, userOne, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userOneScope)).thenReturn(updateAndCreateNewObject);
when(tx.loadObject(any(), eq(2L), any(RequestScope.class))).thenReturn(new Author());
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userOneScope, Optional.of("11"));
com.yahoo.elide.core.PersistentResource<Author> loadedAuthor = PersistentResource.loadRecord(EntityProjection.builder().type(Author.class).build(), "2", userOneScope);
assertThrows(ForbiddenAccessException.class, () -> created.addRelation("author", loadedAuthor));
}
use of com.yahoo.elide.core.TestRequestScope in project elide by yahoo.
the class UpdateOnCreateTest method updatePermissionInheritedForAttributeFailureCase.
@Test
public void updatePermissionInheritedForAttributeFailureCase() {
com.yahoo.elide.core.RequestScope userOneScope = new TestRequestScope(tx, userOne, dictionary);
UpdateAndCreate updateAndCreateExistingObject = new UpdateAndCreate();
when(tx.loadObject(any(), eq(1L), any(com.yahoo.elide.core.RequestScope.class))).thenReturn(updateAndCreateExistingObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> loaded = com.yahoo.elide.core.PersistentResource.loadRecord(EntityProjection.builder().type(UpdateAndCreate.class).build(), "1", userOneScope);
assertThrows(ForbiddenAccessException.class, () -> loaded.updateAttribute("name", ""));
}
Aggregations