Debian Codegraph @

tests/API/XCCDF/unittests/test_fix_instance.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 name=$(basenamescip-shell system . . basename. $0 .sh)
8 result=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
9 stderr=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
10
11 rmscip-shell system . . rm. -f test_file
12
13 $OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
14
15 $OSCAP xccdf validate --skip-schematron $result
16
17 assert_exists 1 '/Benchmark/Rule/fix/instancescip-shell filesystem . . `/Benchmark/Rule/fix/instance`.'
18 assert_exists 3 '//rule-result'
19 assert_exists 2 '//rule-result/instance'
20 assert_exists 1 '//rule-result/instance[text()="a"]'
21 assert_exists 1 '//rule-result/instance[text()="b"]'
22 assert_exists 3 '//rule-result/result[text()="fail"]'
23
24 rmscip-shell system . . rm. $result
25
26 # Remediate
27
28 $OSCAP xccdf remediate --result-id xccdf_org.open-scap_testresult_default-profile --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
29
30 $OSCAP xccdf validate --skip-schematron $result
31
32 assert_exists 1 '/Benchmark/Rule/fix/instancescip-shell filesystem . . `/Benchmark/Rule/fix/instance`.'
33 assert_exists 4 '//rule-result'
34 assert_exists 2 '//rule-result/instance[text()="a"]'
35 assert_exists 2 '//rule-result/instance[text()="b"]'
36 assert_exists 2 '//rule-result/fix'
37 assert_exists 2 '//rule-result/result[text()="fail"]'
38 assert_exists 2 '//rule-result/result[text()="fixed"]'
39
40 rmscip-shell system . . rm. $result
41