Search in sources :

Example 91 with SpaceReference

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);
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 92 with SpaceReference

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;
}
Also used : TestDocument(org.xwiki.security.authorization.testwikis.TestDocument) SpaceReference(org.xwiki.model.reference.SpaceReference) TestUserDocument(org.xwiki.security.authorization.testwikis.TestUserDocument) TestSpace(org.xwiki.security.authorization.testwikis.TestSpace) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 93 with SpaceReference

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;
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) ArrayList(java.util.ArrayList)

Example 94 with SpaceReference

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);
    }
}
Also used : DocumentDoesNotExistPage(org.xwiki.test.ui.po.DocumentDoesNotExistPage) SpaceReference(org.xwiki.model.reference.SpaceReference) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) ViewPage(org.xwiki.test.ui.po.ViewPage) EditPage(org.xwiki.test.ui.po.editor.EditPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 95 with SpaceReference

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);
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) EntityReference(org.xwiki.model.reference.EntityReference) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiReference(org.xwiki.model.reference.WikiReference) EditPage(org.xwiki.test.ui.po.editor.EditPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

SpaceReference (org.xwiki.model.reference.SpaceReference)142 DocumentReference (org.xwiki.model.reference.DocumentReference)96 Test (org.junit.Test)83 WikiReference (org.xwiki.model.reference.WikiReference)58 EntityReference (org.xwiki.model.reference.EntityReference)24 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)21 ArrayList (java.util.ArrayList)11 ResourceReference (org.xwiki.rendering.listener.reference.ResourceReference)11 XWikiException (com.xpn.xwiki.XWikiException)9 QueryRestrictionGroup (com.celements.search.lucene.query.QueryRestrictionGroup)8 Expectations (org.jmock.Expectations)8 XWikiContext (com.xpn.xwiki.XWikiContext)7 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)7 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)7 ComponentManager (org.xwiki.component.manager.ComponentManager)7 NamespacedComponentManager (org.xwiki.component.manager.NamespacedComponentManager)7 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)7 EntityReferenceResolver (org.xwiki.model.reference.EntityReferenceResolver)7 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)7 DocumentResourceReference (org.xwiki.rendering.listener.reference.DocumentResourceReference)7