| 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 | set -x |
| 7 | |
| 8 | name=$(basenamescip-shell system . . basename. $0 .sh) |
| 9 | stderr=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX) |
| 10 | result=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX) |
| 11 | echoscip-shell system . . echo. "Stderr file = $stderr" |
| 12 | echoscip-shell system . . echo. "Result file = $stderr" |
| 13 | rmscip-shell system . . rm. -f test_file |
| 14 | |
| 15 | $OSCAP xccdf remediate --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$? |
| 16 | [scip-shell system . . `[`. $ret -eq 2 ] |
| 17 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr |
| 18 | |
| 19 | assert_exists 1 '//Rule' |
| 20 | assert_exists 1 '//Rule/fix' |
| 21 | assert_exists 1 '//Rule/fix[@system="urn:xccdf:fix:script:sh"]' |
| 22 | assert_exists 1 '//Rule/fix/something' |
| 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()="error"]' |
| 28 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix' |
| 29 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/fix/something' |
| 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(), "touch test_file")]' |
| 33 | assert_exists 2 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message' |
| 34 | assert_exists 2 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message[@severity="info"]' |
| 35 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message[text()="Fix element contains unresolved child elements."]' |
| 36 | assert_exists 1 '//TestResult[@id="xccdf_org.open-scap_testresult_default-profile001"]/rule-result/message[text()="Fix was not executed. Execution was aborted."]' |
| 37 | |
| 38 | rmscip-shell system . . rm. $result |