/// <summary> /// Gets the oval system characteristic in object format. /// </summary> /// <returns></returns> public oval_system_characteristics GetSystemCharacteristics() { if (this.SystemCharacteristics != null) { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); return(factory.CreateSystemCharacteristicsByXML(this.SystemCharacteristics)); } return(null); }
public void Should_be_possible_to_create_a_systemCharacteristics_eliminating_duplicate_references_for_itemType_in_the_systemData_property() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithSytemDataDuplicated(); oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probeResult); Assert.IsNotNull(systemCharacteristics, "the systemCharacteristics expected is null"); Assert.AreEqual(2, systemCharacteristics.system_data.Count(), "the quantity of system data is not expected"); }
public void Should_be_possible_to_get_a_system_characteristics_in_xml_format_given_a_probeResult() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); string systemCharacteristicsXML = factory.CreateSystemCharacteristicsInXMLFormat(probe); Assert.IsNotNull(systemCharacteristicsXML); //creates a stream for the xml generated MemoryStream m = new MemoryStream(Encoding.UTF8.GetBytes(systemCharacteristicsXML)); IEnumerable <string> loadErrors; oval_system_characteristics systemCharacteristicsFromXmlGenerated = oval_system_characteristics.GetOvalSystemCharacteristicsFromStream(m, out loadErrors); Assert.IsNotNull(systemCharacteristicsFromXmlGenerated, "Not was possible to get a SystemCharacteristis given the xml generated"); Assert.IsTrue(loadErrors.Count() == 0, "there are errors in the xml"); }
public void Should_be_possible_to_create_system_characteristics_given_a_probeResult() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probe); Assert.IsNotNull(systemCharacteristics); Assert.IsNotNull(systemCharacteristics.collected_objects, "the collected object is null"); Assert.IsTrue(systemCharacteristics.collected_objects[0].id == ProbeResultFactory.ID_REGISTRY_OBJECT, "the oval id is not expected"); Assert.IsTrue(systemCharacteristics.collected_objects.Count() == 1); Assert.IsNotNull(systemCharacteristics.system_data, "the system data is null"); Assert.IsTrue(systemCharacteristics.system_data.Count() > 0, "the system data is empty."); Assert.IsNotNull(systemCharacteristics.generator, "the generator is null"); Assert.IsNotNull(systemCharacteristics.system_info, "the system info is not null."); Assert.IsTrue(systemCharacteristics.system_info.interfaces.Count() == 1, "the interfaces is not expected"); }
public void Should_be_possible_to_get_a_system_characteristics_in_xml_format_given_a_probeResult_with_variables_defined() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithVariables(); string systemCharacteristicsXML = factory.CreateSystemCharacteristicsInXMLFormat(probe); Assert.IsNotNull(systemCharacteristicsXML); //creates a stream for the xml generated MemoryStream m = new MemoryStream(Encoding.UTF8.GetBytes(systemCharacteristicsXML)); IEnumerable <string> loadErrors; oval_system_characteristics systemCharacteristicsFromXmlGenerated = oval_system_characteristics.GetOvalSystemCharacteristicsFromStream(m, out loadErrors); Assert.IsNotNull(systemCharacteristicsFromXmlGenerated, "Not was possible to get a SystemCharacteristis given the xml generated"); Assert.IsTrue(loadErrors.Count() == 0, "there are errors in the xml"); Assert.AreEqual(systemCharacteristicsFromXmlGenerated.collected_objects[0].variable_value[0].variable_id, "oval:com.hp:var:4", "the variable Id is not expected"); Assert.AreEqual(systemCharacteristicsFromXmlGenerated.collected_objects[0].variable_value[0].Value, "Microsoft\\WindowsNT\\", "the variable value is not expected"); }
public void Should_be_possible_to_create_system_characteristics_given_a_probeResult_with_variables() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); ProbeResult probe = new ProbeResultFactory().CreateProbeResultForRegistryCollectWithVariables(); oval_system_characteristics systemCharacteristics = factory.CreateSystemCharacteristics(probe); Assert.IsNotNull(systemCharacteristics); Assert.IsNotNull(systemCharacteristics.collected_objects, "the collected object is null"); Assert.IsTrue(systemCharacteristics.collected_objects[0].id == ProbeResultFactory.ID_REGISTRY_OBJECT, "the oval id is not expected"); Assert.AreEqual(systemCharacteristics.collected_objects[0].variable_value[0].variable_id, "oval:com.hp:var:4", "the variable Id is not expected"); Assert.AreEqual(systemCharacteristics.collected_objects[0].variable_value[0].Value, "Microsoft\\WindowsNT\\", "the variable value is not expected"); Assert.IsTrue(systemCharacteristics.collected_objects.Count() == 1); Assert.IsNotNull(systemCharacteristics.system_data, "the system data is null"); Assert.IsTrue(systemCharacteristics.system_data.Count() > 0, "the system data is empty."); Assert.IsNotNull(systemCharacteristics.generator, "the generator is null"); Assert.IsNotNull(systemCharacteristics.system_info, "the system info is not null."); Assert.IsTrue(systemCharacteristics.system_info.interfaces.Count() == 1, "the interfaces is not expected"); }
public void Should_be_possible_to_create_a_new_systemCharacteristics_from_the_combination_with_others_and_the_systemInformation_by_SystemInfo() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); oval_system_characteristics systemCharacteristics = this.GetSystemCharacteristics("oval.org.mitre.oval.sc.5368.xml"); oval_system_characteristics otherSystemCharacteristics = this.GetSystemCharacteristics("fdcc_xpfirewall_oval.sc.xml"); List <oval_system_characteristics> scList = new List <oval_system_characteristics>(); scList.Add(systemCharacteristics); scList.Add(otherSystemCharacteristics); Target target = this.CreateTargetWithSystemInformation(); oval_system_characteristics newSystemCharacteristics = factory.CreateSystemCharacteristicsBy(scList, target.SystemInformation); Assert.IsNotNull(newSystemCharacteristics, "the systemCaracteristics expected is null"); Assert.IsNotNull(newSystemCharacteristics.system_info, "the system_info is null"); Assert.AreEqual(newSystemCharacteristics.system_info.architecture, target.SystemInformation.Architecture); Assert.AreEqual(newSystemCharacteristics.system_info.os_name, target.SystemInformation.SystemName); Assert.AreEqual(newSystemCharacteristics.system_info.os_version, target.SystemInformation.SystemVersion); }
public void Should_be_possible_to_create_a_new_systemCharacteristics_from_the_combination_with_others() { SystemCharacteristicsFactory factory = new SystemCharacteristicsFactory(); oval_system_characteristics systemCharacteristics = this.GetSystemCharacteristics("oval.org.mitre.oval.sc.5368.xml"); oval_system_characteristics otherSystemCharacteristics = this.GetSystemCharacteristics("fdcc_xpfirewall_oval.sc.xml"); List <oval_system_characteristics> scList = new List <oval_system_characteristics>(); scList.Add(systemCharacteristics); scList.Add(otherSystemCharacteristics); oval_system_characteristics newSystemCharacteristics = factory.CreateSystemCharacteristicsBy(scList); int quantityCollectedObject = systemCharacteristics.collected_objects.Count() + otherSystemCharacteristics.collected_objects.Count(); int quantitySystemData = systemCharacteristics.system_data.Count() + otherSystemCharacteristics.system_data.Count(); Assert.IsNotNull(newSystemCharacteristics, "the systemCharacteristics expected is null"); Assert.IsTrue(newSystemCharacteristics.collected_objects.Count() == quantityCollectedObject, " the quantity of collected objects is not expected"); Assert.IsTrue(newSystemCharacteristics.system_data.Count() == quantitySystemData, "the quantity of system data is no expected"); }
public CollectResultFactory() { this.systemCharacteristicsFactory = new SystemCharacteristicsFactory(); }