Пример #1
0
        public void Should_be_possible_to_generate_SID_SIDItems_from_SID_SIDObject_with_referenced_variable()
        {
            // Arrange
            oval_definitions definitions   = ProbeHelper.GetFakeOvalDefinitions(DEFINITIONS_SIMPLE);
            sid_sid_object   sid_sidObject = (sid_sid_object)definitions.objects.Where(obj => obj.id.Equals("oval:modulo:obj:201")).Single();
            VariableType     ovalVariable  = definitions.variables.Where(var => var.id.Equals("oval:modulo:var:201")).Single();
            string           variableValue = ((VariablesTypeVariableConstant_variable)ovalVariable).value.First().Value;

            VariablesEvaluated       fakeVariables = VariableHelper.CreateVariableWithOneValue(sid_sidObject.id, ovalVariable.id, variableValue);
            SID_SIDItemTypeGenerator itemGenerator = new SID_SIDItemTypeGenerator();

            // Act
            var generatedItems = itemGenerator.GetItemsToCollect(sid_sidObject, fakeVariables);

            Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null.");
            Assert.AreEqual(1, generatedItems.Count(), "Unexpected items count was found.");
            Assert.IsInstanceOfType(generatedItems.ElementAt(0), typeof(sid_sid_item), "Unexpected type of generated item found. The correct type is 'sid_sid_item'");
            Assert.AreEqual(variableValue, ((sid_sid_item)generatedItems.ElementAt(0)).trustee_sid.Value, "A generated sid_sid_item with unexpected sid was found.");
            Assert.IsNull(((sid_sid_item)generatedItems.ElementAt(0)).trustee_name);
        }
Пример #2
0
        public void Should_be_possible_generate_SID_SIDItems_from_with_PatternMatch_operation_on_TrusteeSIDEntity()
        {
            #region SID SID OBJECT
            //<sid_sid_object id="oval:modulo:obj:202">
            //    <trustee_sid operation="pattern match">^S.*-500$</trustee_sid>
            //</sid_sid_object>
            #endregion

            // Arrange
            string[] fakeTrusteeSIDs = new string[] { "S-1-5", @"S-1-18-500", @"S-1-55-500", "S-1-25-5000" };
            var      sidObject       = (sid_sid_object)WindowsTestHelper.GetObjectFromDefinitions(DEFINITIONS_SIMPLE, "oval:modulo:obj:202");
            SID_SIDItemTypeGenerator itemGenerator = this.GetMockecSid_SidItemTypeGenerator(sidObject.id, fakeTrusteeSIDs);

            // Act
            var generatedItems = itemGenerator.GetItemsToCollect(sidObject, null);

            // Assert
            Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null.");
            Assert.AreEqual(2, generatedItems.Count(), "Unexpected items count was found.");
            this.AssertGeneratedSid_SidItem(generatedItems.ElementAt(0), @"S-1-18-500");
            this.AssertGeneratedSid_SidItem(generatedItems.ElementAt(1), @"S-1-55-500");
        }
Пример #3
0
        public void Should_be_possible_to_generate_SID_SID_Items_from_SID_SIDObject()
        {
            #region SID SID OBJECT
            //<sid_sid_object id="oval:modulo:obj:200">
            //  <trustee_sid>S-1-5-20</trustee_sid>
            //</sid_sid_object>
            #endregion

            // Arrange
            var sid_sidObject = (sid_sid_object)WindowsTestHelper.GetObjectFromDefinitions(DEFINITIONS_SIMPLE, "oval:modulo:obj:200");
            SID_SIDItemTypeGenerator itemTypeGenerator = new SID_SIDItemTypeGenerator();

            // Act
            var generatedItems = itemTypeGenerator.GetItemsToCollect(sid_sidObject, null);

            // Assert
            Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null.");
            Assert.AreEqual(1, generatedItems.Count(), "Unexpected items count was found.");
            Assert.IsInstanceOfType(generatedItems.ElementAt(0), typeof(sid_sid_item), "Unexpected type of generated item found. The correct type is 'sid_sid_item'");
            Assert.AreEqual("S-1-5-20", ((sid_sid_item)generatedItems.ElementAt(0)).trustee_sid.Value, "A generated sid_sid_item with unexpected sid was found.");
            Assert.IsNull(((sid_sid_item)generatedItems.ElementAt(0)).trustee_name);
        }