Debian Codegraph @

tests/API/OVAL/report_variable_values/all.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 # Check that variables have their values recorded in the OVAL results.
4 # This test verifies that different flavours of variable which are
5 # referenced from various OVAL elements are recorded in the
6 # 'tested_variable' and 'variable_value' elements.
7
8 . $builddir/tests/test_common.sh
9
10 set -e -o pipefail
11
12 function report_variable_values() {
13 name="report_variable_values"
14 defxml=${name}.def.xml
15 varxml=${name}.var.xml
16 resxml=$(mktemp ${name}.res.XXXXXX.xml)
17 stderr=$(mktemp ${name}.stderr.XXXXXX)
18
19 echo "Results file: $resxml"
20 echo "Stderr dump from oscap: $stderr"
21
22 echo "Running eval"
23 $OSCAP oval eval --variables $srcdir/$varxml --results $resxml $srcdir/$defxml > $stderr 2>&1
24
25 echo "Verifying results"
26 result="$resxml"
27 assert_exists 1 '/oval_results'
28 assert_exists 1 '/oval_results/results'
29 assert_exists 1 '/oval_results/results/system'
30 assert_exists 1 '/oval_results/results/system/definitions'
31 assert_exists 1 '/oval_results/results/system/definitions/definition[@result="true"]'
32 assert_exists 1 '/oval_results/results/system/tests'
33 assert_exists 8 '/oval_results/results/system/tests/test'
34
35 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1" and @result="true"]'
36 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item'
37 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable'
38 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
39 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
40
41 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2" and @result="true"]'
42 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item'
43 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable'
44 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
45
46 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3" and @result="true"]'
47 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item'
48 assert_exists 4 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable'
49 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
50 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
51 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
52 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'
53
54 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4" and @result="true"]'
55 assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item'
56 assert_exists 4 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable'
57 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
58 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
59 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'
60 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:4"]'
61
62 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5" and @result="true"]'
63 assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item'
64 assert_exists 5 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable'
65 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
66 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
67 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
68 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'
69 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:4"]'
70
71 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6" and @result="true"]'
72 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item'
73 assert_exists 5 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable'
74 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
75 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
76 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
77 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:5" and text()="4"]'
78 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:5" and text()="5"]'
79
80 assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:7"]'
81
82 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8" and @result="true"]'
83 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_item'
84 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_variable'
85 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
86
87 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9" and @result="true"]'
88 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_item'
89 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_variable'
90 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
91
92 assert_exists 1 '/oval_results/results/system/oval_system_characteristics'
93 assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects'
94 assert_exists 7 '/oval_results/results/system/oval_system_characteristics/collected_objects/object'
95 CO='/oval_results/results/system/oval_system_characteristics/collected_objects'
96
97 assert_exists 1 "$CO"'/object[@id="oval:x:obj:1" and @flag="complete"]'
98 assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/reference[@item_ref]'
99 assert_exists 2 "$CO"'/object[@id="oval:x:obj:1"]/variable_value'
100 assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
101 assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'
102
103 assert_exists 1 "$CO"'/object[@id="oval:x:obj:2" and @flag="complete"]'
104 assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/reference[@item_ref]'
105 assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/variable_value'
106 assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'
107
108 assert_exists 1 "$CO"'/object[@id="oval:x:obj:3" and @flag="complete"]'
109 assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/reference[@item_ref]'
110 assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/variable_value'
111 assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/variable_value[@variable_id="oval:x:var:3" and text()="3"]'
112
113 assert_exists 1 "$CO"'/object[@id="oval:x:obj:4" and @flag="does not exist"]'
114 assert_exists 0 "$CO"'/object[@id="oval:x:obj:4"]/reference[@item_ref]'
115 assert_exists 4 "$CO"'/object[@id="oval:x:obj:4"]/variable_value'
116 assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
117 assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'
118 assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:3" and text()="3"]'
119 assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:4"]'
120
121 assert_exists 0 "$CO"'/object[@id="oval:x:obj:5"]'
122
123 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6" and @flag="complete"]'
124 assert_exists 2 "$CO"'/object[@id="oval:x:obj:6"]/reference[@item_ref]'
125 assert_exists 5 "$CO"'/object[@id="oval:x:obj:6"]/variable_value'
126 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
127 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'
128 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'
129 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:5" and text()="4"]'
130 assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:5" and text()="5"]'
131
132 assert_exists 0 "$CO"'/object[@id="oval:x:obj:7"]'
133
134 assert_exists 1 "$CO"'/object[@id="oval:x:obj:8" and @flag="complete"]'
135 assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/reference[@item_ref]'
136 assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/variable_value'
137 assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'
138
139 assert_exists 1 "$CO"'/object[@id="oval:x:obj:9" and @flag="complete"]'
140 assert_exists 2 "$CO"'/object[@id="oval:x:obj:9"]/reference[@item_ref]'
141 assert_exists 1 "$CO"'/object[@id="oval:x:obj:9"]/variable_value'
142 assert_exists 1 "$CO"'/object[@id="oval:x:obj:9"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'
143
144 rm $resxml
145 rm $stderr
146 }
147
148 test_init report_variable_values.log
149 test_run "Report variable values in OVAL results" report_variable_values
150 test_exit