Debian Codegraph @

tests/API/XCCDF/unittests/test_fix_resultid_by_suffix.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2 . $builddir/tests/test_common.sh
3
4 set -e
5 set -o pipefail
6
7 name=$(basename $0 .sh)
8 stderr=$(mktemp -t ${name}.out.XXXXXX)
9 script=$(mktemp -t ${name}.sh.XXXXXX)
10 result=$srcdir/${name}.xml
11 echo "Stderr file = $stderr"
12 echo "Result file = $result"
13 ret=0
14
15 # Should pass, unique TestResult ID suffix
16 $OSCAP xccdf generate fix --result-id standard --output $script $result 2> $stderr
17 # Checks that full result id is used in rule evaluation
18 # grep -Fq xccdf_org.open-scap_testresult_xccdf_moc.elpmaxe.www_profile_standard $script
19
20 # Should pass, because underscore creates unique suffix
21 $OSCAP xccdf generate fix --result-id _common --output $script $result 2> $stderr
22 # Checks that full result id is used in rule evaluation
23 # Will work with script header generation
24 # grep -Fq xccdf_org.open-scap_testresult_xccdf_moc.elpmaxe.www_profile_common $script
25
26 # Should fail, because result with this id suffix does not exist
27 $OSCAP xccdf generate fix --result-id rare --output $script $result 2> $stderr || ret=$?
28 [ $ret -eq 1 ]
29 # Checks that last test does result in no match error
30 # Will work with script header generation
31 grep -Fq "Could not find TestResult/@id=\"rare\"" $stderr
32
33 # Multiple matches should result in failure
34 $OSCAP xccdf generate fix --result-id common --output $script $result 2> $stderr || ret=$?
35 [ $ret -eq 1 ]
36 # Checks that first test does result in multiple match error
37 grep -Fq "Multiple matches found" $stderr
38
39 [ -f $stderr ]; rm $stderr
40 rm $script