@@ -10,13 +10,37 @@ output_dir=`mktemp -d -t oval_details_XXXXXX`
10
10
11
11
# Test cases.
12
12
13
- function test_oval_details {
13
+ function test_oval_details_implicit {
14
+ # Tests if OVAL Details are present in HTML report by default
15
+ # without specifing --oval-results --results (new behavior)
14
16
xccdffile=$srcdir /$1 .xccdf.xml
15
17
resultfile=$output_dir /$1 .result.xml
16
18
reportfile=$output_dir /$1 .report.html
19
+ oval_resultfile=" $1 .oval.xml.result.xml"
20
+ $OSCAP xccdf eval --report $reportfile $xccdffile
21
+ [ -f $reportfile ]
22
+ [ ! -f $resultfile ]
23
+ [ ! -f $oval_resultfile ]
24
+ grep -i $2 $reportfile > /dev/null && grep -i $3 $reportfile > /dev/null
25
+ rm $reportfile
26
+ }
27
+
28
+ function test_oval_details_explicit {
29
+ # Tests if OVAL details are present in HTML report when options
30
+ # --oval-results and --results are explicitely specified
31
+ # (backwards-compatible behavior)
32
+ xccdffile=$srcdir /$1 .xccdf.xml
33
+ resultfile=$output_dir /$1 .result.xml
34
+ reportfile=$output_dir /$1 .report.html
35
+ oval_resultfile=" $1 .oval.xml.result.xml"
17
36
$OSCAP xccdf eval --results $resultfile --oval-results --report $reportfile $xccdffile
18
37
grep -i $2 $reportfile > /dev/null && grep -i $3 $reportfile > /dev/null
19
- rm " $1 .oval.xml.result.xml"
38
+ [ -f $reportfile ]
39
+ [ -f $resultfile ]
40
+ [ -f $oval_resultfile ]
41
+ rm $reportfile
42
+ rm $resultfile
43
+ rm $oval_resultfile
20
44
}
21
45
22
46
# Testing.
@@ -29,16 +53,24 @@ if ! [ -f foo.txt ] ; then
29
53
cp $srcdir /foo.src.txt ./foo.txt
30
54
fi
31
55
32
- test_run " test_oval_details_file_object" test_oval_details file " path.*UID.*permissions" " /dev/null"
33
- test_run " test_oval_details_partition_object" test_oval_details partition " mount point.*device.*uuid" " /"
34
- test_run " test_oval_details_rpminfo_object" test_oval_details rpminfo " name.*release.*version" " rpm"
56
+ test_run " test_oval_details_file_object_implicit" test_oval_details_implicit file " path.*UID.*permissions" " /dev/null"
57
+ test_run " test_oval_details_file_object_explicit" test_oval_details_explicit file " path.*UID.*permissions" " /dev/null"
58
+ test_run " test_oval_details_partition_object_implicit" test_oval_details_implicit partition " mount point.*device.*uuid" " /"
59
+ test_run " test_oval_details_partition_object_explicit" test_oval_details_explicit partition " mount point.*device.*uuid" " /"
60
+ test_run " test_oval_details_rpminfo_object_implicit" test_oval_details_implicit rpminfo " name.*release.*version" " rpm"
61
+ test_run " test_oval_details_rpminfo_object_explicit" test_oval_details_explicit rpminfo " name.*release.*version" " rpm"
35
62
if ! pidof systemd > /dev/null ; then
36
- test_run " test_oval_details_runlevel_object" test_oval_details runlevel " service name.*runlevel" " smartd"
63
+ test_run " test_oval_details_runlevel_object_implicit" test_oval_details_implicit runlevel " service name.*runlevel" " smartd"
64
+ test_run " test_oval_details_runlevel_object_explicit" test_oval_details_explicit runlevel " service name.*runlevel" " smartd"
37
65
fi
38
- test_run " test_oval_details_sysctl_object" test_oval_details sysctl " name.*value" " net\.ipv4\.ip_forward"
39
- test_run " test_oval_details_textfilecontent54_object" test_oval_details textfilecontent54 " path.*content" " foo\.txt.*Hello"
40
- test_run " test_oval_details_variable_object" test_oval_details variable " var ref.*value" " oval:x:var:1.*42"
41
- test_run " test_oval_details_xmlfilecontent_object" test_oval_details xmlfilecontent " filepath.*xpath.*value of" " countries\.xml.*London"
66
+ test_run " test_oval_details_sysctl_object_implicit" test_oval_details_implicit sysctl " name.*value" " net\.ipv4\.ip_forward"
67
+ test_run " test_oval_details_sysctl_object_explicit" test_oval_details_explicit sysctl " name.*value" " net\.ipv4\.ip_forward"
68
+ test_run " test_oval_details_textfilecontent54_object_implicit" test_oval_details_implicit textfilecontent54 " path.*content" " foo\.txt.*Hello"
69
+ test_run " test_oval_details_textfilecontent54_object_explicit" test_oval_details_explicit textfilecontent54 " path.*content" " foo\.txt.*Hello"
70
+ test_run " test_oval_details_variable_object_implicit" test_oval_details_implicit variable " var ref.*value" " oval:x:var:1.*42"
71
+ test_run " test_oval_details_variable_object_explicit" test_oval_details_explicit variable " var ref.*value" " oval:x:var:1.*42"
72
+ test_run " test_oval_details_xmlfilecontent_object_implicit" test_oval_details_implicit xmlfilecontent " filepath.*xpath.*value of" " countries\.xml.*London"
73
+ test_run " test_oval_details_xmlfilecontent_object_explicit" test_oval_details_explicit xmlfilecontent " filepath.*xpath.*value of" " countries\.xml.*London"
42
74
43
75
rm -rf $output_dir
44
76
rm -f ./foo.txt ./countries.xml
0 commit comments