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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations