use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class ImportNodeCommandTest method keep_permissions_on_update.
@Test
public void keep_permissions_on_update() throws Exception {
importNode(Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(new PropertyTree()).build());
final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.DELETE).build()).build();
final Node updatedNode = importNode(Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(new PropertyTree()).permissions(aclList).build(), true, true).getNode();
assertEquals(aclList, updatedNode.getPermissions());
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class CreateContentParamsTest method copyConstructor.
@Test
public void copyConstructor() {
final AccessControlList permissions = AccessControlList.of(AccessControlEntry.create().principal(PrincipalKey.ofAnonymous()).allow(READ).build());
final CreateContentParams source = CreateContentParams.create().type(ContentTypeName.site()).parent(ContentPath.from("/myPath/myContent")).contentData(new PropertyTree()).childOrder(ChildOrder.manualOrder()).createAttachments(CreateAttachments.empty()).displayName("displayName").extraDatas(ExtraDatas.empty()).permissions(permissions).inheritPermissions(true).language(Locale.forLanguageTag("en")).name(ContentName.from("name")).owner(PrincipalKey.ofAnonymous()).requireValid(true).build();
final CreateContentParams createContentParams = CreateContentParams.create(source).build();
assertEquals(ContentTypeName.site(), createContentParams.getType());
assertEquals(ContentPath.from("/myPath/myContent"), createContentParams.getParent());
assertEquals(new PropertyTree(), createContentParams.getData());
assertEquals(ChildOrder.manualOrder(), createContentParams.getChildOrder());
assertEquals(CreateAttachments.empty(), createContentParams.getCreateAttachments());
assertEquals("displayName", createContentParams.getDisplayName());
assertEquals(ExtraDatas.empty(), createContentParams.getExtraDatas());
assertEquals(permissions, createContentParams.getPermissions());
assertEquals(true, createContentParams.isInheritPermissions());
assertEquals(Locale.forLanguageTag("en"), createContentParams.getLanguage());
assertEquals("name", createContentParams.getName().toString());
assertEquals(PrincipalKey.ofAnonymous(), createContentParams.getOwner());
assertEquals(true, createContentParams.isRequireValid());
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class CreateContentParamsTest method allParameters.
@Test
public void allParameters() {
final AccessControlList permissions = AccessControlList.of(AccessControlEntry.create().principal(PrincipalKey.ofAnonymous()).allow(READ).build());
final CreateContentParams createContentParams = CreateContentParams.create().type(ContentTypeName.site()).parent(ContentPath.from("/myPath/myContent")).contentData(new PropertyTree()).childOrder(ChildOrder.manualOrder()).createAttachments(CreateAttachments.empty()).displayName("displayName").extraDatas(ExtraDatas.empty()).permissions(permissions).inheritPermissions(true).language(Locale.forLanguageTag("en")).name("name").owner(PrincipalKey.ofAnonymous()).requireValid(true).build();
assertEquals(ContentTypeName.site(), createContentParams.getType());
assertEquals(ContentPath.from("/myPath/myContent"), createContentParams.getParent());
assertEquals(new PropertyTree(), createContentParams.getData());
assertEquals(ChildOrder.manualOrder(), createContentParams.getChildOrder());
assertEquals(CreateAttachments.empty(), createContentParams.getCreateAttachments());
assertEquals("displayName", createContentParams.getDisplayName());
assertEquals(ExtraDatas.empty(), createContentParams.getExtraDatas());
assertEquals(permissions, createContentParams.getPermissions());
assertEquals(true, createContentParams.isInheritPermissions());
assertEquals(Locale.forLanguageTag("en"), createContentParams.getLanguage());
assertEquals("name", createContentParams.getName().toString());
assertEquals(PrincipalKey.ofAnonymous(), createContentParams.getOwner());
assertEquals(true, createContentParams.isRequireValid());
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class XmlPermissionsParser method parse.
public static AccessControlList parse(final DomElement root) {
final AccessControlList.Builder builder = AccessControlList.create();
final List<DomElement> aclEntries = root.getChildren("principal");
for (final DomElement aclEntry : aclEntries) {
builder.add(parseACLEntry(aclEntry));
}
return builder.build();
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class DumpServiceImplTest method obsolete_repository_deleted.
@Test
public void obsolete_repository_deleted() throws Exception {
final AccessControlList newRepoACL = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build();
final Repository newRepoInsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-inside-dump"), newRepoACL, ChildOrder.manualOrder()));
NodeHelper.runAsAdmin(() -> doDump(SystemDumpParams.create().dumpName("myTestDump").build()));
final Repository newRepoOutsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-outside-dump"), newRepoACL, ChildOrder.manualOrder()));
final Repositories oldRepos = NodeHelper.runAsAdmin(this::doListRepositories);
NodeHelper.runAsAdmin(this::doLoad);
final Repositories newRepos = NodeHelper.runAsAdmin(this::doListRepositories);
assertEquals(6, oldRepos.getIds().getSize());
assertEquals(5, newRepos.getIds().getSize());
assertNotNull(newRepos.getRepositoryById(newRepoInsideDump.getId()));
assertNull(newRepos.getRepositoryById(newRepoOutsideDump.getId()));
}
Aggregations