use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class AccessControlTest method role_system_admin_can_access_everything.
@Test
public void role_system_admin_can_access_everything() throws Exception {
final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.from("user:myidprovider:rmy")).allow(Permission.READ).build()).add(AccessControlEntry.create().principal(PrincipalKey.from("user:myidprovider:tsi")).allow(Permission.READ).build()).build();
final CreateNodeParams params = CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).permissions(aclList).build();
final Node node = this.nodeService.create(params);
final Context anonContext = ContextBuilder.from(ctxDefault()).authInfo(AuthenticationInfo.create().user(User.ANONYMOUS).build()).build();
assertNull(anonContext.callWith(() -> getNode(node.id())));
final Context anonContextWithAdminUserRole = ContextBuilder.from(ctxDefault()).authInfo(AuthenticationInfo.create().principals(RoleKeys.ADMIN).user(User.ANONYMOUS).build()).build();
assertNotNull(anonContextWithAdminUserRole.callWith(() -> getNode(node.id())));
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class AccessControlTest method index_has_read.
@Test
public void index_has_read() throws Exception {
final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.from("user:myidprovider:rmy")).allow(Permission.READ).build()).add(AccessControlEntry.create().principal(PrincipalKey.from("user:myidprovider:tsi")).allow(Permission.READ).build()).build();
final CreateNodeParams params = CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).permissions(aclList).build();
this.nodeService.create(params);
refresh();
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class GetNodeByIdAndVersionIdCommandTest method testExecute_NonRootNode.
@Test
public void testExecute_NonRootNode() {
final CreateNodeParams createNodeParams = CreateNodeParams.create().name("child-node").parent(NodePath.ROOT).build();
final Node createdNode = createNode(createNodeParams);
final Node result = GetNodeByIdAndVersionIdCommand.create().nodeId(createdNode.id()).versionId(createdNode.getNodeVersionId()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
assertNotNull(result);
assertEquals(createdNode, result);
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class GetNodeByPathAndVersionIdCommandTest method testExecute_NonRootNode.
@Test
public void testExecute_NonRootNode() {
final CreateNodeParams createNodeParams = CreateNodeParams.create().name("child-node").parent(NodePath.ROOT).build();
final Node createdNode = createNode(createNodeParams);
final Node result = GetNodeByPathAndVersionIdCommand.create().nodePath(createdNode.path()).versionId(createdNode.getNodeVersionId()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
assertNotNull(result);
assertEquals(createdNode, result);
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class GetNodeByIdCommandTest method get_by_id_no_access.
@Test
public void get_by_id_no_access() throws Exception {
final CreateNodeParams createNodeParams = CreateNodeParams.create().name("my-node").parent(NodePath.ROOT).permissions(AccessControlList.create().add(AccessControlEntry.create().deny(Permission.READ).principal(PrincipalKey.ofAnonymous()).build()).add(AccessControlEntry.create().allow(Permission.READ).principal(PrincipalKey.from("user:system:rmy")).build()).build()).build();
final Node createdNode = createNode(createNodeParams);
final Node fetchedNode = GetNodeByIdCommand.create().indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).id(createdNode.id()).build().execute();
assertNull(fetchedNode);
}
Aggregations