summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-11-27 20:20:32 +1000
committerGitHub <noreply@github.com>2025-11-27 10:20:32 +0000
commit7157c6a195c3b1c6f013dab8fe322c6ace4e0c63 (patch)
tree62020d20617aec7e8849bd0687621d82a25e1419 /tests
parent85e132415cd7917c677d27b9085d17f50bc3da2e (diff)
downloadvyos.vyos-7157c6a195c3b1c6f013dab8fe322c6ace4e0c63.tar.gz
vyos.vyos-7157c6a195c3b1c6f013dab8fe322c6ace4e0c63.zip
T7621 vyos_firewall_global features (#432)
* t7621 vyos_firewall_global diff mode * vyos_firewall_global integration test for diff * enhanced integration tests with diff * diff integration tests * merged diff test * 1.3- specific changes to integration tests * data/config separated --------- Co-authored-by: Gaige B Paulsen <gaige@cluetrust.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml7
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml20
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml18
-rw-r--r--tests/integration/targets/vyos_firewall_global/vars/main.yaml71
-rw-r--r--tests/integration/targets/vyos_firewall_global/vars/pre-v1_4.yaml10
-rw-r--r--tests/integration/targets/vyos_firewall_global/vars/v1_4.yaml10
6 files changed, 136 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml
index 19fc83de..abcf597c 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml
@@ -10,11 +10,16 @@
vyos.vyos.vyos_firewall_global: &id001
config:
state: deleted
+ diff: true
- name: Assert that the before dicts were correctly generated
assert:
that:
- "{{ populate == result['before'] }}"
+ - item in result.diff.prepared
+ loop: "{{ deleted_diff }}"
+ loop_control:
+ loop_var: item
- name: Assert that the correct set of commands were generated
assert:
@@ -29,12 +34,14 @@
- name: Delete attributes of given interfaces (IDEMPOTENT)
register: result
vyos.vyos.vyos_firewall_global: *id001
+ diff: true
- name: Assert that the previous task was idempotent
assert:
that:
- result.changed == false
- result.commands|length == 0
+ - result['diff'] is not defined
- name: Assert that the before dicts were correctly generated
assert:
diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml
index a538476a..d40d37c9 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml
@@ -2,6 +2,8 @@
- debug:
msg: START vyos_firewall_global merged integration tests on connection={{ ansible_connection }}
+- include_tasks: _get_version.yaml
+
- include_tasks: _remove_config.yaml
- block:
@@ -28,15 +30,33 @@
- name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
register: result
vyos.vyos.vyos_firewall_global: *id001
+ diff: true
- name: Assert that the previous task was idempotent
assert:
that:
- result['changed'] == false
+ - result['diff'] is not defined
- name: Assert that before dicts were correctly generated
assert:
that:
- "{{ merged['after'] == result['before'] }}"
+
+ - name: Prepare device configurationsfor diff mode test
+ register: result
+ vyos.vyos.vyos_firewall_global:
+ config: "{{ merged['diff_config'] }}"
+ state: merged
+ diff: true
+
+ - name: Assert that correct diff of commands were generated
+ assert:
+ that:
+ - item in result.diff.prepared
+ loop: "{{ merged_diff }}"
+ loop_control:
+ loop_var: item
+
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml
index 4c7b4279..26c94b30 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml
@@ -29,15 +29,33 @@
- name: Replace device configurations of listed firewall with provided configurarions (IDEMPOTENT)
register: result
vyos.vyos.vyos_firewall_global: *id001
+ diff: true
- name: Assert that task was idempotent
assert:
that:
- result['changed'] == false
+ - result['diff'] is not defined
- name: Assert that before dict is correctly generated
assert:
that:
- "{{ replaced['after'] == result['before'] }}"
+
+ - name: Replace device configurations and test diff mode
+ register: result
+ vyos.vyos.vyos_firewall_global:
+ config: "{{ replaced['diff_config'] }}"
+ state: replaced
+ diff: true
+
+ - name: Assert that correct diff of commands were generated
+ assert:
+ that:
+ - item in result.diff.prepared
+ loop: "{{ replaced_diff }}"
+ loop_control:
+ loop_var: item
+
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_global/vars/main.yaml b/tests/integration/targets/vyos_firewall_global/vars/main.yaml
index 363cc9e6..0f041b60 100644
--- a/tests/integration/targets/vyos_firewall_global/vars/main.yaml
+++ b/tests/integration/targets/vyos_firewall_global/vars/main.yaml
@@ -70,6 +70,39 @@ merged:
description: This group has the Management network addresses
members:
- address: 192.0.1.0/24
+ diff_config:
+ validation: strict
+ log_martians: true
+ syn_cookies: true
+ twa_hazards_protection: true
+ ping:
+ all: true
+ broadcast: true
+ state_policy:
+ - connection_type: established
+ action: accept
+ log: true
+ - connection_type: invalid
+ action: reject
+ route_redirects:
+ - afi: ipv4
+ ip_src_route: true
+ icmp_redirects:
+ send: true
+ receive: false
+ group:
+ address_group:
+ - name: MGMT-HOSTS
+ description: This group has the Management hosts address list
+ members:
+ - address: 192.0.1.1
+ - address: 192.0.1.3
+ - address: 192.0.1.5
+ network_group:
+ - name: MGMT
+ description: This group has the Management network addresses
+ members:
+ - address: 1.1.1.1/32
populate:
validation: strict
@@ -188,6 +221,44 @@ replaced:
description: This group has the Management network addresses
members:
- address: 192.0.1.0/24
+ diff_config:
+ validation: strict
+ log_martians: true
+ syn_cookies: true
+ twa_hazards_protection: true
+ ping:
+ all: true
+ broadcast: true
+ state_policy:
+ - connection_type: established
+ action: accept
+ log: true
+ - connection_type: invalid
+ action: reject
+ route_redirects:
+ - afi: ipv4
+ ip_src_route: true
+ icmp_redirects:
+ send: true
+ receive: false
+ group:
+ address_group:
+ - name: SALES-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.2.1
+ - address: 192.0.2.2
+ - address: 192.0.2.3
+ - name: ENG-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.3.1
+ - address: 192.0.3.2
+ network_group:
+ - name: MGMT
+ description: This group has the Management network addresses
+ members:
+ - address: 1.1.1.1/32
rendered:
commands: "{{ rendered_commands }}"
diff --git a/tests/integration/targets/vyos_firewall_global/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_firewall_global/vars/pre-v1_4.yaml
index db293451..581d4d57 100644
--- a/tests/integration/targets/vyos_firewall_global/vars/pre-v1_4.yaml
+++ b/tests/integration/targets/vyos_firewall_global/vars/pre-v1_4.yaml
@@ -83,3 +83,13 @@ deleted_commands:
- "delete firewall"
parsed_config_file: "_parsed_config_1_3.cfg"
+
+replaced_diff:
+ - "+network 1.1.1.1/32"
+ - "-network 192.0.1.0/24"
+
+merged_diff:
+ - "+network 1.1.1.1/32"
+
+deleted_diff:
+ - "- network 192.0.1.0/24"
diff --git a/tests/integration/targets/vyos_firewall_global/vars/v1_4.yaml b/tests/integration/targets/vyos_firewall_global/vars/v1_4.yaml
index d1ee6f2b..68773b2c 100644
--- a/tests/integration/targets/vyos_firewall_global/vars/v1_4.yaml
+++ b/tests/integration/targets/vyos_firewall_global/vars/v1_4.yaml
@@ -83,3 +83,13 @@ deleted_commands:
- "delete firewall"
parsed_config_file: "_parsed_config_1_4.cfg"
+
+replaced_diff:
+ - '+ network "1.1.1.1/32"'
+ - '- network "192.0.1.0/24"'
+
+merged_diff:
+ - '+ network "1.1.1.1/32"'
+
+deleted_diff:
+ - '- network "192.0.1.0/24"'