| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Author: |
| 4 | # Martin Preisler <[email protected]> |
| 5 | |
| 6 | set -e -o pipefail |
| 7 | |
| 8 | . $builddir/tests/test_common.sh |
| 9 | |
| 10 | # Test Cases. |
| 11 | |
| 12 | function test_generate_fix_source { |
| 13 | local fixfile=$(mktemp -t ${name}.out.XXXXXX) |
| 14 | |
| 15 | # all rules (default profile) |
| 16 | $OSCAP xccdf generate fix --output $fixfile "${srcdir}/$1" |
| 17 | grep -q remediation_rule_applicable_pass $fixfile |
| 18 | grep -q remediation_rule_applicable_fail $fixfile |
| 19 | grep -q remediation_rule_notapplicable $fixfile |
| 20 | rm $fixfile |
| 21 | |
| 22 | # selected profile |
| 23 | $OSCAP xccdf generate fix --output $fixfile --profile xccdf_org.ssgproject.content_profile_test "${srcdir}/$1" |
| 24 | grep -qv remediation_rule_applicable_pass $fixfile |
| 25 | grep -q remediation_rule_applicable_fail $fixfile |
| 26 | grep -q remediation_rule_notapplicable $fixfile |
| 27 | rm $fixfile |
| 28 | } |
| 29 | |
| 30 | # Testing. |
| 31 | test_init |
| 32 | |
| 33 | test_run "generate_fix_cpe_source" test_generate_fix_source eval_cpe/sds.xml |
| 34 | |
| 35 | test_exit |