Beispiel #1
0
        public void Item_Inherits_AllowedEditors_FromParent()
        {
            var enforcer = new SecurityEnforcer(persister, new SecurityManager(new ThreadContext(), new EditSection()), activator, MockRepository.GenerateStub <IUrlParser>(), new ThreadContext());

            enforcer.Start();

            DefinitionTextPage page = definitions.CreateInstance <DefinitionTextPage>(null);

            DynamicPermissionMap.SetRoles(page, Permission.Publish, new string[] { "Group1" });

            try
            {
                DefinitionTextPage child = definitions.CreateInstance <DefinitionTextPage>(page);

                Assert.That(DynamicPermissionMap.GetRoles(child, Permission.Publish).Count(), Is.EqualTo(1));
                Assert.That(DynamicPermissionMap.GetRoles(child, Permission.Publish).Contains("Group1"));
            }
            finally
            {
                enforcer.Stop();
            }
        }
Beispiel #2
0
        public void Item_Inherits_AllowedReaders_FromParent()
        {
            var enforcer = new SecurityEnforcer(persister, new SecurityManager(new ThreadContext(), new EditSection()), activator, MockRepository.GenerateStub <IUrlParser>(), new ThreadContext());

            enforcer.Start();

            DefinitionTextPage page = definitions.CreateInstance <DefinitionTextPage>(null);

            page.AuthorizedRoles.Add(new N2.Security.AuthorizedRole(page, "Administrators"));

            try
            {
                DefinitionTextPage child = definitions.CreateInstance <DefinitionTextPage>(page);

                Assert.That(child.AuthorizedRoles.Count, Is.EqualTo(1));
                Assert.That(child.AuthorizedRoles[0].Role, Is.EqualTo("Administrators"));
                Assert.That(child.AuthorizedRoles[0].EnclosingItem, Is.EqualTo(child));
            }
            finally
            {
                enforcer.Stop();
            }
        }
Beispiel #3
0
        public void CanCreate_NewItemInstance()
        {
            DefinitionTextPage item = definitions.CreateInstance <DefinitionTextPage>(null);

            Assert.IsNotNull(item, "Couldn't create item");
        }