Skip to content

Commit a793916

Browse files
authored
Merge pull request #1341 from ggbecker/improve-test-sds-detect-version
Improve SDS detect version test to cover future releases.
2 parents 1d46f2d + 9eca41e commit a793916

File tree

4 files changed

+18
-58
lines changed

4 files changed

+18
-58
lines changed

tests/DS/sds_detect_version/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ CLEANFILES = *.log *.results oscap_debug.log.*
33

44
TESTS_ENVIRONMENT= \
55
builddir=$(top_builddir) \
6+
top_srcdir=$(top_srcdir) \
67
OSCAP_FULL_VALIDATION=1 \
78
$(top_builddir)/run
89

910
TESTS = test_detect_version.sh
1011

1112
EXTRA_DIST = test_detect_version.sh \
12-
scap-1.2-ds.xml \
13-
scap-1.3-ds.xml
13+
scap-ds.xml

tests/DS/sds_detect_version/scap-1.2-ds.xml

Lines changed: 0 additions & 51 deletions
This file was deleted.

tests/DS/sds_detect_version/scap-1.3-ds.xml renamed to tests/DS/sds_detect_version/scap-ds.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
2-
<ns0:data-stream-collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ns0="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ns1="http://www.w3.org/1999/xlink" xmlns:ns10="http://checklists.nist.gov/xccdf/1.2" xmlns:ns13="http://cpe.mitre.org/dictionary/2.0" xmlns:ns2="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:ns3="http://scap.nist.gov/schema/ocil/2.0" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns6="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns7="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns8="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns9="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="scap_org.open-scap_collection_from_xccdf_ssg-rhel8-xccdf-1.2.xml" schematron-version="1.3">
3-
<ns0:data-stream id="scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml" scap-version="1.3" use-case="OTHER">
2+
<ns0:data-stream-collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ns0="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ns1="http://www.w3.org/1999/xlink" xmlns:ns10="http://checklists.nist.gov/xccdf/1.2" xmlns:ns13="http://cpe.mitre.org/dictionary/2.0" xmlns:ns2="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:ns3="http://scap.nist.gov/schema/ocil/2.0" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns6="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns7="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns8="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns9="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="scap_org.open-scap_collection_from_xccdf_ssg-rhel8-xccdf-1.2.xml" schematron-version="X.X">
3+
<ns0:data-stream id="scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml" scap-version="X.X" use-case="OTHER">
44
<ns0:checks>
55
<ns0:component-ref id="scap_org.open-scap_cref_ssg-rhel8-oval.xml" ns1:href="#scap_org.open-scap_comp_ssg-rhel8-oval.xml"/>
66
</ns0:checks>

tests/DS/sds_detect_version/test_detect_version.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,27 @@
1212

1313
set -e -o pipefail
1414

15+
echo $srcdir
16+
1517
function test_oscap_info {
1618
version="$1"
1719
stdout="$(mktemp)"
1820
stderr="$(mktemp)"
19-
$OSCAP info $srcdir/scap-$version-ds.xml > $stdout 2> $stderr
21+
ds="$(mktemp)"
22+
cp $srcdir/scap-ds.xml $ds
23+
sed -i "s/X.X/${version}/g" $ds
24+
25+
$OSCAP info $ds > $stdout 2> $stderr
2026
[ ! -s $stderr ]
2127
grep -q "Version: $version" $stdout
2228
rm $stdout
2329
rm $stderr
30+
rm $ds
2431
}
2532

26-
test_oscap_info "1.2"
27-
test_oscap_info "1.3"
33+
SDS=$(find $top_srcdir/schemas/sds -maxdepth 1 -mindepth 1 -type d -printf '%f\n')
34+
35+
for sds_version in $SDS
36+
do
37+
test_oscap_info $sds_version
38+
done

0 commit comments

Comments
 (0)