Search in sources :

Example 16 with LegacyTestWiki

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

the class AuthorizationManagerTest method testGlobalUserInEmptySubWiki.

// Tests
@Test
public void testGlobalUserInEmptySubWiki() throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "emptySubWiki.xml", false);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki2");
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.VIEW, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.EDIT, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.COMMENT, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.DELETE, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.REGISTER, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.ADMIN, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), ctx);
    assertAccessFalse("User from global wiki should have the same rights on empty subwiki", Right.PROGRAM, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki2", "Space", "Page"), 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 17 with LegacyTestWiki

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

the class AuthorizationManagerTest method testRightOnUserAndDelete.

// Cache tests
@Test
public void testRightOnUserAndDelete() throws Exception {
    LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "usersAndGroups.xml", false);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    assertAccessTrue("User should have view right", Right.VIEW, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki", "Space", "Page"), ctx);
    assertAccessTrue("User should have view right", Right.VIEW, new DocumentReference("wiki", "XWiki", "user2"), new DocumentReference("wiki", "Space", "Page"), ctx);
    testWiki.deleteUser("user", "wiki");
    assertAccessFalse("User should have view right", Right.VIEW, new DocumentReference("wiki", "XWiki", "user"), new DocumentReference("wiki", "Space", "Page"), ctx);
    assertAccessTrue("User should have view right", Right.VIEW, new DocumentReference("wiki", "XWiki", "user2"), new DocumentReference("wiki", "Space", "Page"), 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 18 with LegacyTestWiki

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

the class XWikiRightServiceTest method testRelativeDocumentReference.

@Test
public void testRelativeDocumentReference() throws Exception {
    LegacyTestWiki testWiki = newTestWiki("denieddocument.xml", true);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    testWiki.setDoc("wiki:Space.Page");
    // view
    assertAccessLevelFalse("User has right on the denied document", "view", "wiki:XWiki.user", "wiki:Space.Page", ctx);
    assertAccessLevelFalse("User has right on the denied document", "view", "wiki:XWiki.user", "Space.Page", ctx);
    assertAccessLevelFalse("User has right on the denied document", "view", "wiki:XWiki.user", "Page", ctx);
    assertAccessLevelTrue("User does not have right on the document space", "view", "wiki:XWiki.user", "", ctx);
    // edit
    assertAccessLevelFalse("User has right on the denied document", "edit", "XWiki.user", "wiki:Space.Page", ctx);
    assertAccessLevelFalse("User has right on the denied document", "edit", "XWiki.user", "Space.Page", ctx);
    assertAccessLevelFalse("User has right on the denied document", "edit", "XWiki.user", "Page", ctx);
    assertAccessLevelTrue("User does not have right on the document space", "edit", "XWiki.user", "", ctx);
}
Also used : LegacyTestWiki(org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki) XWikiContext(com.xpn.xwiki.XWikiContext) Test(org.junit.Test)

Example 19 with LegacyTestWiki

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

the class XWikiRightServiceTest method testGuestRightsOnEmptyWiki.

@Test
public void testGuestRightsOnEmptyWiki() throws Exception {
    LegacyTestWiki testWiki = newTestWiki("empty.xml", true);
    XWikiContext ctx = testWiki.getXWikiContext();
    ctx.setWikiId("wiki");
    assertAccessLevelTrue("Guest does not have view right on empty wiki.", "view", "wiki:XWiki.XWikiGuest", "wiki:Space.Page", ctx);
    assertAccessLevelTrue("Guest does not have edit right on empty wiki.", "edit", "wiki:XWiki.XWikiGuest", "wiki:Space.Page", ctx);
    assertAccessLevelFalseExpectedDifference("Guest should not have delete right on empty wiki.", "delete", "wiki:XWiki.XWikiGuest", "wiki:Space.Page", ctx);
    assertAccessLevelFalseExpectedDifference("Guest should not have admin right on empty wiki.", "admin", "wiki:XWiki.XWikiGuest", "wiki:Space.Page", ctx);
    assertAccessLevelFalse("Guest should not have programming right on empty wiki.", "programming", "wiki:XWiki.XWikiGuest", "wiki:Space.Page", ctx);
    testWiki.setUser("wiki:XWiki.XWikiGuest");
    assertWikiAdminRightsFalseExpectedDifference("Guest should not have admin right on empty wiki.", ctx);
    testWiki.setDoc("wiki:Space.Page");
    assertAdminRightsFalseExpectedDifference("Guest should not have admin right on empty wiki.", 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