Debian Codegraph @

tests/API/XCCDF/parser/test_extensions.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 # Copyright 2018 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # OpenScap XCCDF Module Test Suite.
7 #
8 # Authors:
9 # Peter Vrabec <[email protected]>
10 # Alexander Scheel <[email protected]>
11
12 . $builddir/tests/test_common.sh
13
14 # Test cases.
15
16 function test_known_extension {
17 local INPUT=$1
18
19 output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
20 has_warning=$(echo "$output" | grep -i "Skipping rule")
21
22 return $([ "x$has_warning" == "x" ])
23 }
24
25
26
27 function test_malformed_extension {
28 local INPUT=$1
29
30 output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
31 has_warning=$(echo "$output" | grep -i "Skipping rule that uses OVAL")
32
33 return $([ "x$has_warning" != "x" ])
34 }
35
36
37 function test_unknown_extension {
38 local INPUT=$1
39
40 output=$(bash $builddir/run $builddir/utils/oscap xccdf eval $srcdir/$INPUT 2>&1)
41 has_warning=$(echo "$output" | grep -i "Skipping rule that requires")
42
43 return $([ "x$has_warning" != "x" ])
44 }
45
46 # Testing.
47
48 test_init "test_xccdf_check_extensions.log"
49
50 if [ -z ${CUSTOM_OSCAP+x} ] ; then
51 test_run "known check extension" test_known_extension test_known_extensions.xml
52 test_run "malformed check extension" test_malformed_extension test_malformed_extensions.xml
53 test_run "unknown check extension" test_unknown_extension test_proprietary_extensions.xml
54 fi
55
56 test_exit