Search in sources :

Example 21 with AccessControlList

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());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 22 with AccessControlList

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());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 23 with AccessControlList

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());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 24 with AccessControlList

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();
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) DomElement(com.enonic.xp.xml.DomElement)

Example 25 with AccessControlList

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()));
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) Repositories(com.enonic.xp.repository.Repositories) Repository(com.enonic.xp.repository.Repository) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

AccessControlList (com.enonic.xp.security.acl.AccessControlList)53 Test (org.junit.jupiter.api.Test)35 Node (com.enonic.xp.node.Node)26 PropertyTree (com.enonic.xp.data.PropertyTree)15 PrincipalKey (com.enonic.xp.security.PrincipalKey)8 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)6 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)6 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)6 AccessControlEntry (com.enonic.xp.security.acl.AccessControlEntry)5 Content (com.enonic.xp.content.Content)4 Context (com.enonic.xp.context.Context)4 PropertySet (com.enonic.xp.data.PropertySet)4 ApplyNodePermissionsParams (com.enonic.xp.node.ApplyNodePermissionsParams)4 NodeId (com.enonic.xp.node.NodeId)4 NodePath (com.enonic.xp.node.NodePath)4 FindNodesByParentParams (com.enonic.xp.node.FindNodesByParentParams)3 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 ImportNodeResult (com.enonic.xp.node.ImportNodeResult)3 Nodes (com.enonic.xp.node.Nodes)3 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)3