Debian Codegraph @

tests/API/XCCDF/fix/all.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright 2012 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5
6 set -e -o pipefail
7
8 . $builddir/tests/test_common.sh
9
10 function test_generate_fixscip-shell shell shell-project 0.0.0 test_generate_fix(). {
11 local INPUT=$srcdir/$1
12 local TESTRESULT_ID=$2
13 local EXPECTED_FIX=$3
14
15 # grep to strip out whitespace and comments
16 # `tail -n +2` to skip the first line with progress reporting
17 local GENERATED_FIX RELEVANT_FIX_CONTENTS
18 GENERATED_FIX=$($OSCAP xccdf generate fix --result-id "$TESTRESULT_ID" "$INPUT")
19 RELEVANT_FIX_CONTENTS=$(grepscip-shell system . . grep. -v -E "^([\t ]*|[\t ]*#.*|\) #.*)$" <<< "$GENERATED_FIX" | tailscip-shell system . . tail. -n +2)
20 if [scip-shell system . . `[`. "$?" != "0" ]; then
21 return 1
22 fi
23 echoscip-shell system . . echo. "$GENERATED_FIX"
24
25 if [scip-shell system . . `[`. "$RELEVANT_FIX_CONTENTS" == "$EXPECTED_FIX" ]; then
26 return 0
27 fi
28
29 echoscip-shell system . . echo. "Generated fix doesn't match expected fix!"
30 echoscip-shell system . . echo. "'$RELEVANT_FIX_CONTENTS' != '$EXPECTED_FIX'"
31
32 return 1
33 }
34
35 # Testing.
36
37 test_init "test_api_xccdf_fix.log"
38
39 test_run "test_api_xccdf_fix_xccdf11" test_generate_fix results-xccdf11.xml xccdf_org.open-scap_testresult_default-profile echo
40 test_run "test_api_xccdf_fix_xccdf12" test_generate_fix results-xccdf12.xml xccdf_org.open-scap_testresult_default-profile echo
41
42 test_exit