コード例 #1
0
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();
            parser = mocks.StrictMock<N2.Web.IUrlParser>();
            context = CreateWebContext(false);

            EditSection editSection = new EditSection();
            security = new SecurityManager(context, editSection);
            enforcer = new SecurityEnforcer(persister, security, new ContentActivator(null, null, null), parser, context, new HostSection());
            enforcer.Start();
        }
コード例 #2
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();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
0
ファイル: SecurityManagerTests.cs プロジェクト: spmason/n2cms
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();
            parser = mocks.StrictMock<N2.Web.IUrlParser>();
            context = CreateWebContext(false);

            EditSection editSection = new EditSection();
            security = new SecurityManager(context, editSection);
            enforcer = new SecurityEnforcer(persister, security, MockRepository.GenerateStub<IDefinitionManager>(), parser, context);
            enforcer.Start();
        }