private CollectExecution CreateCollectExecution(IDocumentSession session, CollectRequest collectRequest) { collectFactory = new CollectFactory(); CollectExecution collectExecution = collectFactory.CreateCollectExecution(session, collectRequest); return(collectExecution); }
public CollectRequest CreateCollectRequestCompleteAfterCollect(IDocumentSession session) { CollectRequest collectRequest = new CollectRequest(); session.Store(collectRequest); CollectExecution collectExecution = new CollectExecution(); session.Store(collectExecution); collectExecution.RequestId = collectRequest.Oid; collectExecution.SetDateStartCollect(); collectExecution.SetDateEndCollect(); ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); CollectFactory collectFactory = new CollectFactory(session); ProbeExecution probeExecution = collectFactory.CreateAProbeExecution(probeResult, "registry"); CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult); collectRequest.Result = collectResult; string systemCharacteristicsXml = this.GetSystemCharacteristicsInXML(".system_characteristics.oval.org.mitre.oval.sc.5368.xml"); collectResult.SystemCharacteristics = systemCharacteristicsXml; probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics; collectExecution.ProbeExecutions.Add(probeExecution); this.CreateTarget(session, collectRequest); //session.Store(collectRequest); collectExecution.RequestId = collectRequest.Oid; return(collectRequest); }
private ProbeExecution GetProbeExecutionWithSuccess(IDocumentSession session) { ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); ProbeExecution probeExecution = new CollectFactory().CreateAProbeExecution(probeResult, "registry"); CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult); probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics; //probeExecution.Results.Add(collectResult); return(probeExecution); }
public void Should_be_possible_to_initialize_a_new_Collect_Execution() { var session = provider.GetSession(); CollectFactory collectFactory = new CollectFactory(session); //ProbeResult probeResult = probeResultFactory.CreateProbeResultForRegostryCollectWithError(); var request = new CollectRequestFactory().CreateCollectRequest(session).Item2; var execution = collectFactory.CreateCollectExecution(session, request); Assert.IsNotNull(execution); }
public void Should_be_possible_to_build_a_probeExecution_from_collectedObject() { CollectFactory collectFactory = new CollectFactory(provider.GetSession()); ProbeResult probeResult = probeResultFactory.CreateProbeResultForRegistryCollect(); ProbeExecution probeExecution = collectFactory.CreateAProbeExecution(probeResult, "registry"); Assert.IsNotNull(probeExecution); Assert.AreEqual("registry", probeExecution.Capability); Assert.IsTrue(probeExecution.ExecutionLogs.Count == 8, "the probe execution not have executionLogs expecteds"); Assert.IsTrue(probeExecution.IsComplete(), "the probe execution not have a status expected"); }
public void Shoud_be_possible_to_build_a_probeExecution_with_the_error_status_if_not_collect_was_executed() { CollectFactory collectFactory = new CollectFactory(provider.GetSession()); ProbeResult probeResult = probeResultFactory.CreateProbeResultForRegostryCollectWithError(); ProbeExecution probeExecution = collectFactory.CreateAProbeExecutionWithError("registry", "Erro connecting to host"); Assert.IsNotNull(probeExecution); Assert.AreEqual("registry", probeExecution.Capability); Assert.IsTrue(probeExecution.ExecutionLogs.Count == 1, "the probe execution not have executionLogs expecteds"); Assert.IsTrue(probeExecution.HasErrors(), "the probe execution not have a status expected"); }
public void Should_be_possible_to_build_a_probeExecution_with_error_status_and_execution_logs_if_not_collect_was_executed() { CollectFactory collectFactory = new CollectFactory(provider.GetSession()); ProbeResult probeResult = probeResultFactory.CreateProbeResultForRegostryCollectWithError(); ExecutionLogBuilder executionLog = new ExecutionLogBuilder(); executionLog.StartCollectOf("registry"); executionLog.TryConnectToHost("176.16.3.22"); executionLog.AnErrorOccurred("Error connecting to host"); executionLog.EndCollect(); ProbeExecution probeExecution = collectFactory.CreateAProbeExecutionWithError("registry", executionLog.BuildExecutionLogs()); Assert.IsNotNull(probeExecution); Assert.AreEqual("registry", probeExecution.Capability); Assert.IsTrue(probeExecution.ExecutionLogs.Count == 4, "the probe execution not have executionLogs expecteds"); Assert.IsTrue(probeExecution.HasErrors(), "the probe execution not have a status expected"); }
public CollectRequest CreateCollectRequestIncompleteAfterCollect(IDocumentSession session) { CollectRequest collectRequest = new CollectRequest(); string definitionsInXml = GetOvalObjectInXML(".definitions.fdcc_xpfirewall_oval.xml"); StringBuilder builder = new StringBuilder(definitionsInXml); var newDefinitiondoc = new DefinitionDocument() { OriginalId = "01", Text = builder.ToString() }; session.Store(newDefinitiondoc); collectRequest.OvalDefinitionsId = newDefinitiondoc.Oid; session.Store(collectRequest); CollectExecution collectExecution = new CollectExecution(); collectExecution.RequestId = collectRequest.Oid; session.Store(collectExecution); collectExecution.SetDateStartCollect(); collectExecution.SetDateEndCollect(); //collectRequest.Collects.Add(collectExecution); ProbeResult probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); CollectFactory collectFactory = new CollectFactory(session); ProbeExecution probeExecution = collectFactory.CreateAProbeExecution(probeResult, "registry"); CollectResult collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult); string systemCharacteristicsXml = this.GetSystemCharacteristicsInXML(".system_characteristics.fdcc_xpfirewall_oval.sc_incomplete.xml"); collectResult.SystemCharacteristics = systemCharacteristicsXml; probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics; collectExecution.ProbeExecutions.Add(probeExecution); // collectRequest.Collects.Add(collectExecution); this.CreateTarget(session, collectRequest); session.SaveChanges(); return(collectRequest); }
public CollectRequest CreateCompleteCollectRequestAfterCollectWithSystemCharacteristics( IDocumentSession session, string definitionsFilename, string SystemCharacteristicsFilename, string externalVariables) { var probeResult = new ProbeResultFactory().CreateProbeResultForRegistryCollect(); var definitionsInXML = GetOvalObjectInXML(definitionsFilename); var systemCharacteristicsXml = GetSystemCharacteristicsInXML(SystemCharacteristicsFilename); var collectResult = new CollectResultFactory().CreateCollectResultForTheProbeExecution(probeResult); collectResult.SystemCharacteristics = systemCharacteristicsXml; var probeExecution = new CollectFactory(session).CreateAProbeExecution(probeResult, "registry"); probeExecution.SystemCharacteristics = collectResult.SystemCharacteristics; var collectRequest = GetOvalObjectInXML(session, definitionsInXML, externalVariables); var collectExecution = CreateCollectExecution(session, collectRequest); collectExecution.ProbeExecutions.Add(probeExecution); // collectRequest.Collects.Add(collectExecution); CreateTarget(session, collectRequest); return(collectRequest); }