public void MyTestInitialize() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); this.OvalDefinitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml"); this.OvalSystemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml"); }
public void MyTestInitialize() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); this.systemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_sets.xml"); oval_definitions definitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithSet.xml"); this.states = definitions.states; }
private oval_results GetOvalResultsSample() { var ovalDocLoader = new OvalDocumentLoader(); var fakeDefinitions = ovalDocLoader.GetFakeOvalDefinitions("definitionsWithExternalVariables.xml"); var fakeSystemCharacteristics = ovalDocLoader.GetFakeOvalSystemCharacteristics("system_characteristics_with_variables.xml"); return oval_results.CreateFromDocuments(fakeDefinitions, fakeSystemCharacteristics, null); }
public void Should_be_possible_to_evaluate_a_set_with_another_set_defintion() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); sc.oval_system_characteristics systemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_sets.xml"); oval_definitions definitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithSet.xml"); IEnumerable<StateType> states = definitions.states; set registryObjectSet = SetFactory.GetSetFromDefinitionsOfRegistryObject("definitionsWithSet.xml", "oval:org.mitre.oval:obj:5000"); SetEvaluator setEvaluator = new SetEvaluator(systemCharacteristics,states, null); SetResult result = setEvaluator.Evaluate(registryObjectSet); Assert.IsNotNull(result, "the items expected is null"); Assert.AreEqual(1, result.Result.Count(), "the quantity of items is not expected"); string element = result.Result.Where<string>(item => item == "3").SingleOrDefault(); Assert.IsNotNull(element, "the element expected is not exits"); }
public void Should_be_evaluate_a_local_Variables_of_an_entityType() { OvalDocumentLoader ovalDocument = new OvalDocumentLoader(); oval_definitions definitions = ovalDocument.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml"); Assert.IsNotNull(definitions, "the definitios is not created"); oval_system_characteristics systemCharacteristics = ovalDocument.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml"); Assert.IsNotNull(definitions, "the system Characteristics is not was created"); EntityObjectStringType entityType = new EntityObjectStringType(); entityType.var_ref = "oval:org.mitre.oval:var:4000"; VariableEvaluator variableEvaluator = new VariableEvaluator(definitions.variables, systemCharacteristics, null); IEnumerable<string> values = variableEvaluator.Evaluate(entityType); Assert.IsNotNull(values, "the valueToMatch of variable is null"); Assert.IsTrue(values.Count() == 1, "the quantity of values is not expected"); Assert.IsTrue(values.ElementAt(0) == @"Software\Microsoft\Windows NT\CurrentVersion", "the value is not expected"); }
private oval_results GetOvalResultsFromDefinitionsAndSystemCharacteristicsDocuments( string definitionsResourceName, string systemCharacteristicsResourceName, oval_variables evaluatedExternalVariables) { try { var ovalDocumentLoader = new OvalDocumentLoader(); var definitions = ovalDocumentLoader.GetFakeOvalDefinitions(definitionsResourceName); var systemCharacteristics = ovalDocumentLoader.GetFakeOvalSystemCharacteristics(systemCharacteristicsResourceName); return oval_results.CreateFromDocuments(definitions, systemCharacteristics, evaluatedExternalVariables); } catch (Exception ex) { Assert.Fail(String.Format(CREATE_OVAL_RESULTS_DOC_ERROR_MSG, ex.Message)); return null; } }
public void Should_not_be_possible_to_get_value_to_variableComponent_if_this_variable_refer_his_localVariable() { OvalDocumentLoader ovalDocuments = new OvalDocumentLoader(); oval_definitions definitions = ovalDocuments.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml"); Assert.IsNotNull(definitions); oval_system_characteristics systemSystemCharacteristics = ovalDocuments.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml"); Assert.IsNotNull(systemSystemCharacteristics); VariablesTypeVariableLocal_variable localVariable = new VariablesTypeVariableLocal_variable() { id = "oval:org.mitre.oval:var:4000" }; VariableComponentType variableComponent = new VariableComponentType() { var_ref = "oval:org.mitre.oval:var:4000" }; LocalVariableVariablesComponent variableComponentEvaluator = new LocalVariableVariablesComponent(localVariable,variableComponent, definitions.variables, systemSystemCharacteristics); IEnumerable<string> values = variableComponentEvaluator.GetValue(); Assert.IsTrue(values.Count() == 0); }
public void Should_be_possible_to_get_value_to_variableComponent_by_the_LocalVariable() { OvalDocumentLoader ovalDocuments = new OvalDocumentLoader(); oval_definitions definitions = ovalDocuments.GetFakeOvalDefinitions("definitionsWithLocalVariable.xml"); Assert.IsNotNull(definitions); oval_system_characteristics systemSystemCharacteristics = ovalDocuments.GetFakeOvalSystemCharacteristics("system_characteristics_with_local_variable.xml"); Assert.IsNotNull(systemSystemCharacteristics); VariablesTypeVariableLocal_variable localVariable = new VariablesTypeVariableLocal_variable() { id = "oval:org.mitre.oval:var:5000" }; VariableComponentType variableComponent = new VariableComponentType() { var_ref = "oval:org.mitre.oval:var:4000" }; LocalVariableVariablesComponent variableComponentEvaluator = new LocalVariableVariablesComponent(localVariable,variableComponent, definitions.variables, systemSystemCharacteristics); IEnumerable<string> values = variableComponentEvaluator.GetValue(); Assert.IsTrue(values.Count() > 0, "the quantity of value is not expected"); Assert.IsTrue(values.ElementAt(0) == @"Software\Microsoft\Windows NT\CurrentVersion", "the value is not expected"); }