Debian Codegraph @

tests/API/XCCDF/unittests/test_remediation_subs_plain_text_empty.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 # First make sure that this OVAL fails, then scan again with --remediate
13 $OSCAP xccdf eval --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
14 catscip-shell system . . cat. $stderr
15 [scip-shell system . . `[`. $ret -eq 2 ]
16
17 echoscip-shell system . . echo. "Stderr file = $stderr"
18 echoscip-shell system . . echo. "Result file = $result"
19 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
20
21 $OSCAP xccdf validate --skip-schematron $result
22
23 assert_exists 1 '/Benchmark/plain-textscip-shell filesystem . . `/Benchmark/plain-text`.'
24 assert_exists 1 '/Benchmark/Rulescip-shell filesystem . . `/Benchmark/Rule`.'
25 assert_exists 1 '/Benchmark/Rule/fixscip-shell filesystem . . `/Benchmark/Rule/fix`.'
26 assert_exists 2 '/Benchmark/Rule/fix/subscip-shell filesystem . . `/Benchmark/Rule/fix/sub`.'
27 assert_exists 1 '//rule-result'
28 assert_exists 1 '//rule-result/result'
29 assert_exists 1 '//rule-result/result[text()="fail"]'
30 assert_exists 0 '//rule-result/fix'
31 assert_exists 1 '//score'
32 assert_exists 1 '//score[text()="0.000000"]'
33 :> $result
34
35 $OSCAP xccdf eval --remediate --results $result $srcdir/${name}.xccdf.xml 2> $stderr
36 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr
37
38 $OSCAP xccdf validate --skip-schematron $result
39
40 assert_exists 1 '/Benchmark/plain-textscip-shell filesystem . . `/Benchmark/plain-text`.'
41 assert_exists 1 '/Benchmark/Rulescip-shell filesystem . . `/Benchmark/Rule`.'
42 assert_exists 1 '/Benchmark/Rule/fixscip-shell filesystem . . `/Benchmark/Rule/fix`.'
43 assert_exists 2 '/Benchmark/Rule/fix/subscip-shell filesystem . . `/Benchmark/Rule/fix/sub`.'
44 assert_exists 1 '//rule-result'
45 assert_exists 1 '//rule-result/result'
46 assert_exists 1 '//rule-result/result[text()="fixed"]'
47 assert_exists 1 '//rule-result/fix'
48 assert_exists 1 '//rule-result/fix[@system="urn:xccdf:fix:script:sh"]'
49 assert_exists 1 '//rule-result/fix[contains(text(), " touch test_file")]'
50 assert_exists 1 '//rule-result/fix[contains(text(), " chmod a-x test_file")]'
51 assert_exists 0 '//rule-result/fix/sub'
52 assert_exists 1 '//rule-result/message'
53 assert_exists 1 '//rule-result/message[@severity="info"]'
54 assert_exists 1 '//rule-result/message[text()="Fix execution completed and returned: 0"]'
55 assert_exists 1 '//score'
56 assert_exists 1 '//score[text()="100.000000"]'
57
58 rmscip-shell system . . rm. test_file
59 rmscip-shell system . . rm. $result