| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | touch not_executable |
| 7 | |
| 8 | name=$(basename $0 .sh) |
| 9 | |
| 10 | for args in "" "--profile xccdf_moc.elpmaxe.www_profile_1"; do |
| 11 | result=$(mktemp -t ${name}.out.XXXXXX) |
| 12 | stderr=$(mktemp -t ${name}.out.XXXXXX) |
| 13 | # If an <xccdf:Rule> contains an <xccdf:complex-check>, then the benchmark consumer MUST process it |
| 14 | # and MUST ignore any <xccdf:check> elements that are also contained by the <xccdf:Rule>. |
| 15 | $OSCAP xccdf eval --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr |
| 16 | |
| 17 | echo "Stderr file = $stderr" |
| 18 | echo "Result file = $result" |
| 19 | [ -f $stderr ]; [ ! -s $stderr ]; rm $stderr |
| 20 | |
| 21 | $OSCAP xccdf validate --skip-schematron $result || [ $? == 2 ] |
| 22 | |
| 23 | assert_exists 1 '//rule-result' |
| 24 | assert_exists 1 '//rule-result/result[text()="pass"]' |
| 25 | assert_exists 1 '//rule-result[not(check)]' |
| 26 | assert_exists 1 '//rule-result/complex-check' |
| 27 | assert_exists 1 '//rule-result/complex-check/check' |
| 28 | assert_exists 1 '//rule-result/complex-check/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]' |
| 29 | assert_exists 1 '//rule-result/complex-check/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]/check-content-ref' |
| 30 | assert_exists 1 '//rule-result/complex-check/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]/check-content-ref[@name="oval:moc.elpmaxe.www:def:1"]' |
| 31 | assert_exists 1 '//rule-result/complex-check/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]/check-content-ref[@href="test_xccdf_check_content_ref_without_name_attr.oval.xml"]' |
| 32 | assert_exists 1 '//Rule/complex-check[not(@system)]' |
| 33 | assert_exists 1 '//rule-result/complex-check[not(@system)]' |
| 34 | assert_exists 1 '//Rule/complex-check[@operator="AND"]' |
| 35 | assert_exists 1 '//rule-result/complex-check[@operator="AND"]' |
| 36 | rm $result |
| 37 | done |
| 38 | |
| 39 | rm not_executable |