Blame SOURCES/test_ds_session_without_remote_resources.patch

7a6a25
From 8645604c8e5285c5b5bec538a50d3b4f6b13c9a5 Mon Sep 17 00:00:00 2001
7a6a25
From: Matus Marhefka <mmarhefk@redhat.com>
7a6a25
Date: Tue, 14 May 2019 15:38:50 +0200
7a6a25
Subject: [PATCH] Add test for DS session and SCAP 1.3 remote resources
7a6a25
7a6a25
* Test for PR#1324 which verifies that DS session does not quit
7a6a25
  when SCAP 1.3 content contains remote component but
7a6a25
  `--fetch-remote-resources` option is not provided. The test is
7a6a25
  also extended to verify that scans utilizing SCAP 1.2 and 1.3
7a6a25
  datastreams produce the same results.
7a6a25
---
7a6a25
 tests/DS/Makefile.am                          |  2 +
7a6a25
 .../remote_content_1.2.ds.xml                 | 87 ++++++++++++++++++
7a6a25
 .../remote_content_1.3.ds.xml                 | 89 +++++++++++++++++++
7a6a25
 tests/DS/test_ds.sh                           | 17 ++++
7a6a25
 4 files changed, 195 insertions(+)
7a6a25
 create mode 100644 tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml
7a6a25
 create mode 100644 tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml
7a6a25
7a6a25
diff --git a/tests/DS/Makefile.am b/tests/DS/Makefile.am
7a6a25
index 616f24d24..ea742386d 100644
7a6a25
--- a/tests/DS/Makefile.am
7a6a25
+++ b/tests/DS/Makefile.am
7a6a25
@@ -11,6 +11,8 @@ TESTS_ENVIRONMENT= \
7a6a25
 TESTS = test_ds.sh
7a6a25
 
7a6a25
 EXTRA_DIST = test_ds.sh \
7a6a25
+		ds_continue_without_remote_resources/remote_content_1.2.ds.xml \
7a6a25
+		ds_continue_without_remote_resources/remote_content_1.3.ds.xml \
7a6a25
 		eval_invalid/sds.xml \
7a6a25
 		eval_invalid/sds-oval.xml \
7a6a25
 		eval_simple/sds.xml \
7a6a25
diff --git a/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml b/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml
7a6a25
new file mode 100644
7a6a25
index 000000000..31d4fc770
7a6a25
--- /dev/null
7a6a25
+++ b/tests/DS/ds_continue_without_remote_resources/remote_content_1.2.ds.xml
7a6a25
@@ -0,0 +1,87 @@
7a6a25
+
7a6a25
+<ds:data-stream-collection xmlns:ds="http://scap.nist.gov/schema/scap/source/1.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cat="urn:oasis:names:tc:entity:xmlns:xml:catalog" id="scap_org.open-scap_collection_from_xccdf_test_single_rule.xccdf.xml" schematron-version="1.2">
7a6a25
+<ds:data-stream id="scap_org.open-scap_datastream_from_xccdf_test_single_rule.xccdf.xml" scap-version="1.2" use-case="OTHER">
7a6a25
+  <ds:checklists>
7a6a25
+    <ds:component-ref id="scap_org.open-scap_cref_test_single_rule.xccdf.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.xccdf.xml">
7a6a25
+      <cat:catalog>
7a6a25
+        <cat:uri name="test_single_rule.oval.xml" uri="#scap_org.open-scap_cref_test_single_rule.oval.xml"/>
7a6a25
+      </cat:catalog>
7a6a25
+    </ds:component-ref>
7a6a25
+  </ds:checklists>
7a6a25
+  <ds:checks>
7a6a25
+    <ds:component-ref id="scap_org.open-scap_cref_test_single_rule.oval.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.oval.xml"/>
7a6a25
+  </ds:checks>
7a6a25
+</ds:data-stream>
7a6a25
+
7a6a25
+<ds:component id="scap_org.open-scap_comp_test_single_rule.oval.xml" timestamp="2017-06-09T07:07:38">
7a6a25
+<oval_definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:win-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd    http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd   http://oval.mitre.org/XMLSchema/oval-definitions-5#windows windows-definitions-schema.xsd">
7a6a25
+  <generator>
7a6a25
+    <oval:schema_version>5.10</oval:schema_version>
7a6a25
+    <oval:timestamp>2009-01-12T10:41:00-05:00</oval:timestamp>
7a6a25
+  </generator>
7a6a25
+
7a6a25
+  <definitions>
7a6a25
+    <definition class="compliance" id="oval:test-pass:def:1" version="1">
7a6a25
+      <metadata>
7a6a25
+        <title>PASS</title>
7a6a25
+	<description>pass</description>
7a6a25
+      </metadata>
7a6a25
+      <criteria>
7a6a25
+        <criterion comment="PASS test" test_ref="oval:x:tst:1"/>
7a6a25
+      </criteria>
7a6a25
+    </definition>
7a6a25
+  </definitions>
7a6a25
+
7a6a25
+    <tests>
7a6a25
+    <variable_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:tst:1" check="all" comment="always pass" version="1">
7a6a25
+      <object object_ref="oval:x:obj:1"/>
7a6a25
+    </variable_test>
7a6a25
+    </tests>
7a6a25
+
7a6a25
+    <objects>
7a6a25
+    <variable_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:obj:1" version="1" comment="x">
7a6a25
+      <var_ref>oval:x:var:1</var_ref>
7a6a25
+    </variable_object>
7a6a25
+    </objects>
7a6a25
+</oval_definitions>
7a6a25
+</ds:component>
7a6a25
+
7a6a25
+<ds:component id="scap_org.open-scap_comp_test_single_rule.xccdf.xml" timestamp="2017-06-09T09:15:45">
7a6a25
+<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="xccdf_com.example.www_benchmark_dummy" xml:lang="en-US">
7a6a25
+  <status>accepted</status>
7a6a25
+  <version>1.0</version>
7a6a25
+
7a6a25
+  <Profile id="xccdf_com.example.www_profile_test_remote_res">
7a6a25
+    <title>xccdf_test_profile</title>
7a6a25
+    <description>This profile is for testing.</description>
7a6a25
+    <select idref="xccdf_com.example.www_rule_test-pass" selected="true"/>
7a6a25
+    <select idref="xccdf_com.example.www_rule_test-remote_res" selected="true"/>
7a6a25
+  </Profile>
7a6a25
+
7a6a25
+  <Value id="xccdf_com.example.www_value_val1" type="number" operator="equals" interactive="0">
7a6a25
+    <title>test value</title>
7a6a25
+    <description>foo</description>
7a6a25
+    <value selector="bar_1">50</value>
7a6a25
+    <value selector="bar_2">100</value>
7a6a25
+  </Value>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass">
7a6a25
+    <title>This rule always pass</title>
7a6a25
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
7a6a25
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
7a6a25
+    </check>
7a6a25
+  </Rule>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-remote_res">
7a6a25
+      <title>This rule checks remote resource</title>
7a6a25
+      <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
7a6a25
+          <check-content-ref href="https://www.example.com/security/data/oval/oval.xml.bz2"/>
7a6a25
+      </check>
7a6a25
+  </Rule>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass2">
7a6a25
+    <title>This rule always pass</title>
7a6a25
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
7a6a25
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
7a6a25
+    </check>
7a6a25
+  </Rule>
7a6a25
+</Benchmark>
7a6a25
+</ds:component>
7a6a25
+</ds:data-stream-collection>
7a6a25
diff --git a/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml b/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml
7a6a25
new file mode 100644
7a6a25
index 000000000..3cf15f8df
7a6a25
--- /dev/null
7a6a25
+++ b/tests/DS/ds_continue_without_remote_resources/remote_content_1.3.ds.xml
7a6a25
@@ -0,0 +1,89 @@
7a6a25
+
7a6a25
+<ds:data-stream-collection xmlns:ds="http://scap.nist.gov/schema/scap/source/1.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cat="urn:oasis:names:tc:entity:xmlns:xml:catalog" id="scap_org.open-scap_collection_from_xccdf_test_single_rule.xccdf.xml" schematron-version="1.3">
7a6a25
+<ds:data-stream id="scap_org.open-scap_datastream_from_xccdf_test_single_rule.xccdf.xml" scap-version="1.3" use-case="OTHER">
7a6a25
+  <ds:checklists>
7a6a25
+    <ds:component-ref id="scap_org.open-scap_cref_test_single_rule.xccdf.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.xccdf.xml">
7a6a25
+      <cat:catalog>
7a6a25
+        <cat:uri name="test_single_rule.oval.xml" uri="#scap_org.open-scap_cref_test_single_rule.oval.xml"/>
7a6a25
+        <cat:uri name="security-data-oval.xml.bz2" uri="#scap_org.open-scap_cref_security-data-oval.xml.bz2"/>
7a6a25
+      </cat:catalog>
7a6a25
+    </ds:component-ref>
7a6a25
+  </ds:checklists>
7a6a25
+  <ds:checks>
7a6a25
+    <ds:component-ref id="scap_org.open-scap_cref_test_single_rule.oval.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.oval.xml"/>
7a6a25
+    <ds:component-ref id="scap_org.open-scap_cref_security-data-oval.xml.bz2" xlink:href="https://www.example.com/security/data/oval/oval.xml.bz2"/>
7a6a25
+  </ds:checks>
7a6a25
+</ds:data-stream>
7a6a25
+
7a6a25
+<ds:component id="scap_org.open-scap_comp_test_single_rule.oval.xml" timestamp="2017-06-09T07:07:38">
7a6a25
+<oval_definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:win-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd    http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd   http://oval.mitre.org/XMLSchema/oval-definitions-5#windows windows-definitions-schema.xsd">
7a6a25
+  <generator>
7a6a25
+    <oval:schema_version>5.11</oval:schema_version>
7a6a25
+    <oval:timestamp>2009-01-12T10:41:00-05:00</oval:timestamp>
7a6a25
+  </generator>
7a6a25
+
7a6a25
+  <definitions>
7a6a25
+    <definition class="compliance" id="oval:test-pass:def:1" version="1">
7a6a25
+      <metadata>
7a6a25
+        <title>PASS</title>
7a6a25
+	<description>pass</description>
7a6a25
+      </metadata>
7a6a25
+      <criteria>
7a6a25
+        <criterion comment="PASS test" test_ref="oval:x:tst:1"/>
7a6a25
+      </criteria>
7a6a25
+    </definition>
7a6a25
+  </definitions>
7a6a25
+
7a6a25
+    <tests>
7a6a25
+    <variable_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:tst:1" check="all" comment="always pass" version="1">
7a6a25
+      <object object_ref="oval:x:obj:1"/>
7a6a25
+    </variable_test>
7a6a25
+    </tests>
7a6a25
+
7a6a25
+    <objects>
7a6a25
+    <variable_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:obj:1" version="1" comment="x">
7a6a25
+      <var_ref>oval:x:var:1</var_ref>
7a6a25
+    </variable_object>
7a6a25
+    </objects>
7a6a25
+</oval_definitions>
7a6a25
+</ds:component>
7a6a25
+
7a6a25
+<ds:component id="scap_org.open-scap_comp_test_single_rule.xccdf.xml" timestamp="2017-06-09T09:15:45">
7a6a25
+<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="xccdf_com.example.www_benchmark_dummy" xml:lang="en-US">
7a6a25
+  <status>accepted</status>
7a6a25
+  <version>1.0</version>
7a6a25
+
7a6a25
+  <Profile id="xccdf_com.example.www_profile_test_remote_res">
7a6a25
+    <title>xccdf_test_profile</title>
7a6a25
+    <description>This profile is for testing.</description>
7a6a25
+    <select idref="xccdf_com.example.www_rule_test-pass" selected="true"/>
7a6a25
+    <select idref="xccdf_com.example.www_rule_test-remote_res" selected="true"/>
7a6a25
+  </Profile>
7a6a25
+
7a6a25
+  <Value id="xccdf_com.example.www_value_val1" type="number" operator="equals" interactive="0">
7a6a25
+    <title>test value</title>
7a6a25
+    <description>foo</description>
7a6a25
+    <value selector="bar_1">50</value>
7a6a25
+    <value selector="bar_2">100</value>
7a6a25
+  </Value>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass">
7a6a25
+    <title>This rule always pass</title>
7a6a25
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
7a6a25
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
7a6a25
+    </check>
7a6a25
+  </Rule>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-remote_res">
7a6a25
+    <title>This rule checks remote resource</title>
7a6a25
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5" multi-check="true">
7a6a25
+      <check-content-ref href="security-data-oval.xml.bz2"/>
7a6a25
+    </check>
7a6a25
+  </Rule>
7a6a25
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass2">
7a6a25
+    <title>This rule always pass</title>
7a6a25
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
7a6a25
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
7a6a25
+    </check>
7a6a25
+  </Rule>
7a6a25
+</Benchmark>
7a6a25
+</ds:component>
7a6a25
+</ds:data-stream-collection>
7a6a25
diff --git a/tests/DS/test_ds.sh b/tests/DS/test_ds.sh
7a6a25
index 22cafe6c9..1383ad87a 100755
7a6a25
--- a/tests/DS/test_ds.sh
7a6a25
+++ b/tests/DS/test_ds.sh
7a6a25
@@ -414,6 +414,21 @@ function test_sds_tailoring {
7a6a25
 	rm -f "$result"
7a6a25
 }
7a6a25
 
7a6a25
+function test_ds_continue_without_remote_resources() {
7a6a25
+	local DS="${srcdir}/$1"
7a6a25
+	local PROFILE="$2"
7a6a25
+	local result=$(mktemp)
7a6a25
+
7a6a25
+	$OSCAP xccdf eval --profile "$PROFILE" --results "$result" "$DS"
7a6a25
+
7a6a25
+	assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
7a6a25
+	assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-remote_res"]/result[text()="notchecked"]'
7a6a25
+	assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass2"]/result[text()="pass"]'
7a6a25
+
7a6a25
+	rm -f "$result"
7a6a25
+}
7a6a25
+
7a6a25
+
7a6a25
 # Testing.
7a6a25
 test_init "test_ds.log"
7a6a25
 
7a6a25
@@ -454,6 +469,8 @@ test_run "rds_split_simple" test_rds_split rds_split_simple report-request.xml r
7a6a25
 
7a6a25
 test_run "test_eval_complex" test_eval_complex
7a6a25
 test_run "sds_add_multiple_oval_twice_in_row" sds_add_multiple_twice
7a6a25
+test_run "test_ds_1_2_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.2.ds.xml xccdf_com.example.www_profile_test_remote_res
7a6a25
+test_run "test_ds_1_3_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.3.ds.xml xccdf_com.example.www_profile_test_remote_res
7a6a25
 
7a6a25
 test_exit
7a6a25