Skip to content

Commit 68289f5

Browse files
committed
Split tests by features of yamlpath
1 parent 9af6e7b commit 68289f5

File tree

5 files changed

+141
-51
lines changed

5 files changed

+141
-51
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
if(ENABLE_PROBES_INDEPENDENT)
2-
add_oscap_test("test_probes_yamlfilecontent.sh")
2+
add_oscap_test("test_probes_yamlfilecontent_key.sh")
3+
add_oscap_test("test_probes_yamlfilecontent_array.sh")
34
endif()
45

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
. $builddir/tests/test_common.sh
4+
5+
function test_probes_yamlfilecontent_array {
6+
7+
probecheck "yamlfilecontent" || return 255
8+
9+
local ret_val=0;
10+
local DF="${srcdir}/test_probes_yamlfilecontent_array.xml"
11+
local RF="results.xml"
12+
13+
[ -f $RF ] && rm -f $RF
14+
15+
cp "${srcdir}/openshift-logging.yaml" /tmp
16+
17+
local YAML_FILE="/tmp/openshift-logging.yaml"
18+
19+
$OSCAP oval eval --results $RF $DF
20+
21+
if [ -f $RF ]; then
22+
verify_results "def" $DF $RF 2 && verify_results "tst" $DF $RF 3
23+
ret_val=$?
24+
else
25+
ret_val=1
26+
fi
27+
28+
rm -f $YAML_FILE
29+
30+
return $ret_val
31+
}
32+
33+
test_probes_yamlfilecontent_array

tests/probes/yamlfilecontent/test_probes_yamlfilecontent.xml renamed to tests/probes/yamlfilecontent/test_probes_yamlfilecontent_array.xml

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
<description></description>
1717
</metadata>
1818
<criteria operator="AND">
19-
<criterion comment="get_root_scalar" test_ref="oval:0:tst:1"/>
20-
<criterion comment="get_nested_scalar" test_ref="oval:0:tst:2"/>
21-
<criterion comment="filtered_get" test_ref="oval:0:tst:3"/>
22-
<criterion comment="filtered_get_multiple" test_ref="oval:0:tst:4"/>
19+
<criterion comment="get_indexed_array" test_ref="oval:0:tst:1"/>
20+
<criterion comment="get_range_array" test_ref="oval:0:tst:2"/>
2321
</criteria>
2422
</definition>
2523

@@ -29,7 +27,7 @@
2927
<description></description>
3028
</metadata>
3129
<criteria operator="AND">
32-
<criterion comment="non_scalar_get" test_ref="oval:0:tst:5"/>
30+
<criterion comment="get_non_scalar_array" test_ref="oval:0:tst:3"/>
3331
</criteria>
3432
</definition>
3533

@@ -47,49 +45,27 @@
4745
<ind-def:state state_ref="oval:0:ste:2"/>
4846
</ind-def:yamlfilecontent_test>
4947

50-
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:3" check="all" comment="true">
48+
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:3" check="all" comment="error">
5149
<ind-def:object object_ref="oval:0:obj:3"/>
52-
<ind-def:state state_ref="oval:0:ste:3"/>
53-
</ind-def:yamlfilecontent_test>
54-
55-
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:4" check="all" comment="true">
56-
<ind-def:object object_ref="oval:0:obj:4"/>
57-
<ind-def:state state_ref="oval:0:ste:4"/>
58-
</ind-def:yamlfilecontent_test>
59-
60-
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:5" check="all" comment="error">
61-
<ind-def:object object_ref="oval:0:obj:5"/>
6250
</ind-def:yamlfilecontent_test>
6351

6452
</tests>
6553

6654
<objects>
6755

6856
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:1">
69-
<ind-def:path>/tmp</ind-def:path>
70-
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
71-
<ind-def:yamlpath>.kind</ind-def:yamlpath>
72-
</ind-def:yamlfilecontent_object>
73-
74-
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:2">
75-
<ind-def:path>/tmp</ind-def:path>
76-
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
77-
<ind-def:yamlpath>.metadata.namespace</ind-def:yamlpath>
78-
</ind-def:yamlfilecontent_object>
79-
80-
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:3">
8157
<ind-def:path>/tmp</ind-def:path>
8258
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
8359
<ind-def:yamlpath>.spec.outputs[2].name</ind-def:yamlpath>
8460
</ind-def:yamlfilecontent_object>
8561

86-
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:4">
62+
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:2">
8763
<ind-def:path>/tmp</ind-def:path>
8864
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
8965
<ind-def:yamlpath>.spec.outputs[0:2].name</ind-def:yamlpath>
9066
</ind-def:yamlfilecontent_object>
9167

92-
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:5">
68+
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:3">
9369
<ind-def:path>/tmp</ind-def:path>
9470
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
9571
<ind-def:yamlpath>.spec.outputs[0]</ind-def:yamlpath>
@@ -100,26 +76,18 @@
10076
<states>
10177

10278
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:1">
103-
<ind-def:value-of datatype="string">LogForwarding</ind-def:value-of>
104-
</ind-def:yamlfilecontent_state>
105-
106-
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:2">
107-
<ind-def:value-of datatype="string">openshift-logging</ind-def:value-of>
108-
</ind-def:yamlfilecontent_state>
109-
110-
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:3">
11179
<ind-def:value-of datatype="string">secureforward-offcluster</ind-def:value-of>
11280
</ind-def:yamlfilecontent_state>
11381

114-
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:4">
115-
<ind-def:value-of datatype="string" var_ref="oval:0:var:4"/>
82+
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:2">
83+
<ind-def:value-of datatype="string" var_ref="oval:0:var:2"/>
11684
</ind-def:yamlfilecontent_state>
11785

11886
</states>
11987

12088
<variables>
12189

122-
<local_variable comment="oval:0:var:3" datatype="string" version="1" id="">
90+
<local_variable comment="oval:0:var:2" datatype="string" version="1" id="">
12391
<!-- The use of split should force creation of a local variable with two values
12492
NOTE: Wildly untested! -->
12593
<split delimiter="|">

tests/probes/yamlfilecontent/test_probes_yamlfilecontent.sh renamed to tests/probes/yamlfilecontent/test_probes_yamlfilecontent_key.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22

33
. $builddir/tests/test_common.sh
44

5-
function test_probes_yamlfilecontent {
5+
function test_probes_yamlfilecontent_key {
66

77
probecheck "yamlfilecontent" || return 255
8-
8+
99
local ret_val=0;
10-
local DF="${srcdir}/test_probes_yamlfilecontent.xml"
10+
local DF="${srcdir}/test_probes_yamlfilecontent_key.xml"
1111
local RF="results.xml"
12-
12+
1313
[ -f $RF ] && rm -f $RF
1414

1515
cp "${srcdir}/openshift-logging.yaml" /tmp
1616

1717
local YAML_FILE="/tmp/openshift-logging.yaml"
1818

1919
$OSCAP oval eval --results $RF $DF
20-
20+
2121
if [ -f $RF ]; then
22-
verify_results "def" $DF $RF 2 && verify_results "tst" $DF $RF 5
22+
verify_results "def" $DF $RF 2 && verify_results "tst" $DF $RF 3
2323
ret_val=$?
24-
else
24+
else
2525
ret_val=1
2626
fi
2727

28-
rm -f $YAML_FILE
28+
rm -f $YAML_FILE
2929

3030
return $ret_val
3131
}
3232

33-
test_probes_yamlfilecontent
33+
test_probes_yamlfilecontent_key
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0"?>
2+
<oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:unix-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd">
3+
4+
<generator>
5+
<oval:product_name>yamlfilecontent</oval:product_name>
6+
<oval:product_version>1.0</oval:product_version>
7+
<oval:schema_version>5.10</oval:schema_version>
8+
<oval:timestamp>2020-02-13T00:00:00-00:00</oval:timestamp>
9+
</generator>
10+
11+
<definitions>
12+
13+
<definition class="compliance" version="1" id="oval:0:def:1"> <!-- comment="true" -->
14+
<metadata>
15+
<title></title>
16+
<description></description>
17+
</metadata>
18+
<criteria operator="AND">
19+
<criterion comment="get_root_scalar" test_ref="oval:0:tst:1"/>
20+
<criterion comment="get_nested_scalar" test_ref="oval:0:tst:2"/>
21+
</criteria>
22+
</definition>
23+
24+
<definition class="compliance" version="1" id="oval:0:def:2"> <!-- comment="error" -->
25+
<metadata>
26+
<title></title>
27+
<description></description>
28+
</metadata>
29+
<criteria operator="AND">
30+
<criterion comment="get_non_scalar" test_ref="oval:0:tst:3"/>
31+
</criteria>
32+
</definition>
33+
34+
</definitions>
35+
36+
<tests>
37+
38+
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:1" check="all" comment="true">
39+
<ind-def:object object_ref="oval:0:obj:1"/>
40+
<ind-def:state state_ref="oval:0:ste:1"/>
41+
</ind-def:yamlfilecontent_test>
42+
43+
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:2" check="all" comment="true">
44+
<ind-def:object object_ref="oval:0:obj:2"/>
45+
<ind-def:state state_ref="oval:0:ste:2"/>
46+
</ind-def:yamlfilecontent_test>
47+
48+
<ind-def:yamlfilecontent_test version="1" id="oval:0:tst:3" check="all" comment="error">
49+
<ind-def:object object_ref="oval:0:obj:5"/>
50+
</ind-def:yamlfilecontent_test>
51+
52+
</tests>
53+
54+
<objects>
55+
56+
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:1">
57+
<ind-def:path>/tmp</ind-def:path>
58+
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
59+
<ind-def:yamlpath>.kind</ind-def:yamlpath>
60+
</ind-def:yamlfilecontent_object>
61+
62+
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:2">
63+
<ind-def:path>/tmp</ind-def:path>
64+
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
65+
<ind-def:yamlpath>.metadata.namespace</ind-def:yamlpath>
66+
</ind-def:yamlfilecontent_object>
67+
68+
<ind-def:yamlfilecontent_object version="1" id="oval:0:obj:3">
69+
<ind-def:path>/tmp</ind-def:path>
70+
<ind-def:filename>openshift-logging.yaml</ind-def:filename>
71+
<ind-def:yamlpath>.metadata</ind-def:yamlpath>
72+
</ind-def:yamlfilecontent_object>
73+
74+
</objects>
75+
76+
<states>
77+
78+
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:1">
79+
<ind-def:value-of datatype="string">LogForwarding</ind-def:value-of>
80+
</ind-def:yamlfilecontent_state>
81+
82+
<ind-def:yamlfilecontent_state version="1" id="oval:0:ste:2">
83+
<ind-def:value-of datatype="string">openshift-logging</ind-def:value-of>
84+
</ind-def:yamlfilecontent_state>
85+
86+
</states>
87+
88+
</oval_definitions>

0 commit comments

Comments
 (0)