use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.
the class XWikiRightServiceTest method testGlobalUserInLocalGroup.
@Test
public void testGlobalUserInLocalGroup() throws Exception {
LegacyTestWiki testWiki = newTestWiki("glocalUserInLocalGroup.xml", true);
XWikiContext ctx = testWiki.getXWikiContext();
ctx.setWikiId("wiki2");
assertAccessLevelTrue("User from global wiki should have right on local wiki through local group", "view", "wiki:XWiki.user", "wiki2:Space.Page", ctx);
}
use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.
the class XWikiRightServiceTest method testGlobalGroupInLocalGroup.
@Test
public void testGlobalGroupInLocalGroup() throws Exception {
LegacyTestWiki testWiki = newTestWiki("glocalGroupInLocalGroup.xml", true);
XWikiContext ctx = testWiki.getXWikiContext();
ctx.setWikiId("wiki2");
assertAccessLevelTrue("Users from global wiki should have right on local wiki through local group", "view", "wiki:XWiki.user", "wiki2:Space.Page", ctx);
assertAccessLevelTrue("Groups from global wiki should have right on local wiki through local group", "view", "wiki:XWiki.group", "wiki2:Space.Page", ctx);
}
use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.
the class AuthorizationManagerTest method testEditAccessToGlobalRightObject.
@Test
public void testEditAccessToGlobalRightObject() throws Exception {
LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "accessToGlobalObjects.xml", false);
XWikiContext ctx = testWiki.getXWikiContext();
ctx.setWikiId("wiki");
DocumentReference userA = new DocumentReference("wiki", "XWiki", "userA");
DocumentReference userB = new DocumentReference("wiki", "XWiki", "userB");
DocumentReference userA2 = new DocumentReference("wiki2", "XWiki", "userA");
DocumentReference userB2 = new DocumentReference("wiki2", "XWiki", "userB");
assertAccessTrue("Admin should have edit access to XWikiPreferences when allowed by the wiki", Right.EDIT, userA, new DocumentReference("wiki", "XWiki", "XWikiPreferences"), ctx);
assertAccessTrue("Admin should have edit access to XWikiPreferences when allowed by the XWiki space", Right.EDIT, userA2, new DocumentReference("wiki2", "XWiki", "XWikiPreferences"), ctx);
assertAccessTrue("Global Admin should have edit access to XWikiPreferences", Right.EDIT, userA, new DocumentReference("wiki2", "XWiki", "XWikiPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to XWikiPreferences even when allowed by the document", Right.EDIT, userB, new DocumentReference("wiki", "XWiki", "XWikiPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to XWikiPreferences even when allowed by the space", Right.EDIT, userB, new DocumentReference("wiki2", "XWiki", "XWikiPreferences"), ctx);
assertAccessTrue("Admin should have edit access to XWikiPreferences when allowed by the wiki", Right.EDIT, userA, new DocumentReference("wiki", "XWiki", "WebPreferences"), ctx);
assertAccessTrue("Admin should have edit access to XWikiPreferences when allowed by the XWiki space", Right.EDIT, userA2, new DocumentReference("wiki2", "XWiki", "WebPreferences"), ctx);
assertAccessTrue("Global Admin should have edit access to XWikiPreferences", Right.EDIT, userA, new DocumentReference("wiki2", "XWiki", "WebPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to XWikiPreferences even when allowed by the document", Right.EDIT, userB, new DocumentReference("wiki", "XWiki", "WebPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to XWikiPreferences even when allowed by the space", Right.EDIT, userB, new DocumentReference("wiki2", "XWiki", "WebPreferences"), ctx);
}
use of org.xwiki.security.authorization.testwikibuilding.LegacyTestWiki in project xwiki-platform by xwiki.
the class AuthorizationManagerTest method testPublicAccessOnTopLevel.
@Test
public void testPublicAccessOnTopLevel() throws Exception {
LegacyTestWiki testWiki = new LegacyTestWiki(getMockery(), getComponentManager(), "empty.xml", false);
XWikiContext ctx = testWiki.getXWikiContext();
ctx.setWikiId("wiki");
DocumentReference user = null;
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 testEditAccessToGlobalRightObjectOnEmptyWiki.
@Test
public void testEditAccessToGlobalRightObjectOnEmptyWiki() 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");
assertAccessFalse("Non-admin should not have edit access to XWikiPreferences in an empty wiki", Right.EDIT, user, new DocumentReference("wiki", "XWiki", "XWikiPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to XWiki.WebPreferences in an empty wiki", Right.EDIT, user, new DocumentReference("wiki", "XWiki", "WebPreferences"), ctx);
assertAccessFalse("Non-admin should not have edit access to WebPreferences in any space of an empty wiki", Right.EDIT, user, new DocumentReference("wiki", "space", "WebPreferences"), ctx);
}
Aggregations