| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basename $0 .sh) |
| 8 | |
| 9 | result=$(mktemp -t ${name}.out.XXXXXX) |
| 10 | stderr=$(mktemp -t ${name}.out.XXXXXX) |
| 11 | |
| 12 | $OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml 2> $stderr |
| 13 | |
| 14 | echo "Stderr file = $stderr" |
| 15 | echo "Result file = $result" |
| 16 | [ -f $stderr ]; [ ! -s $stderr ]; rm $stderr |
| 17 | |
| 18 | $OSCAP xccdf validate --skip-schematron $result |
| 19 | |
| 20 | assert_exists 3 '//fix' |
| 21 | assert_exists 3 '//fix/@id' |
| 22 | assert_exists 3 '//Rule/fix' |
| 23 | assert_exists 0 '//rule-result/fix' |
| 24 | assert_exists 1 '//Rule/fix[@id="fix-empty"]' |
| 25 | assert_exists 0 '//rule-result/fix[@id="fix-empty"]' |
| 26 | assert_exists 1 '//Rule/fix[@id="fix-unknown"]' |
| 27 | assert_exists 0 '//rule-result/fix[@id="fix-unknown"]' |
| 28 | assert_exists 1 '//Rule/fix[@id="fix-restrict"]' |
| 29 | assert_exists 0 '//rule-result/fix[@id="fix-restrict"]' |
| 30 | |
| 31 | assert_exists 1 '//fix[@id="fix-empty"]' |
| 32 | assert_exists 1 '//fix[@id="fix-empty"]/@*' |
| 33 | |
| 34 | assert_exists 1 '//fix[@id="fix-unknown"]' |
| 35 | assert_exists 3 '//fix[@id="fix-unknown"]/@*' |
| 36 | assert_exists 1 '//fix[@id="fix-unknown" and @disruption="unknown"]' |
| 37 | assert_exists 1 '//fix[@id="fix-unknown" and @complexity="unknown"]' |
| 38 | assert_exists 0 '//fix[@id="fix-unknown" and @strategy="unknown"]' |
| 39 | |
| 40 | assert_exists 1 '//fix[@id="fix-restrict"]' |
| 41 | assert_exists 4 '//fix[@id="fix-restrict"]/@*' |
| 42 | assert_exists 1 '//fix[@id="fix-restrict" and @disruption="medium"]' |
| 43 | assert_exists 1 '//fix[@id="fix-restrict" and @complexity="high"]' |
| 44 | assert_exists 1 '//fix[@id="fix-restrict" and @strategy="restrict"]' |
| 45 | |
| 46 | rm $result |