Esempio n. 1
0
        public void Import_3AccessTypes()
        {
            string metadataXml =
                @"
          <securityMetadata xmlns=""http://www.re-motion.org/Security/Metadata/1.0"">
            <classes />
            <stateProperties />
            <accessTypes>
              <accessType id=""1d6d25bc-4e85-43ab-a42d-fb5a829c30d5"" name=""Create|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""0"" />
              <accessType id=""62dfcd92-a480-4d57-95f1-28c0f5996b3a"" name=""Read|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""1"" />
              <accessType id=""11186122-6de0-4194-b434-9979230c41fd"" name=""Edit|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""2"" />
            </accessTypes>
            <abstractRoles />
          </securityMetadata>
          ";

            _importer.Import(GetXmlDocument(metadataXml));

            using (_testHelper.Transaction.EnterNonDiscardingScope())
            {
                Assert.AreEqual(0, _importer.Classes.Count, "Class count");
                Assert.AreEqual(0, _importer.StateProperties.Count, "State property count");
                Assert.AreEqual(0, _importer.AbstractRoles.Count, "Abstract role count");
                Assert.AreEqual(3, _importer.AccessTypes.Count, "Access type count");

                AccessTypeDefinition expectedAccessType1 = _testHelper.CreateAccessTypeCreate(0);
                MetadataObjectAssert.AreEqual(expectedAccessType1, _importer.AccessTypes[expectedAccessType1.MetadataItemID], "Access Type Create");

                AccessTypeDefinition expectedAccessType2 = _testHelper.CreateAccessTypeRead(1);
                MetadataObjectAssert.AreEqual(expectedAccessType2, _importer.AccessTypes[expectedAccessType2.MetadataItemID], "Access Type Read");

                AccessTypeDefinition expectedAccessType3 = _testHelper.CreateAccessTypeEdit(2);
                MetadataObjectAssert.AreEqual(expectedAccessType3, _importer.AccessTypes[expectedAccessType3.MetadataItemID], "Access Type Edit");
            }
        }
Esempio n. 2
0
        public void Import_3AbstractRoles()
        {
            string metadataXml =
                @"
          <securityMetadata xmlns=""http://www.re-motion.org/Security/Metadata/1.0"">
            <classes />
            <stateProperties />
            <accessTypes />
            <abstractRoles>
              <abstractRole id=""00000003-0001-0000-0000-000000000000"" name=""Clerk|Remotion.Security.UnitTests.TestDomain.DomainAbstractRoles, Remotion.Security.UnitTests.TestDomain"" value=""0"" />
              <abstractRole id=""00000003-0002-0000-0000-000000000000"" name=""Secretary|Remotion.Security.UnitTests.TestDomain.DomainAbstractRoles, Remotion.Security.UnitTests.TestDomain"" value=""1"" />
              <abstractRole id=""00000004-0001-0000-0000-000000000000"" name=""Administrator|Remotion.Security.UnitTests.TestDomain.SpecialAbstractRoles, Remotion.Security.UnitTests.TestDomain"" value=""0"" />
            </abstractRoles>
          </securityMetadata>
          ";

            _importer.Import(GetXmlDocument(metadataXml));

            using (_testHelper.Transaction.EnterNonDiscardingScope())
            {
                Assert.AreEqual(0, _importer.Classes.Count, "Class count");
                Assert.AreEqual(0, _importer.StateProperties.Count, "State property count");
                Assert.AreEqual(3, _importer.AbstractRoles.Count, "Abstract role count");
                Assert.AreEqual(0, _importer.AccessTypes.Count, "Access type count");

                AbstractRoleDefinition expectedRole1 = _testHelper.CreateClerkAbstractRole(0);
                MetadataObjectAssert.AreEqual(expectedRole1, _importer.AbstractRoles[expectedRole1.MetadataItemID], "Abstract Role Clerk");

                AbstractRoleDefinition expectedRole2 = _testHelper.CreateSecretaryAbstractRole(1);
                MetadataObjectAssert.AreEqual(expectedRole2, _importer.AbstractRoles[expectedRole2.MetadataItemID], "Abstract Role Secretary");

                AbstractRoleDefinition expectedRole3 = _testHelper.CreateAdministratorAbstractRole(2);
                MetadataObjectAssert.AreEqual(expectedRole3, _importer.AbstractRoles[expectedRole3.MetadataItemID], "Abstract Role Administrator");
            }
        }
Esempio n. 3
0
        public void GetState_ValidValue()
        {
            StatePropertyDefinition stateProperty = _testHelper.CreateConfidentialityProperty(0);

            StateDefinition actualState = stateProperty.GetState(MetadataTestHelper.Confidentiality_PrivateValue);

            StateDefinition expectedState = _testHelper.CreatePrivateState();

            MetadataObjectAssert.AreEqual(expectedState, actualState, "Private state");
        }
Esempio n. 4
0
        public void Indexer_ValidName()
        {
            StatePropertyDefinition stateProperty = _testHelper.CreateConfidentialityProperty(0);

            StateDefinition actualState = stateProperty[MetadataTestHelper.Confidentiality_ConfidentialName];

            StateDefinition expectedState = _testHelper.CreateConfidentialState();

            MetadataObjectAssert.AreEqual(expectedState, actualState, "Confidential state");
        }
Esempio n. 5
0
        public void Import_2StateProperties()
        {
            string metadataXml =
                @"
          <securityMetadata xmlns=""http://www.re-motion.org/Security/Metadata/1.0"">
            <classes />
            <stateProperties>
              <stateProperty id=""00000000-0000-0000-0002-000000000001"" name=""State"">
                <state name=""New"" value=""0"" />
                <state name=""Normal"" value=""1"" />
                <state name=""Archived"" value=""2"" />
              </stateProperty>

              <stateProperty id=""00000000-0000-0000-0001-000000000001"" name=""Confidentiality"">
                <state name=""Normal"" value=""0"" />
                <state name=""Confidential"" value=""1"" />
                <state name=""Private"" value=""2"" />
              </stateProperty>
            </stateProperties>
            <accessTypes />
            <abstractRoles />
          </securityMetadata>
          ";

            _importer.Import(GetXmlDocument(metadataXml));

            using (_testHelper.Transaction.EnterNonDiscardingScope())
            {
                Assert.AreEqual(0, _importer.Classes.Count, "Class count");
                Assert.AreEqual(2, _importer.StateProperties.Count, "State property count");
                Assert.AreEqual(0, _importer.AbstractRoles.Count, "Abstract role count");
                Assert.AreEqual(0, _importer.AccessTypes.Count, "Access type count");

                StatePropertyDefinition expectedProperty1 = _testHelper.CreateFileStateProperty(0);
                StatePropertyDefinition actualProperty1   = _importer.StateProperties[expectedProperty1.MetadataItemID];
                Assert.IsNotNull(actualProperty1, "State property not found");
                MetadataObjectAssert.AreEqual(expectedProperty1, actualProperty1, "State property");

                StatePropertyDefinition expectedProperty2 = _testHelper.CreateConfidentialityProperty(1);
                StatePropertyDefinition actualProperty2   = _importer.StateProperties[expectedProperty2.MetadataItemID];
                Assert.IsNotNull(actualProperty2, "Confidentiality property not found");
                MetadataObjectAssert.AreEqual(expectedProperty2, actualProperty2, "Confidentiality property");
            }
        }