use of org.xwiki.model.reference.EntityReference 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.model.reference.EntityReference 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.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultContextualAuthorizationManager method checkAccess.
@Override
public void checkAccess(Right right) throws AccessDeniedException {
if (CONTENT_AUTHOR_RIGHTS.contains(right)) {
EntityReference entity;
if (right == Right.PROGRAM) {
// Defaults to the main wiki reference.
entity = null;
} else {
entity = getCurrentEntity();
}
checkAccess(right, getCurrentUser(right, null), entity);
} else {
checkAccess(right, getCurrentEntity());
}
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class TestDocumentFactory method getNewInstance.
@Override
TestDocument getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestDocument.TYPE, parent.getReference());
String creatorString = attributes.getValue("creator");
EntityReference creator = (creatorString) != null ? parser.getResolver().resolve(creatorString, DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, reference.getRoot())) : null;
return new DefaultTestDocument(reference, creator, attributes.getValue("alt"), parent);
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class TestGroupFactory method getNewInstance.
@Override
TestDocument getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestDocument.TYPE, parent.getReference());
EntityReference creator = parser.getResolver().resolve(attributes.getValue("creator"), DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, reference.getRoot()));
return new DefaultTestGroupDocument(reference, creator, attributes.getValue("alt"), parent);
}
Aggregations