Beispiel #1
0
        public void and_permission_info_extractor_returns_correct_info_for_root_node()
        {
            var expected = new List<IPermissionInfo>
            {
                new Context.Permissions.PermissionInfo
                {
                    DisplayName = s1.ToString(),
                    Spec = READ,
                    Inherit = true,
                    InheritedFrom = null,
                },
                new Context.Permissions.PermissionInfo
                {
                    DisplayName = s2.ToString(),
                    Spec = READ,
                    Inherit = false,
                                       InheritedFrom = null,

                },
            };
            var nameResolver = new DefaultNameResolver();
            var infoExtractor = new PermissionInfoExtractor(store, nameResolver);
            var actual = infoExtractor.GetPermissionInfoForNode(n1).ToList();

            actual.Should().NotBeNull();
            actual.Count().Should().Be(expected.Count);
            foreach (var ex in expected)
            {
                actual.Should().Contain(ex);
            }
        }
 public void ResolveSubjectShouldReturnCorrectID()
 {
     const string prefix1 = "test";
     const string prefix2 = "test2";
     var nameResolver = new DefaultNameResolver(prefix1, prefix2);
     var guid = new Guid();
     var expected = prefix1 + guid;
     var actual = nameResolver.ResolveSubjectID(guid);
     Assert.AreEqual(expected, actual);
 }
Beispiel #3
0
        public void and_permission_info_extractor_returns_correct_info_for_subjects()
        {
            store.AddRight(n1, s2, MANAGE, true);

            var expected = new List<IPermissionInfo>
            {
                new Context.Permissions.PermissionInfo
                {
                    DisplayName = n1.ToString(),
                    Spec = READ,
                    Inherit = false,
                    InheritedFrom = null,
                },
                new Context.Permissions.PermissionInfo
                {
                    DisplayName = n1_2.ToString(),
                    Spec = WRITE,
                    Inherit = false,
                                       InheritedFrom = null,

                },
            };

            var guids = new Guid[] { n1, n1_1, n1_2, n1_1_1, special, n1_2_1, n1_2_2, n1_2_3 };
            foreach (var g in guids)
            {
                expected.Add(new Context.Permissions.PermissionInfo
                {
                    DisplayName = g.ToString(),
                    Spec = MANAGE,
                    Inherit = true,
                    InheritedFrom = g != n1 ? n1.ToString() : null,
                });
            }

            var nameResolver = new DefaultNameResolver("");
            var infoExtractor = new PermissionInfoExtractor(store, nameResolver);
            var actual = infoExtractor.GetPermissionInfoForSubject(s2).ToList();

            actual.Should().NotBeNull();
            actual.Count().Should().Be(expected.Count);
            foreach (var ex in expected)
            {
                actual.Should().Contain(ex);
            }
            foreach (var ac in actual)
            {
                expected.Should().Contain(ac);
            }
        }