use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class SolrIndexScriptServiceTest method openrationsOnMultipleReferencesOnDifferentWikisChecksRightsOnEachWiki.
@Test
public void openrationsOnMultipleReferencesOnDifferentWikisChecksRightsOnEachWiki() throws Exception {
// References from 3 different wikis
WikiReference wikiReference1 = new WikiReference("wiki");
SpaceReference spaceReference = new SpaceReference("space", wikiReference1);
WikiReference wikiReference2 = new WikiReference("wiki2");
DocumentReference documentReference = new DocumentReference("wiki2", "space", "name");
WikiReference wikiReference3 = new WikiReference("wiki3");
DocumentReference documentReference2 = new DocumentReference("wiki3", "space", "name2");
// Call
this.service.index(Arrays.asList(wikiReference1, spaceReference, wikiReference2, documentReference, documentReference2));
// Assert and verify
// Actual rights check, once for each wiki.
verify(this.mockAuthorization).hasAccess(Right.ADMIN, this.userReference, wikiReference1);
verify(this.mockAuthorization).hasAccess(Right.ADMIN, this.userReference, wikiReference2);
verify(this.mockAuthorization).hasAccess(Right.ADMIN, this.userReference, wikiReference3);
verify(this.mockAuthorization).hasAccess(Right.PROGRAM, this.contentAuthorReference, wikiReference1);
verify(this.mockAuthorization).hasAccess(Right.PROGRAM, this.contentAuthorReference, wikiReference2);
verify(this.mockAuthorization).hasAccess(Right.PROGRAM, this.contentAuthorReference, wikiReference3);
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class DefaultTestWiki method getUser.
@Override
public TestUserDocument getUser(String name) {
SpaceReference spaceRef = new SpaceReference(XWikiConstants.XWIKI_SPACE, getWikiReference());
TestSpace space = getSpace(spaceRef);
if (space == null) {
return null;
}
TestDocument user = space.getDocument(new DocumentReference(name, spaceRef));
return (user instanceof TestUserDocument) ? (TestUserDocument) user : null;
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class DefaultAnnotationConfiguration method getExceptionSpaces.
@Override
public List<SpaceReference> getExceptionSpaces() {
List<String> exceptionSpaces = configuration.get().getProperty("exceptionSpaces", List.class);
List<SpaceReference> result = new ArrayList<SpaceReference>();
for (String exceptionSpace : exceptionSpaces) {
result.add(new SpaceReference(exceptionSpace, getCurrentWikiReference()));
}
return result;
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class CreatePageNestedDocumentsTest method createNestedDocumentsFromURL.
@Test
public void createNestedDocumentsFromURL() {
// Create and assert each nested document.
for (DocumentReference pageReference : nestedDocuments) {
// Navigate from URL to the page in view mode, using the no-WebHome URL, e.g. /A instead of /A/WebHome
SpaceReference spaceReference = pageReference.getLastSpaceReference();
ViewPage viewPage = getUtil().gotoPage(spaceReference);
// It should not exist and we will create it.
assertFalse(String.format("Document [%s] already exists", pageReference), viewPage.exists());
new DocumentDoesNotExistPage().clickEditThisPageToCreate();
new CreatePagePage().clickCreate();
EditPage editPage = new EditPage();
viewPage = editPage.clickSaveAndView();
// Check that we created the right page
assertCreatedNestedDocument(pageReference, viewPage);
}
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class CreatePageNestedDocumentsTest method createNestedDocumentsFromUI.
@Test
public void createNestedDocumentsFromUI() {
// Create the homepage if it does not exist and start the test from there.
DocumentReference homepage = new DocumentReference("xwiki", "Main", "WebHome");
ViewPage viewPage = getUtil().createPage(homepage, "", "Home Page");
// Create and assert each nested document.
for (DocumentReference pageReference : nestedDocuments) {
SpaceReference spaceReference = pageReference.getLastSpaceReference();
// Click the create button from the previous page.
CreatePagePage createPage = viewPage.createPage();
// Determine the values to fill in the form.
WikiReference wikiReference = spaceReference.getWikiReference();
EntityReference localParentSpaceReference = spaceReference.removeParent(wikiReference).getParent();
String spaceReferenceString = getUtil().serializeReference(localParentSpaceReference);
String pageName = spaceReference.getName();
// Fill in the form and submit it, using the space name as title.
EditPage editPage = createPage.createPage(pageName, spaceReferenceString, null, false);
// Save the page.
viewPage = editPage.clickSaveAndView();
// Check that we created the right page
assertCreatedNestedDocument(pageReference, viewPage);
}
}
Aggregations