Ejemplo n.º 1
0
        public static string[] GetProtectedPaths(Content content)
        {
            var permitted = ContentProtector.GetProtectedPaths()
                            .Where(x =>
            {
                var head = NodeHead.Get(x);
                return(head != null && SecurityHandler.HasPermission(
                           User.Current, head.Id, PermissionType.See));
            })
                            .ToArray();

            return(permitted);
        }
        public void ContentProtector_ListIsImmutable()
        {
            Test(builder =>
            {
                // Additional path
                builder.ProtectContent("/Root/TestFolder");
            }, () =>
            {
                var originalList  = ContentProtector.GetProtectedPaths();
                var expectedFirst = originalList[0];
                originalList[0]   = null;

                var actualList  = ContentProtector.GetProtectedPaths();
                var actualFirst = actualList[0];

                Assert.AreEqual(expectedFirst, actualFirst);
            });
        }
        public void ContentProtector_ParentAxis()
        {
            var originalList = new string[0];

            Test(builder =>
            {
                originalList = ContentProtector.GetProtectedPaths();

                // Add a deep path
                builder.ProtectContent("/Root/A/B/C");
            }, () =>
            {
                var actual = string.Join(" ",
                                         ContentProtector.GetProtectedPaths().Except(originalList));

                // The whole parent axis added but the "Except" operation removes the "/Root".
                var expected = "/Root/A /Root/A/B /Root/A/B/C";

                Assert.AreEqual(expected, actual);
            });
        }