| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | . $builddir/tests/test_common.sh |
| 4 | set -e -o pipefail |
| 5 | |
| 6 | # both XCCDF and SDS schematrons find only warnings but not errors |
| 7 | output="$(mktemp)" |
| 8 | $OSCAP xccdf validate "$srcdir/simple_ds.xml" >"$output" |
| 9 | [ $? = 0 ] |
| 10 | grep -q "Schematron validation of OVAL Definition component 'test_single_rule.oval.xml': PASS" "$output" |
| 11 | grep -q "Schematron validation of XCCDF Checklist component 'scap_org.open-scap_cref_test_single_rule.xccdf.xml': PASS" "$output" |
| 12 | grep -q "Global schematron validation using the source data stream schematron: PASS" $output |
| 13 | grep -q "Complete result of schematron validation of '$srcdir/simple_ds.xml': PASS" $output |
| 14 | rm -f "$output" |
| 15 | |
| 16 | # XCCDF schematron reports an error |
| 17 | output="$(mktemp)" |
| 18 | stderr="$(mktemp)" |
| 19 | $OSCAP xccdf validate "$srcdir/simple_ds_xccdf_schematron_error.xml" >"$output" 2>"$stderr" || ret=$? |
| 20 | [ $ret = 2 ] |
| 21 | grep -q "Error: The given @idref attribute 'xccdf_com.example.www_rule_test-pass2' must match a the @id or @cluster-id attributes of a 'Rule' or 'Group' element. See the XCCDF 1.2.1 specification, Section 6.5.3." $output |
| 22 | grep -q "Schematron validation of OVAL Definition component 'test_single_rule.oval.xml': PASS" "$output" |
| 23 | grep -q "Schematron validation of XCCDF Checklist component 'scap_org.open-scap_cref_test_single_rule.xccdf.xml': FAIL" "$output" |
| 24 | grep -q "Global schematron validation using the source data stream schematron: PASS" $output |
| 25 | grep -q "Complete result of schematron validation of '$srcdir/simple_ds_xccdf_schematron_error.xml': FAIL" $output |
| 26 | grep -q "OpenSCAP Error: Invalid SCAP Source Datastream (1.3) content in $srcdir/simple_ds_xccdf_schematron_error.xml" "$stderr" |
| 27 | rm -f "$output" |
| 28 | rm -f "$stderr" |