summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_firewall_interfaces
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2026-08-22 01:36:21 +1000
committerGitHub <noreply@github.com>2026-08-21 10:36:21 -0500
commit7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff (patch)
tree82dad9c7ca58b7c88ac25f2ef7b04413e259a260 /tests/integration/targets/vyos_firewall_interfaces
parentcb738721c15ac01f49f66144dae80eb478331f77 (diff)
downloadrest.vyos-7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff.tar.gz
rest.vyos-7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff.zip
T8989: wave3 user, bgp_global, bgp_address_family, facts, firewall_global
* T8989: vyos_user module * T8989: Wave 3 vyos_user module with integration and unit tests * T8989: Wave 3 vyos_bgp_global module with integration and unit tests * T8989: Wave 3 vyos_bgp_address_family module with integration and unit tests * T8989: Add overridden integration tests for vyos_bgp_global and vyos_bgp_address_family * T8989: vyos_facts * T8989: Add vyos_facts integration and unit tests with fixtures * T8989: vyos_firewall_global module * T8989: vyos_firewall_global module with integration and unit tests * T8989: vyos_firewall_rules module * T8989: vyos_firewall_rules module with integration and unit tests * T8989: vyos_firewall_interfaces module * T8989: vyos_firewall_interfaces module * T8989: vyos_firewall_interfaces UAT & SIT * T8989: vyos_firewall_interfaces UAT & SIT
Diffstat (limited to 'tests/integration/targets/vyos_firewall_interfaces')
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/aliases1
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_populate_config.yaml23
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml29
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/merged.yaml46
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml33
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml37
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/rtt.yaml53
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml2
13 files changed, 279 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_firewall_interfaces/aliases b/tests/integration/targets/vyos_firewall_interfaces/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..d2dddc7
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,23 @@
+---
+- name: Populate firewall interfaces config for testing
+ vyos.rest.vyos_firewall_interfaces:
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ - number: 20
+ action: drop
+ state: invalid
+ - hook: forward
+ default_action: accept
+ - afi: ipv6
+ hooks:
+ - hook: input
+ default_action: accept
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..14b0216
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove firewall interfaces configuration
+ vyos.rest.vyos_firewall_interfaces:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..00025f7
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,29 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all firewall interfaces configuration
+ register: result
+ vyos.rest.vyos_firewall_interfaces:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete all firewall interfaces configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_firewall_interfaces:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..27ad537
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather firewall interfaces configuration
+ register: result
+ vyos.rest.vyos_firewall_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1
+ - result.gathered | selectattr('afi', 'eq', 'ipv6') | list | length == 1
+ - (result.gathered | selectattr('afi', 'eq', 'ipv4') | first).hooks | selectattr('hook', 'eq', 'input') | list | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..d89530d
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,46 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge firewall interfaces configuration
+ register: result
+ vyos.rest.vyos_firewall_interfaces:
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge firewall interfaces configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_firewall_interfaces:
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..8a20a48
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override firewall interfaces configuration
+ register: result
+ vyos.rest.vyos_firewall_interfaces: &id001
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: forward
+ default_action: accept
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override firewall interfaces configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_firewall_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..f782fc6
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace firewall interfaces configuration
+ register: result
+ vyos.rest.vyos_firewall_interfaces: &id001
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace firewall interfaces configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_firewall_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..229bc7f
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/rtt.yaml
@@ -0,0 +1,53 @@
+---
+- debug:
+ msg: START vyos_firewall_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_firewall_interfaces:
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ state: merged
+
+ - name: RTT - Gather
+ register: gathered
+ vyos.rest.vyos_firewall_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - gathered.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_firewall_interfaces:
+ config:
+ - afi: ipv4
+ hooks:
+ - hook: input
+ default_action: accept
+ rules:
+ - number: 10
+ action: accept
+ state: established
+ state: replaced
+
+ - name: RTT - Gather after modify
+ register: gathered2
+ vyos.rest.vyos_firewall_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - (gathered2.gathered | selectattr('afi', 'eq', 'ipv4') | first).hooks[0].default_action == 'accept'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml b/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here