Exemple #1
0
        public void FindMatchingEntries_WithMultipleMatchingAces()
        {
            AccessControlEntry   ace1             = AccessControlEntry.NewObject();
            AccessTypeDefinition readAccessType   = _testHelper.CreateReadAccessTypeAndAttachToAce(ace1, true);
            AccessTypeDefinition writeAccessType  = _testHelper.CreateWriteAccessTypeAndAttachToAce(ace1, null);
            AccessTypeDefinition deleteAccessType = _testHelper.CreateDeleteAccessTypeAndAttachToAce(ace1, null);

            AbstractRoleDefinition role2 = AbstractRoleDefinition.NewObject(Guid.NewGuid(), "SoftwareDeveloper", 1);
            AccessControlEntry     ace2  = AccessControlEntry.NewObject();

            ace2.SpecificAbstractRole = role2;
            _testHelper.AttachAccessType(ace2, readAccessType, null);
            _testHelper.AttachAccessType(ace2, writeAccessType, true);
            _testHelper.AttachAccessType(ace2, deleteAccessType, null);

            AccessControlList acl   = _testHelper.CreateStatefulAcl(ace1, ace2);
            SecurityToken     token = _testHelper.CreateTokenWithAbstractRole(role2);

            AccessControlEntry[] entries = acl.FindMatchingEntries(token);

            Assert.That(entries.Length, Is.EqualTo(2));
            Assert.That(entries, Has.Member(ace2));
            Assert.That(entries, Has.Member(ace1));
        }