Debian Codegraph @

tests/API/XCCDF/unittests/test_xccdf_check_multi_check2.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 . $builddir/tests/test_common.sh
3
4 set -e
5 set -o pipefail
6
7 touchscip-shell system . . touch. not_executable
8
9 name=$(basenamescip-shell system . . basename. $0 .sh)
10
11 result=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
12 stdout=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
13 stderr=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
14
15 $OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml > $stdout 2> $stderr || [scip-shell system . . `[`. $? == 2 ]
16
17 echoscip-shell system . . echo. "Stdout file = $stdout"
18 echoscip-shell system . . echo. "Stderr file = $stderr"
19 echoscip-shell system . . echo. "Result file = $result"
20 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr
21 grepscip-shell system . . grep. '^Result.*pass$' $stdout
22 grepscip-shell system . . grep. '^Result.*fail$' $stdout
23 [scip-shell system . . `[`. $(grepscip-shell system . . grep. -c '^Rule.*xccdf_moc.elpmaxe.www_rule_1' $stdout) == 2 ]
24 [scip-shell system . . `[`. $(grepscip-shell system . . grep. -c '^Title.*The only rule in this benchmark' $stdout) == 2 ]
25 grepscip-shell system . . grep. '^OVAL Definition ID.*oval:moc.elpmaxe.www:def:1$' $stdout
26 grepscip-shell system . . grep. '^OVAL Definition Title.*DEFINITION_1_TITLE_EXPECTED_PASS$' $stdout
27 grepscip-shell system . . grep. '^OVAL Definition ID.*oval:moc.elpmaxe.www:def:2$' $stdout
28 grepscip-shell system . . grep. '^OVAL Definition Title.*DEFINITION_2_TITLE_EXPECTED_FAIL$' $stdout
29 rmscip-shell system . . rm. $stdout
30
31 $OSCAP xccdf validate --skip-schematron $result
32
33 assert_exists 1 '//Rule[@id="xccdf_moc.elpmaxe.www_rule_1"]/check[@multi-check="true"]'
34 assert_exists 1 '//check-content-ref[not(@name)]'
35 assert_exists 2 '//rule-result'
36 assert_exists 2 '//rule-result[@idref="xccdf_moc.elpmaxe.www_rule_1"]'
37 assert_exists 1 '//rule-result[result/text()="fail"]'
38 assert_exists 1 '//rule-result[result/text()="pass"]'
39 assert_exists 2 '//rule-result/check'
40 assert_exists 2 '//rule-result/check[@multi-check="true"]'
41 assert_exists 2 '//rule-result/check[@system="http://oval.mitre.org/XMLSchema/oval-definitions-5"]'
42 assert_exists 2 '//rule-result/check/check-content-ref'
43 assert_exists 2 '//rule-result/check/check-content-ref[@href="test_xccdf_check_content_ref_without_name_attr.oval.xml"]'
44 assert_exists 1 '//rule-result/check/check-content-ref[@name="oval:moc.elpmaxe.www:def:2"]'
45 assert_exists 1 '//rule-result[result/text()="fail"]/check/check-content-ref[@name="oval:moc.elpmaxe.www:def:2"]'
46 assert_exists 1 '//rule-result/check/check-content-ref[@name="oval:moc.elpmaxe.www:def:1"]'
47 assert_exists 1 '//rule-result[result/text()="pass"]/check/check-content-ref[@name="oval:moc.elpmaxe.www:def:1"]'
48 rmscip-shell system . . rm. $result
49 rmscip-shell system . . rm. not_executable