コード例 #1
0
        public void PermissionsServiceTests_UserGroup_HasPermission_Success()
        {
            //Arrange
            var permissionsService = new PermissionsService(_hive, _permissions, _membershipService);
            var userGroupIds = _userGroups.Select(x => x.Id).ToArray();

            //Assert

            // Both permissions set to allow, no node inheritance
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Copy), userGroupIds).IsAllowed());

            // One permission set to allow, one deny, no node inheritance
            Assert.IsFalse(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Save), userGroupIds).IsAllowed());
            Assert.IsFalse(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Publish), userGroupIds).IsAllowed());

            // One permission set to inherit, one set to allow, no node inheritance
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Hostnames), userGroupIds).IsAllowed());

            // Both permissions set to inherit, no node inheritance
            Assert.IsFalse(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Move), userGroupIds).IsAllowed());

            // Both permissions set to allow, no node inheritance
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Copy), userGroupIds, _childContentNode.Id).IsAllowed());

            // One permission set to allow, one deny, node inheritance
            Assert.IsFalse(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Save), userGroupIds, _childContentNode.Id).IsAllowed());
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Publish), userGroupIds, _childContentNode.Id).IsAllowed()); // In this instance, becuase the deny permission is inherited, the allow permission takes precedence

            // One permission set to inherit, one set to allow, node inheritance
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Hostnames), userGroupIds, _childContentNode.Id).IsAllowed());

            // Both permissions set to inherit, node inheritance
            Assert.IsFalse(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.Move), userGroupIds, _childContentNode.Id).IsAllowed());
        }
コード例 #2
0
        public void PermissionsServiceTests_Non_Entity_Actions_Dont_Check_Id()
        {
            //Arrange
            var permissionsService = new PermissionsService(_hive, _permissions, _membershipService);

            //Assert

            // Child content node has a BackOffice permission defined and set to Deny where system root has one set to Allow
            // because BackOfficeAccess permission is not an entity action, it should go straight to checking the system root
            // so should come back as allow.
            Assert.IsTrue(permissionsService.GetEffectivePermission(new Guid(FixedPermissionIds.BackOfficeAccess), _userId, _childContentNode.Id).IsAllowed());
        }