| 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 | stderr=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX) |
| 9 | result=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX) |
| 10 | echoscip-shell system . . echo. "Stderr file = $stderr" |
| 11 | echoscip-shell system . . echo. "Result file = $stderr" |
| 12 | rmscip-shell system . . rm. -f test_file |
| 13 | |
| 14 | $OSCAP xccdf remediate --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr |
| 15 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr |
| 16 | [scip-shell system . . `[`. -f test_file ]; rmscip-shell system . . rm. test_file |
| 17 | |
| 18 | assert_exists 1 '//Rule' |
| 19 | assert_exists 1 '//Rule/fix' |
| 20 | assert_exists 1 '//Rule/fix[@system="urn:xccdf:fix:script:python3"]' |
| 21 | assert_exists 0 '//Rule/fix/sub' |
| 22 | assert_exists 3 '//Rule/fix/xhtml:object' |
| 23 | assert_exists 2 '//TestResult' |
| 24 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]' |
| 25 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result' |
| 26 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/result' |
| 27 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/result[text()="fixed"]' |
| 28 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix' |
| 29 | assert_exists 0 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix/sub' |
| 30 | assert_exists 0 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix/object' |
| 31 | assert_exists 0 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix/xhtml:object' |
| 32 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix[contains(text(), "import os")]' |
| 33 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix[contains(text(), "touch('"'"'test_file'"'"')")]' |
| 34 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message' |
| 35 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message[text()="Fix execution completed and returned: 0"]' |
| 36 | |
| 37 | rmscip-shell system . . rm. $result |