Debian Codegraph @

tests/API/XCCDF/unittests/test_xccdf_check_processing_invalid_content_refs.sh

raw symbols SCIP
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 stdout=$(mktemp -t ${name}.out.XXXXXX)
11 stderr=$(mktemp -t ${name}.out.XXXXXX)
12
13 $OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml > $stdout 2> $stderr
14
15 echo "Stdout file = $stdout"
16 echo "Stderr file = $stderr"
17 echo "Result file = $result"
18 [ -f $stderr ]; [ "`cat $stderr`" == "WARNING: Skipping $srcdir/nonexistent-file file which is referenced from XCCDF content" ]; rm $stderr
19 grep '^Result.*notchecked$' $stdout
20 rm $stdout
21
22 $OSCAP xccdf validate --skip-schematron $result
23
24 assert_exists 1 '//Rule[@id="xccdf_moc.elpmaxe.www_rule_1"]/check[@multi-check="true"]'
25 assert_exists 2 '//check-content-ref[not(@name)]'
26 assert_exists 1 '//rule-result'
27 assert_exists 1 '//rule-result[@idref="xccdf_moc.elpmaxe.www_rule_1"]'
28 assert_exists 1 '//rule-result[result/text()="notchecked"]'
29 assert_exists 1 '//rule-result/check'
30 assert_exists 1 '//rule-result/check[@multi-check="true"]'
31 assert_exists 1 '//rule-result/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]'
32 assert_exists 1 '//rule-result/check/check-content-ref[@href="test_xccdf_check_content_ref_without_name_attr.oval.xml" and @name="nonexistent"]'
33 assert_exists 1 '//rule-result/check/check-content-ref[@href="nonexistent-file" and @name="x"]'
34 assert_exists 1 '//rule-result/check/check-content-ref[@href="oval_without_definitions.oval.xml" and @name="nonexistent"]'
35 assert_exists 1 '//rule-result/check/check-content-ref[@href="nonexistent-file" and not(@name)]'
36 assert_exists 1 '//rule-result/message/@*'
37 assert_exists 1 '//rule-result/message[@severity="info"]'
38 assert_exists 1 '//rule-result/message[text()="None of the check-content-ref elements was resolvable."]'
39 assert_exists 1 '/Benchmark/TestResult/score'
40 assert_exists 2 '/Benchmark/TestResult/score/@*'
41 assert_exists 1 '/Benchmark/TestResult/score[@maximum="100.000000"]'
42 assert_exists 1 '/Benchmark/TestResult/score[text()="0.000000"]'
43
44 rm $result