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(); }
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(); } }
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(); } }
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(); }