Blame SOURCES/openscap-1.3.4-add_compression_test-PR_1564.patch

4def80
From 12ccadd9f9cd30143b3af6feced58f8da636e9d2 Mon Sep 17 00:00:00 2001
4def80
From: Evgeny Kolesnikov <ekolesni@redhat.com>
4def80
Date: Mon, 20 Jul 2020 07:45:05 +0200
4def80
Subject: [PATCH] Add test for cURL "Accept-Encoding" header
4def80
4def80
---
4def80
 tests/CMakeLists.txt             |  1 +
4def80
 tests/curl/CMakeLists.txt        |  1 +
4def80
 tests/curl/ds.xml                | 99 ++++++++++++++++++++++++++++++++
4def80
 tests/curl/test_curl_encoding.sh | 23 ++++++++
4def80
 4 files changed, 124 insertions(+)
4def80
 create mode 100644 tests/curl/CMakeLists.txt
4def80
 create mode 100644 tests/curl/ds.xml
4def80
 create mode 100755 tests/curl/test_curl_encoding.sh
4def80
4def80
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
4def80
index b7ca6cd79..6948cd260 100644
4def80
--- a/tests/CMakeLists.txt
4def80
+++ b/tests/CMakeLists.txt
4def80
@@ -26,6 +26,7 @@ add_subdirectory("API")
4def80
 add_subdirectory("bindings")
4def80
 add_subdirectory("bz2")
4def80
 add_subdirectory("codestyle")
4def80
+add_subdirectory("curl")
4def80
 add_subdirectory("CPE")
4def80
 add_subdirectory("DS")
4def80
 add_subdirectory("mitre")
4def80
diff --git a/tests/curl/CMakeLists.txt b/tests/curl/CMakeLists.txt
4def80
new file mode 100644
4def80
index 000000000..9c3d90d74
4def80
--- /dev/null
4def80
+++ b/tests/curl/CMakeLists.txt
4def80
@@ -0,0 +1 @@
4def80
+add_oscap_test("test_curl_encoding.sh")
4def80
diff --git a/tests/curl/ds.xml b/tests/curl/ds.xml
4def80
new file mode 100644
4def80
index 000000000..f33cb475d
4def80
--- /dev/null
4def80
+++ b/tests/curl/ds.xml
4def80
@@ -0,0 +1,99 @@
4def80
+
4def80
+<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">
4def80
+<ds:data-stream id="scap_org.open-scap_datastream_from_xccdf_test_single_rule.xccdf.xml" scap-version="1.3" use-case="OTHER">
4def80
+  <ds:checklists>
4def80
+    <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">
4def80
+      <cat:catalog>
4def80
+        <cat:uri name="test_single_rule.oval.xml" uri="#scap_org.open-scap_cref_test_single_rule.oval.xml"/>
4def80
+        <cat:uri name="security-data-oval.xml.bz2" uri="#scap_org.open-scap_cref_security-data-oval.xml.bz2"/>
4def80
+      </cat:catalog>
4def80
+    </ds:component-ref>
4def80
+  </ds:checklists>
4def80
+  <ds:checks>
4def80
+    <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"/>
4def80
+
4def80
+    <ds:component-ref id="scap_org.open-scap_cref_security-data-oval.xml.bz2" xlink:href="https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml"/>
4def80
+-->
4def80
+    <ds:component-ref id="scap_org.open-scap_cref_security-data-oval.xml.bz2" xlink:href="https://github.com/"/>
4def80
+  </ds:checks>
4def80
+</ds:data-stream>
4def80
+
4def80
+<ds:component id="scap_org.open-scap_comp_test_single_rule.oval.xml" timestamp="2017-06-09T07:07:38">
4def80
+<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">
4def80
+  <generator>
4def80
+    <oval:schema_version>5.11</oval:schema_version>
4def80
+    <oval:timestamp>2009-01-12T10:41:00-05:00</oval:timestamp>
4def80
+  </generator>
4def80
+
4def80
+  <definitions>
4def80
+    <definition class="compliance" id="oval:test-pass:def:1" version="1">
4def80
+      <metadata>
4def80
+        <title>PASS</title>
4def80
+        <description>pass</description>
4def80
+      </metadata>
4def80
+      <criteria>
4def80
+        <criterion comment="PASS test" test_ref="oval:x:tst:1"/>
4def80
+      </criteria>
4def80
+    </definition>
4def80
+  </definitions>
4def80
+
4def80
+    <tests>
4def80
+    <variable_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:tst:1" check="all" comment="always pass" version="1">
4def80
+      <object object_ref="oval:x:obj:1"/>
4def80
+    </variable_test>
4def80
+    </tests>
4def80
+
4def80
+    <objects>
4def80
+    <variable_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:obj:1" version="1" comment="x">
4def80
+      <var_ref>oval:x:var:1</var_ref>
4def80
+    </variable_object>
4def80
+    </objects>
4def80
+
4def80
+    <variables>
4def80
+      <constant_variable id="oval:x:var:1" version="1" comment="x" datatype="int">
4def80
+        <value>100</value>
4def80
+      </constant_variable>
4def80
+    </variables>
4def80
+
4def80
+</oval_definitions>
4def80
+</ds:component>
4def80
+
4def80
+<ds:component id="scap_org.open-scap_comp_test_single_rule.xccdf.xml" timestamp="2017-06-09T09:15:45">
4def80
+<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">
4def80
+  <status>accepted</status>
4def80
+  <version>1.0</version>
4def80
+
4def80
+  <Profile id="xccdf_com.example.www_profile_test_remote_res">
4def80
+    <title>xccdf_test_profile</title>
4def80
+    <description>This profile is for testing.</description>
4def80
+    <select idref="xccdf_com.example.www_rule_test-pass" selected="true"/>
4def80
+    <select idref="xccdf_com.example.www_rule_test-remote_res" selected="true"/>
4def80
+  </Profile>
4def80
+
4def80
+  <Value id="xccdf_com.example.www_value_val1" type="number" operator="equals" interactive="0">
4def80
+    <title>test value</title>
4def80
+    <description>foo</description>
4def80
+    <value selector="bar_1">50</value>
4def80
+    <value selector="bar_2">100</value>
4def80
+  </Value>
4def80
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass">
4def80
+    <title>This rule always pass</title>
4def80
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
4def80
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
4def80
+    </check>
4def80
+  </Rule>
4def80
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-remote_res">
4def80
+    <title>This rule checks remote resource</title>
4def80
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5" multi-check="true">
4def80
+      <check-content-ref href="security-data-oval.xml.bz2"/>
4def80
+    </check>
4def80
+  </Rule>
4def80
+  <Rule selected="true" id="xccdf_com.example.www_rule_test-pass2">
4def80
+    <title>This rule always pass</title>
4def80
+    <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
4def80
+      <check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
4def80
+    </check>
4def80
+  </Rule>
4def80
+</Benchmark>
4def80
+</ds:component>
4def80
+</ds:data-stream-collection>
4def80
diff --git a/tests/curl/test_curl_encoding.sh b/tests/curl/test_curl_encoding.sh
4def80
new file mode 100755
4def80
index 000000000..6d82f9569
4def80
--- /dev/null
4def80
+++ b/tests/curl/test_curl_encoding.sh
4def80
@@ -0,0 +1,23 @@
4def80
+#!/bin/bash
4def80
+
4def80
+set -e -o pipefail
4def80
+
4def80
+. $builddir/tests/test_common.sh
4def80
+
4def80
+function curl_accept_encoding {
4def80
+	local DF="${srcdir}/ds.xml"
4def80
+	local RF="results.xml"
4def80
+	local LOG="verbose.log"
4def80
+
4def80
+	$OSCAP xccdf --verbose=DEVEL eval --fetch-remote-resources --results $RF $DF 2>$LOG || echo "OK"
4def80
+
4def80
+	grep -P "Accept-Encoding.*gzip" $LOG
4def80
+
4def80
+	return 0
4def80
+}
4def80
+
4def80
+test_init
4def80
+
4def80
+test_run "cURL: Accept-Encoding" curl_accept_encoding
4def80
+
4def80
+test_exit