Example #1
0
        public void Should_be_possible_to_get_the_oval_results_document()
        {
            //arrange
            var loadOvalDocument = new OvalDocumentLoader();
            var session          = GetSession();
            var collectRequest   = new CollectRequestFactory().CreateCollectRequestCompleteAfterCollect(this.SessionDefault);
            var newDefinitiondoc = new DefinitionDocument()
            {
                OriginalId = "01",
                Text       = loadOvalDocument.GetFakeOvalDefinitions("OvalResultDocumentTest.xml").GetDefinitionsXml()
            };

            session.Store(newDefinitiondoc);
            collectRequest.OvalDefinitionsId = newDefinitiondoc.Oid;
            var id = this.SaveCollectRequest(collectRequest, session);

            var collectResult = new Result();

            collectResult.SystemCharacteristics = loadOvalDocument.GetFakeOvalSystemCharacteristics("OvalResultDocumentTest.xml").GetSystemCharacteristicsXML();

            var ovalDocumentGenerator = new OvalDefinitionDocumentGenerator();
            //act
            oval_results document = ovalDocumentGenerator.GetDocument(collectRequest, newDefinitiondoc.Text, collectResult);

            //assert
            Assert.IsNotNull(document);
            Assert.AreEqual(ResultEnumeration.@true, document.results[0].definitions[0].result);
        }
Example #2
0
        public void Should_Be_Possible_To_Generate_A_Valid_Result_Document_XML()
        {
            IEnumerable <string> errors;
            var definitionsDoc = GetType().Assembly.GetManifestResourceStream(
                GetType().Assembly.GetName().Name + ".samples.oval.org.mitre.oval.def.5368.xml");

            var definitions = oval_definitions.GetOvalDefinitionsFromStream(definitionsDoc, out errors);

            var scDoc = GetType().Assembly.GetManifestResourceStream(
                GetType().Assembly.GetName().Name + ".samples.oval.org.mitre.oval.sc.5368.xml");

            var systemcharacteristics = oval_system_characteristics.GetOvalSystemCharacteristicsFromStream(scDoc, out errors);

            var result = oval_results.CreateFromDocuments(definitions, systemcharacteristics, null);

            result.Analyze();

            //generate the xml from the Results object
            string resultsXML = result.GetResultsXML();

            Assert.IsFalse(string.IsNullOrEmpty(resultsXML));

            //creates a stream for the xml generated
            MemoryStream         m = new MemoryStream(Encoding.UTF8.GetBytes(resultsXML));
            IEnumerable <string> loadErrors;

            // load the oval_results from the xml generated
            oval_results ovalResults = oval_results.GetOvalResultsFromStream(m, out loadErrors);

            Assert.IsNotNull(ovalResults);
            Assert.IsTrue(loadErrors.Count() == 0, "the errors occurs in the load results object");
        }
Example #3
0
 private Results.DefinitionType GetResultDefinitionByID(oval_results ovalResults, string definitionID)
 {
     return
         (ovalResults
          .results.First()
          .definitions
          .Where(def => def.definition_id.Equals(definitionID)).Single());
 }
Example #4
0
        public void Analyze_Of_A_Test_With_No_Object_Id_Should_Return_Unknown()
        {
            var results = new oval_results();

            results.oval_definitions = new oval_definitions();
            var fakeTest = MockRepository.GenerateMock <Modulo.Collect.OVAL.Definitions.TestType>();

            fakeTest.Expect(x => x.HasObjectReference).Return(false).Repeat.Any();
            results.oval_definitions.tests = new [] { fakeTest };

            var target = new Modulo.Collect.OVAL.Results.TestType();

            target.test_id = results.oval_definitions.tests[0].id;

            ResultEnumeration result = target.Analyze(results);

            Assert.AreEqual(ResultEnumeration.unknown, result);
        }
Example #5
0
 private void DoBasicResultAssert(oval_results ovalResults)
 {
     Assert.AreEqual(0, ovalResults.results[0].definitions.Where(d => d.result == ResultEnumeration.unknown).Count());
     Assert.AreEqual(0, ovalResults.results[0].tests.Where(t => t.result == ResultEnumeration.unknown).Count());
 }