Пример #1
0
        public void GetClass()
        {
            SecurableClassDefinition  classDefinition = _testHelper.CreateClassDefinition("SecurableClass");
            StatefulAccessControlList acl             = _testHelper.CreateStatefulAcl(classDefinition);

            Assert.That(acl.Class, Is.SameAs(classDefinition));
        }
Пример #2
0
        public void OnCommitting_WithChangedPermission_RegistersClassForCommit()
        {
            var classDefinition = _testHelper.CreateClassDefinition("SecurableClass");
            var acl             = _testHelper.CreateStatelessAcl(classDefinition);
            var ace             = _testHelper.CreateAceWithOwningUser();

            acl.AccessControlEntries.Add(ace);
            var accessType = _testHelper.AttachJournalizeAccessType(classDefinition);

            ace.AllowAccess(accessType);

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                bool commitOnClassWasCalled = false;
                classDefinition.Committing += (sender, e) =>
                {
                    commitOnClassWasCalled = true;
                    Assert.That(GetDataContainer((DomainObject)sender).HasBeenMarkedChanged, Is.True);
                };
                ace.GetPermissions()[0].RegisterForCommit();

                ClientTransaction.Current.Commit();

                Assert.That(commitOnClassWasCalled, Is.True);
            }
        }
Пример #3
0
        public void CreateAccessControlEntry()
        {
            SecurableClassDefinition classDefinition  = _testHelper.CreateClassDefinition("SecurableClass");
            AccessTypeDefinition     readAccessType   = _testHelper.AttachAccessType(classDefinition, Guid.NewGuid(), "Read", 0);
            AccessTypeDefinition     deleteAccessType = _testHelper.AttachAccessType(classDefinition, Guid.NewGuid(), "Delete", 1);
            AccessControlList        acl = _testHelper.CreateStatefulAcl(classDefinition);

            using (_testHelper.Transaction.CreateSubTransaction().EnterDiscardingScope())
            {
                acl.EnsureDataAvailable();
                Assert.That(acl.State, Is.EqualTo(StateType.Unchanged));

                AccessControlEntry entry = acl.CreateAccessControlEntry();

                Assert.That(entry.AccessControlList, Is.SameAs(acl));
                Assert.That(entry.GetPermissions().Count, Is.EqualTo(2));
                Assert.That((entry.GetPermissions()[0]).AccessType, Is.SameAs(readAccessType));
                Assert.That((entry.GetPermissions()[0]).AccessControlEntry, Is.SameAs(entry));
                Assert.That((entry.GetPermissions()[1]).AccessType, Is.SameAs(deleteAccessType));
                Assert.That((entry.GetPermissions()[1]).AccessControlEntry, Is.SameAs(entry));
                Assert.That(acl.State, Is.EqualTo(StateType.Changed));
            }
        }