Debian Codegraph @

tests/API/XCCDF/guide/profile.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 # Copyright 2012 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5
6 set -o pipefail
7
8 . $builddir/tests/test_common.sh
9
10
11 function test_generate_guide_profile {
12 local INPUT=$srcdir/$1
13 local PROFILE=$2
14 local EXPECTED_CONTENT=$3
15 local UNEXPECTED_CONTENT=$4
16
17 local GENERATED_CONTENT=$($OSCAP xccdf generate guide --profile $PROFILE "$INPUT")
18 exit_code=0
19 if [ "$?" != "0" ]; then
20 return 1
21 fi
22
23 echo "$GENERATED_CONTENT" | grep "$EXPECTED_CONTENT"
24 if [ "$?" != "0" ]; then
25 echo "Generated content does not contain '$EXPECTED_CONTENT'!"
26 echo "Generated content:"
27 echo "$GENERATED_CONTENT"
28 exit_code=1
29 fi
30
31 echo "$GENERATED_CONTENT" | grep "$UNEXPECTED_CONTENT"
32 if [ "$?" == "0" ]; then
33 echo "Generated content does contain '$UNEXPECTED_CONTENT', but it should not!"
34 echo "Generated content:"
35 echo "$GENERATED_CONTENT"
36 exit_code=1
37 fi
38
39 return $exit_code
40 }
41
42
43 # Testing.
44
45 test_init "test_api_xccdf_guide_profile.log"
46
47 test_run "test_api_xccdf_guide_profile_value_selector_xccdf11" test_generate_guide_profile content-profile-xccdf11.xml default off_value bflmpsvz
48 test_run "test_api_xccdf_guide_profile_default_xccdf11" test_generate_guide_profile content-profile-xccdf11.xml default rule_1_title rule_2_title
49 test_run "test_api_xccdf_guide_profile_selects_xccdf11" test_generate_guide_profile content-profile-xccdf11.xml alternative rule_2_title rule_1_title
50
51 test_exit