Skip to content

Commit a3e697a

Browse files
committed
ci: Assert fact structure and some well-known entries
Spot-check a particular entry of each fact group (helpers, icmptypes, services, and zones) to ensure the returned fact structure is as expected. This will help with validating a future `firewall-offline-cmd` backend. Note that "policies" does not yet exist in RHEL 7/8, so don't check that. Also check that the service addition and custom service creation actions are actually reflected in the facts.
1 parent 77223db commit a3e697a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/tests_firewall_fact.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
msg: default zone should be {{ __default_zone.stdout }}
4747
when: firewall_config.default_zone != __default_zone.stdout
4848

49+
- name: Spot-check default entries and structure
50+
assert:
51+
that:
52+
- '"snmp" in firewall_config.default.helpers'
53+
- '"echo-request" in firewall_config.default.icmptypes'
54+
- '"http" in firewall_config.default.services'
55+
- '"public" in firewall_config.default.zones'
56+
4957
- name: Save default ansible fact value
5058
set_fact:
5159
__previous_firewall_config: "{{ firewall_config }}"
@@ -86,6 +94,14 @@
8694
'zones' not in firewall_config.custom or
8795
'services' not in firewall_config.custom
8896
97+
- name: Check the customized services
98+
assert:
99+
that:
100+
- '"https" in firewall_config.default.services'
101+
- '"https" not in firewall_config.custom.services'
102+
- '"custom" not in firewall_config.default.services'
103+
- '"custom" in firewall_config.custom.services'
104+
89105
- name: Store previous firewall_config
90106
set_fact:
91107
__previous_firewall_config: "{{ firewall_config }}"
@@ -119,6 +135,14 @@
119135
when: firewall_config.default_zone !=
120136
__previous_firewall_config.default_zone
121137

138+
- name: Spot-check default entry details and structure
139+
assert:
140+
that:
141+
- firewall_config.default.helpers.snmp.description is string
142+
- '"reachable" in firewall_config.default.icmptypes["echo-request"].description'
143+
- '"HTTP" in firewall_config.default.services.http.description'
144+
- '"public areas" in firewall_config.default.zones.public.description'
145+
122146
always:
123147
- name: Cleanup
124148
tags:

0 commit comments

Comments
 (0)