public void Should_be_possible_generate_SIDItems_from_SIDObject_with_PatternMatchOperation_and_VariableReference_on_TrusteeNameEntity() { // Arrange string[] fakeTrusteeNames = new string[] { "XPTO\\fernandess", @"MSS\lfernandes", @"LOCAL\lfernandes", @"lfernandes", "MSS\\admin" }; oval_definitions definitions = ProbeHelper.GetFakeOvalDefinitions(DEFINITIONS_SIMPLE); sid_object sidObject = (sid_object)definitions.objects.Where(obj => obj.id.Equals("oval:modulo:obj:99")).Single(); VariablesEvaluated fakeVariables = this.createFakeVariablesEvaluated(definitions, sidObject.id, "oval:modulo:var:99"); SIDItemTypeGenerator itemGenerator = this.GetMockecSidItemTypeGenerator(sidObject.id, fakeTrusteeNames); // Act var generatedItems = itemGenerator.GetItemsToCollect(sidObject, fakeVariables); // Arrange Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null."); Assert.AreEqual(3, generatedItems.Count(), "Unexpected items count was found."); this.AssertAllGeneratedSidItems(generatedItems.ToList(), new string[] { @"MSS\lfernandes", @"LOCAL\lfernandes", @"lfernandes" }); }
public void Should_be_possible_to_generate_SIDItems_from_SIDObject_with_referenced_variable() { // Arrange oval_definitions definitions = ProbeHelper.GetFakeOvalDefinitions(DEFINITIONS_SIMPLE); sid_object sidObject10 = (sid_object)definitions.objects.Where(obj => obj.id.Equals("oval:modulo:obj:11")).Single(); VariableType variable10 = definitions.variables.Where(var => var.id.Equals("oval:modulo:var:10")).Single(); string variable10Value = ((VariablesTypeVariableConstant_variable)variable10).value.First().Value; VariablesEvaluated fakeVariables = VariableHelper.CreateVariableWithOneValue(sidObject10.id, variable10.id, variable10Value); SIDItemTypeGenerator itemGenerator = new SIDItemTypeGenerator(); // Act IList <ItemType> generatedItems = itemGenerator.GetItemsToCollect(sidObject10, fakeVariables).ToList(); Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null."); Assert.AreEqual(1, generatedItems.Count, "Unexpected items count was found."); Assert.IsInstanceOfType(generatedItems[0], typeof(sid_item), "Unexpected type of generated item found. The correct type is 'sid_item'"); Assert.AreEqual(variable10Value, ((sid_item)generatedItems[0]).trustee_name.Value); }
public void Should_be_possible_to_generate_SIDItems_from_SIDObject() { #region SID OBJECT //<sid_object id="oval:modulo:obj:8" version="1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows"> // <trustee_name>Administrator</trustee_name> //</sid_object> #endregion // Arrange var sidObject = (sid_object)WindowsTestHelper.GetObjectFromDefinitions(DEFINITIONS_SIMPLE, OBJ_SIMPLE_8); SIDItemTypeGenerator itemTypeGenerator = new SIDItemTypeGenerator(); // Act IList <ItemType> generatedItems = itemTypeGenerator.GetItemsToCollect(sidObject, null).ToList(); // Assert Assert.IsNotNull(generatedItems, "The result of GetItemsToCollect cannot be null."); Assert.AreEqual(1, generatedItems.Count, "Unexpected items count was found."); Assert.IsInstanceOfType(generatedItems[0], typeof(sid_item), "Unexpected type of generated item found. The correct type is 'sid_item'"); Assert.AreEqual("Administrator", ((sid_item)generatedItems[0]).trustee_name.Value); }