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

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