use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class NodePermissionsResolverTest method system_admin_has_permission.
@Test
public void system_admin_has_permission() throws Exception {
final AuthenticationInfo authInfo = AuthenticationInfo.create().user(User.create().key(USER_A).login("usera").build()).principals(RoleKeys.ADMIN).build();
final AccessControlList nodePermissions = AccessControlList.create().add(AccessControlEntry.create().principal(USER_A).allow(READ).build()).add(AccessControlEntry.create().principal(GROUP_B).allow(CREATE).build()).add(AccessControlEntry.create().principal(ROLE_C).allow(MODIFY).build()).build();
assertTrue(NodePermissionsResolver.userHasPermission(authInfo, READ, nodePermissions));
assertTrue(NodePermissionsResolver.userHasPermission(authInfo, CREATE, nodePermissions));
assertTrue(NodePermissionsResolver.userHasPermission(authInfo, MODIFY, nodePermissions));
assertTrue(NodePermissionsResolver.userHasPermission(authInfo, PUBLISH, nodePermissions));
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class NodePermissionsResolverTest method hasPermissionEmptyACL.
@Test
public void hasPermissionEmptyACL() throws Exception {
final AuthenticationInfo authInfo = AuthenticationInfo.create().user(User.ANONYMOUS).principals(PrincipalKey.ofAnonymous()).build();
final AccessControlList nodePermissions = AccessControlList.create().add(AccessControlEntry.create().principal(USER_A).allow(READ).build()).add(AccessControlEntry.create().principal(GROUP_B).allow(CREATE).build()).add(AccessControlEntry.create().principal(ROLE_C).allow(MODIFY).build()).build();
assertFalse(NodePermissionsResolver.userHasPermission(authInfo, READ, nodePermissions));
assertFalse(NodePermissionsResolver.userHasPermission(authInfo, CREATE, nodePermissions));
assertFalse(NodePermissionsResolver.userHasPermission(authInfo, MODIFY, nodePermissions));
assertFalse(NodePermissionsResolver.userHasPermission(authInfo, PUBLISH, nodePermissions));
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class SetRootPermissionsHandlerTest method example.
@Test
public void example() {
final AccessControlList acl = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.ADMIN).allowAll().build()).build();
Mockito.when(this.repositoryService.get(RepositoryId.from("com.enonic.cms.default"))).thenReturn(Repository.create().id(RepositoryId.from("com.enonic.cms.default")).branches(Branches.from(ContentConstants.BRANCH_DRAFT, ContentConstants.BRANCH_MASTER)).build());
Mockito.when(this.nodeService.setRootPermissions(acl, true)).thenReturn(Node.create().permissions(acl).inheritPermissions(true).build());
runScript("/lib/xp/examples/node/modifyRootPermissions.js");
}
Aggregations