Esempio n. 1
0
 public void Shoud_be_possible_to_build_an_execution_log_in_steps()
 {
     ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
     executionLog.StartCollectOf("Registry");
     executionLog.TryConnectToHost("176.16.3.166");
     executionLog.CollectingInformationFrom("oval:id:7589");
     executionLog.EndCollect();
     IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();
     Assert.AreEqual(4, executionsLog.Count(), "the quantity of execution logs is not expected");
 }
Esempio n. 2
0
        public void Shoud_be_possible_to_inform_the_systemInformation_collect()
        {
            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");
            executionLog.CollectingInformationFrom("oval:id:7589");

            executionLog.CollectSystemInformation();

            executionLog.EndCollectOf("Registry");
            IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();
            Assert.AreEqual(5, executionsLog.Count());
        }
Esempio n. 3
0
 public void Should_be_possible_to_build_an_execution_log_in_steps_with_custom_errors_logs()
 {
     ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
     executionLog.StartCollectOf("Registry");
     executionLog.TryConnectToHost("176.16.3.166");
     
     executionLog.AnErrorOccurred("Erro trying connect to host 176.16.3.166");
     
     executionLog.CollectingInformationFrom("oval:id:7589");            
     executionLog.EndCollect();
     IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();
     Assert.AreEqual(5, executionsLog.Count());
     Assert.AreEqual(TypeItemLog.Error, executionsLog.ElementAt(2).Type);
 }
Esempio n. 4
0
        public void Should_be_possible_add_a_detail_information_in_the_log()
        {
            ExecutionLogBuilder executionLogDetailBuilder = new ExecutionLogBuilder();
            executionLogDetailBuilder.CollectingDataFrom("Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\BuildType");
            executionLogDetailBuilder.CollectingDataFrom("Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\PathName");
            IEnumerable<ProbeLogItem> executionLogDetail = executionLogDetailBuilder.BuildExecutionLogs();

            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");

            executionLog.AddDetailInformation(executionLogDetail);

            executionLog.CollectingInformationFrom("oval:id:7589");
            executionLog.EndCollect();
            IEnumerable<ProbeLogItem> executionLogComplete = executionLog.BuildExecutionLogs();

            Assert.AreEqual(6, executionLogComplete.Count(), "the quantity of logs entries is not expected");
            Assert.AreEqual(executionLogComplete.ElementAt(2).Message, executionLogDetail.ElementAt(0).Message, "the detail log is no found in the correct position in the complete log");
            Assert.AreEqual(executionLogComplete.ElementAt(3).Message, executionLogDetail.ElementAt(1).Message, "the detail log is no found in the correct position in the complete log");
        }
Esempio n. 5
0
        public void Should_be_possible_to_clear_the_execution_log_after_of_the_build_executionLogs()
        {
            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");
            executionLog.CollectingInformationFrom("oval:id:7589");
            executionLog.EndCollect();
            IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();

            Assert.AreEqual(4, executionsLog.Count());

            executionLog.StartCollectOf("Registry");
            executionsLog = executionLog.BuildExecutionLogs();
            Assert.AreEqual(1, executionsLog.Count());
        }
Esempio n. 6
0
        public void Should_be_possible_to_build_an_execution_log_in_steps_with_custom_warning_logs()
        {
            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");
            executionLog.ConnectedWithSuccess();
            executionLog.CollectingInformationFrom("oval:id:7589");
            executionLog.CollectingDataFrom("Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\BuildType");

            executionLog.Warning("The key of registry item is not exists");

            executionLog.EndCollect();
            IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();
            Assert.AreEqual(7, executionsLog.Count());
            Assert.AreEqual(TypeItemLog.Warning, executionsLog.ElementAt(5).Type, "the type of log is not expected");
        }
Esempio n. 7
0
        public void should_be_possible_to_buid_an_execution_log_in_steps_informing_what_element_is_collected()
        {
            string element = "Key: HKEY_LOCAL_MACHINE\\software\\microsoft\\windows\\currentVersion\\BuildType";
            ExecutionLogBuilder executionLog = new ExecutionLogBuilder();
            executionLog.StartCollectOf("Registry");
            executionLog.TryConnectToHost("176.16.3.166");
            executionLog.ConnectedWithSuccess();
            executionLog.CollectingInformationFrom("oval:id:7858");

            executionLog.CollectingDataFrom(element);

            executionLog.EndCollect();

            IEnumerable<ProbeLogItem> executionsLog = executionLog.BuildExecutionLogs();

            Assert.AreEqual(6, executionsLog.Count());
        }
Esempio n. 8
0
        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");
        }