Search in sources :

Example 1 with LegacyTestWiki

use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.

the class AbstractWikiTestCase method newTestWiki.

/**
 * @param filename The filename of the wiki description file.
 * @return A mocked wiki instance that can be used by both the old, and the caching right service implementation.
 */
protected LegacyTestWiki newTestWiki(String filename, boolean legacymock) throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), filename, legacymock);
    setContext(testWiki.getXWikiContext());
    return testWiki;
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki)

Example 2 with LegacyTestWiki

use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.

the class AuthorizationManagerTest method testMainWikiOwner.

@Test
public void testMainWikiOwner() throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "empty.xml", false);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    assertAccessTrue("Main wiki oner shoudl have Programming Right", Right.PROGRAM, new DocumentReference("wiki", "XWiki", "Admin"), null, ctx);
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki) XWikiContext(com.xpn.xwiki.XWikiContext) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 3 with LegacyTestWiki

use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.

the class AuthorizationManagerTest method testRightOnTopLevel.

@Test
public void testRightOnTopLevel() throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "empty.xml", false);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    DocumentReference user = new DocumentReference("wiki", "XWiki", "user");
    EntityReference document = null;
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.LOGIN, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.VIEW, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.EDIT, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.DELETE, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.REGISTER, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.COMMENT, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.PROGRAM, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.ADMIN, user, document, ctx);
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki) EntityReference(org.xwiki.model.reference.EntityReference) XWikiContext(com.xpn.xwiki.XWikiContext) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 4 with LegacyTestWiki

use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.

the class AuthorizationManagerTest method testPublicAccess.

@Test
public void testPublicAccess() throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "empty.xml", false);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    DocumentReference user = null;
    EntityReference document = new DocumentReference("wiki", "Space", "Page");
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.LOGIN, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.VIEW, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.EDIT, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.DELETE, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.REGISTER, user, document, ctx);
    assertAccessTrue("User from global wiki should have the same rights on empty subwiki", Right.COMMENT, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.PROGRAM, user, document, ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.ADMIN, user, document, ctx);
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki) EntityReference(org.xwiki.model.reference.EntityReference) XWikiContext(com.xpn.xwiki.XWikiContext) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 5 with LegacyTestWiki

use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.

the class XWikiRightServiceTest method testGroupFromAnotherWiki1.

@Test
public void testGroupFromAnotherWiki1() throws Exception {
    LegacyTestWiki testWiki = newTestWiki("groupFromAnotherWiki1.xml", true);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    assertAccessLevelTrue("User group from another wiki does not have right on a local wiki when tested from user wiki", "view", "wiki:XWiki.user", "wiki2:Space.Page", ctx);
    assertAccessLevelTrue("User group from another wiki does not have right on a local wiki when tested from user wiki", "view", "XWiki.user", "wiki2:Space.Page", ctx);
    ctx.setWikiId("wiki2");
    assertAccessLevelTrue("User from another wiki does not have right on a local wiki when tested from local wiki", "view", "wiki:XWiki.user", "wiki2:Space.Page", ctx);
    assertAccessLevelTrue("User from another wiki does not have right on a local wiki when tested from local wiki", "view", "wiki:XWiki.user", "Space.Page", ctx);
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki) XWikiContext(com.xpn.xwiki.XWikiContext) Test(org.junit.Test)

Aggregations

LegacyTestWiki (org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki)19 XWikiContext (com.xpn.xwiki.XWikiContext)18 Test (org.junit.Test)18 DocumentReference (org.xwiki.model.reference.DocumentReference)9 EntityReference (org.xwiki.model.reference.EntityReference)3 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1