use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createDocumentFromRestrictedTemplate.
@Test
public void createDocumentFromRestrictedTemplate() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(false);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
when(this.authorization.hasAccess(Right.EDIT, userReference, documentReference)).thenReturn(true);
DocumentReference templateReference = new DocumentReference("wiki", "Code", "Template");
when(this.authorization.hasAccess(Right.VIEW, userReference, templateReference)).thenReturn(false);
CreateRequest request = createRequest(documentReference, templateReference);
request.setUserReference(userReference);
run(request);
verifyNoCreate();
verify(this.mocker.getMockedLogger()).error("You are not allowed to view the template document [{}].", templateReference);
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createSpaceWithoutTemplate.
@Test
public void createSpaceWithoutTemplate() throws Throwable {
SpaceReference spaceReference = new SpaceReference("wiki", "Space");
DocumentReference spaceHomeReference = new DocumentReference("WebHome", spaceReference);
when(this.modelBridge.exists(spaceHomeReference)).thenReturn(false);
CreateRequest request = createRequest(spaceReference, null);
request.setCheckRights(false);
run(request);
verify(this.modelBridge).create(spaceHomeReference);
verify(this.modelBridge, never()).copy(any(DocumentReference.class), any(DocumentReference.class));
verify(this.modelBridge, never()).removeLock(any(DocumentReference.class));
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createRestrictedDocument.
@Test
public void createRestrictedDocument() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(false);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
when(this.authorization.hasAccess(Right.EDIT, userReference, documentReference)).thenReturn(false);
CreateRequest request = createRequest(documentReference, null);
request.setUserReference(userReference);
run(request);
verifyNoCreate();
verify(this.mocker.getMockedLogger()).error("You are not allowed to create the document [{}].", documentReference);
}
Aggregations