summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-07-06 14:54:12 +1000
committerJohn Estabrook <jestabro@vyos.io>2026-08-21 14:02:19 -0500
commit45dc95873fd906c582fbbd5e6ca3838caf867399 (patch)
tree71b3e53e0080da60abf9fd2381705971dfe4d507 /tests/integration
parent7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff (diff)
downloadrest.vyos-45dc95873fd906c582fbbd5e6ca3838caf867399.tar.gz
rest.vyos-45dc95873fd906c582fbbd5e6ca3838caf867399.zip
T8989: wave4 vyos_command, dict_op refactorT8989_wave4
* T8989: vyos_command module * T8989: vyos_command module UAT and SIT * T8989: vyos_command changelog * T8989: vyos_command linter * T8989: vyos_config module * T8989: vyos_config module changelog * T8989: Wave 4 vyos_config module with integration and unit tests * T8323: vyos_system module * T8332: vyos_system SIT and UAT * T8323: vyos_vlan module * T8323: vyos_vlan module * T8323: vyos_vlan module SIT and UAT * T8323: vyos_system module * T8989: Wave 4 vyos_vlan reworked with dict_op engine * T8989: Fix dict_op single-value string list handling, add vyos_system integration tests * T8989: logging_global refactor * T8989: migrate ntp_global, logging_global, firewall_global to dict_op engine * T8989: vyos_nat module for REST API collection * T8989: vyos_nat module for REST API collection, linter fixes * T8989: vyos_ha module for REST API collection * T8989: vyos_ha module for REST API collection * T8989: vyos_ha module sanity and linter fixes * T8989: vyos_ha module sanity and linter fixes * T8989: vyos_ha module linter fixes * T8989: vyos.rest AI comment fixes * T8323: vyos_nat AI comment fixes * T8989 ai fixes * T8989: vyos_bgp_address_family dict_op * T8989: vyos_bgp_address_family vyos_bgp_global dict_op * T8989: dict_op refactor for firewall_*, nat, user * T8989: dict_op refactor for firewall_*, nat, user * T8989: dict_op refactor for ntp_global, ha * T8989: snmp_server dict_op refactor * T8989: snmp_server dict_op refactor * T8989: route_map dict_op refactor
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_banner/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_address_family/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_bgp_address_family/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_address_family/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_address_family/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_address_family/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_global/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_command/aliases1
-rw-r--r--tests/integration/targets/vyos_command/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_command/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_command/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_command/tests/httpapi/show.yaml45
-rw-r--r--tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml36
-rw-r--r--tests/integration/targets/vyos_command/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_config/aliases1
-rw-r--r--tests/integration/targets/vyos_config/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_config/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_config/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_config/tests/httpapi/_remove_config.yaml6
-rw-r--r--tests/integration/targets/vyos_config/tests/httpapi/delete.yaml37
-rw-r--r--tests/integration/targets/vyos_config/tests/httpapi/lines.yaml44
-rw-r--r--tests/integration/targets/vyos_config/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_configure/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_facts/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_facts/tests/httpapi/_populate_config.yaml16
-rw-r--r--tests/integration/targets/vyos_facts/tests/httpapi/_remove_config.yaml8
-rw-r--r--tests/integration/targets/vyos_facts/tests/httpapi/all.yaml5
-rw-r--r--tests/integration/targets/vyos_facts/tests/httpapi/default.yaml4
-rw-r--r--tests/integration/targets/vyos_facts/tests/httpapi/subsets.yaml25
-rw-r--r--tests/integration/targets/vyos_firewall_global/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_global/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_rules/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_firewall_rules/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_rules/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_rules/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_firewall_rules/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_ha/aliases1
-rw-r--r--tests/integration/targets/vyos_ha/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ha/tasks/httpapi.yaml18
-rw-r--r--tests/integration/targets/vyos_ha/tasks/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml40
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml4
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml36
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml29
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml54
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml50
-rw-r--r--tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml48
-rw-r--r--tests/integration/targets/vyos_ha/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_hostname/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_nat/aliases1
-rw-r--r--tests/integration/targets/vyos_nat/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_nat/tasks/httpapi.yaml18
-rw-r--r--tests/integration/targets/vyos_nat/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/_populate_config.yaml39
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/deleted.yaml36
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/gathered.yaml30
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/merged.yaml49
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/overridden.yaml49
-rw-r--r--tests/integration/targets/vyos_nat/tests/httpapi/replaced.yaml49
-rw-r--r--tests/integration/targets/vyos_nat/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml6
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml8
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml4
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml8
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml54
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml128
-rw-r--r--tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml4
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml4
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml4
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml77
-rw-r--r--tests/integration/targets/vyos_system/aliases1
-rw-r--r--tests/integration/targets/vyos_system/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_system/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_system/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_system/tests/httpapi/_remove_config.yaml12
-rw-r--r--tests/integration/targets/vyos_system/tests/httpapi/absent.yaml48
-rw-r--r--tests/integration/targets/vyos_system/tests/httpapi/gathered.yaml14
-rw-r--r--tests/integration/targets/vyos_system/tests/httpapi/present.yaml63
-rw-r--r--tests/integration/targets/vyos_system/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_user/tasks/httpapi.yaml2
-rw-r--r--tests/integration/targets/vyos_vlan/aliases1
-rw-r--r--tests/integration/targets/vyos_vlan/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml9
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml45
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml28
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml44
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml43
-rw-r--r--tests/integration/targets/vyos_vlan/vars/main.yaml2
126 files changed, 1541 insertions, 170 deletions
diff --git a/tests/integration/targets/vyos_banner/tasks/httpapi.yaml b/tests/integration/targets/vyos_banner/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_banner/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_banner/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml
index 82e0f6e..61f3f2d 100644
--- a/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_banner deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete pre-login banner
register: result
vyos.rest.vyos_banner: &id001
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml
index a51ff48..a332563 100644
--- a/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_banner gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather banner configuration
register: result
vyos.rest.vyos_banner:
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml
index 96a984e..85fafdb 100644
--- a/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml
@@ -3,9 +3,9 @@
msg: START vyos_banner gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather all banners (no config specified)
register: result
vyos.rest.vyos_banner:
diff --git a/tests/integration/targets/vyos_bgp_address_family/tasks/httpapi.yaml b/tests/integration/targets/vyos_bgp_address_family/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/deleted.yaml
index ce1ab70..225f057 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_address_family deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete BGP address-family configuration
register: result
vyos.rest.vyos_bgp_address_family:
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/gathered.yaml
index e686a32..50db299 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_address_family gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather BGP address-family configuration
register: result
vyos.rest.vyos_bgp_address_family:
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/overridden.yaml
index 9a497d2..cae014e 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_address_family overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override BGP address-family configuration
register: result
vyos.rest.vyos_bgp_address_family: &id001
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/replaced.yaml
index 133ae39..f4ae60f 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_address_family replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace BGP address-family configuration
register: result
vyos.rest.vyos_bgp_address_family: &id001
diff --git a/tests/integration/targets/vyos_bgp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_bgp_global/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_bgp_global/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_bgp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_bgp_global/tests/httpapi/deleted.yaml
index ed2c285..9fe1f62 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_global deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete BGP configuration
register: result
vyos.rest.vyos_bgp_global:
diff --git a/tests/integration/targets/vyos_bgp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_bgp_global/tests/httpapi/gathered.yaml
index b38dba0..c8d327c 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_global gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather BGP global configuration
register: result
vyos.rest.vyos_bgp_global:
diff --git a/tests/integration/targets/vyos_bgp_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_bgp_global/tests/httpapi/overridden.yaml
index 603aff3..aad9a9c 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_global overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override BGP global configuration
register: result
vyos.rest.vyos_bgp_global: &id001
diff --git a/tests/integration/targets/vyos_bgp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_bgp_global/tests/httpapi/replaced.yaml
index 1a7d615..d88af15 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_bgp_global replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace BGP global configuration
register: result
vyos.rest.vyos_bgp_global: &id001
diff --git a/tests/integration/targets/vyos_command/aliases b/tests/integration/targets/vyos_command/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_command/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_command/defaults/main.yaml b/tests/integration/targets/vyos_command/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_command/tasks/httpapi.yaml b/tests/integration/targets/vyos_command/tasks/httpapi.yaml
new file mode 100644
index 0000000..0ed3e42
--- /dev/null
+++ b/tests/integration/targets/vyos_command/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 | sort }}"
+
+- 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_command/tasks/main.yaml b/tests/integration/targets/vyos_command/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_command/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_command/tests/httpapi/show.yaml b/tests/integration/targets/vyos_command/tests/httpapi/show.yaml
new file mode 100644
index 0000000..fed35d7
--- /dev/null
+++ b/tests/integration/targets/vyos_command/tests/httpapi/show.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: START vyos_command show integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Run show version
+ register: result
+ vyos.rest.vyos_command:
+ commands:
+ - version
+
+ - assert:
+ that:
+ - result.stdout | length == 1
+ - result.stdout[0] | length > 0
+ - "'VyOS' in result.stdout[0]"
+ - result.stdout_lines | length == 1
+
+ - name: Run multiple show commands
+ register: result
+ vyos.rest.vyos_command:
+ commands:
+ - interfaces
+ - ip route
+ - system uptime
+
+ - assert:
+ that:
+ - result.stdout | length == 3
+ - result.stdout_lines | length == 3
+ - result.stdout[0] | length > 0
+ - result.stdout[1] | length > 0
+ - result.stdout[2] | length > 0
+
+ - name: Run show commands as lists
+ register: result
+ vyos.rest.vyos_command:
+ commands:
+ - - system
+ - uptime
+
+ - assert:
+ that:
+ - result.stdout | length == 1
+ - "'Uptime' in result.stdout[0]"
diff --git a/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml b/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml
new file mode 100644
index 0000000..298c68c
--- /dev/null
+++ b/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_command wait_for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Wait for version output to contain VyOS
+ register: result
+ vyos.rest.vyos_command:
+ commands:
+ - version
+ wait_for:
+ - result[0] contains VyOS
+ retries: 3
+ interval: 1
+
+ - assert:
+ that:
+ - result.stdout | length == 1
+ - "'VyOS' in result.stdout[0]"
+
+ - name: Wait for any condition to match
+ register: result
+ vyos.rest.vyos_command:
+ commands:
+ - version
+ - interfaces
+ wait_for:
+ - result[0] contains VyOS
+ - result[1] contains eth0
+ match: all
+ retries: 3
+ interval: 1
+
+ - assert:
+ that:
+ - result.stdout | length == 2
diff --git a/tests/integration/targets/vyos_command/vars/main.yaml b/tests/integration/targets/vyos_command/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_command/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_config/aliases b/tests/integration/targets/vyos_config/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_config/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_config/defaults/main.yaml b/tests/integration/targets/vyos_config/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_config/tasks/httpapi.yaml b/tests/integration/targets/vyos_config/tasks/httpapi.yaml
new file mode 100644
index 0000000..0ed3e42
--- /dev/null
+++ b/tests/integration/targets/vyos_config/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 | sort }}"
+
+- 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_config/tasks/main.yaml b/tests/integration/targets/vyos_config/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_config/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_config/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_config/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..2c602fa
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Remove test configuration
+ vyos.rest.vyos_config:
+ lines:
+ - delete interfaces ethernet eth1 description
+ match: none
diff --git a/tests/integration/targets/vyos_config/tests/httpapi/delete.yaml b/tests/integration/targets/vyos_config/tests/httpapi/delete.yaml
new file mode 100644
index 0000000..0db8e84
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/httpapi/delete.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_config delete integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup - add description
+ vyos.rest.vyos_config:
+ lines:
+ - set interfaces ethernet eth1 description "To be deleted"
+ match: none
+
+ - name: Delete configuration
+ register: result
+ vyos.rest.vyos_config:
+ lines:
+ - delete interfaces ethernet eth1 description
+ save: true
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete again (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_config:
+ lines:
+ - delete interfaces ethernet eth1 description
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_config/tests/httpapi/lines.yaml b/tests/integration/targets/vyos_config/tests/httpapi/lines.yaml
new file mode 100644
index 0000000..11b69ce
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/httpapi/lines.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_config lines integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply configuration lines
+ register: result
+ vyos.rest.vyos_config:
+ lines:
+ - set interfaces ethernet eth1 description "Test description"
+ save: true
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length == 1
+
+ - name: Apply same config (match=line IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_config:
+ lines:
+ - set interfaces ethernet eth1 description "Test description"
+ match: line
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ - name: Apply with match=none (always apply)
+ register: result
+ vyos.rest.vyos_config:
+ lines:
+ - set interfaces ethernet eth1 description "Test description"
+ match: none
+
+ - assert:
+ that:
+ - result.changed == true
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_config/vars/main.yaml b/tests/integration/targets/vyos_config/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_config/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_configure/tasks/httpapi.yaml b/tests/integration/targets/vyos_configure/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_configure/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_configure/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_facts/tasks/httpapi.yaml b/tests/integration/targets/vyos_facts/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_facts/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_facts/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_facts/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_facts/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..690c0c8
--- /dev/null
+++ b/tests/integration/targets/vyos_facts/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,16 @@
+---
+- name: Configure logging for facts testing
+ vyos.rest.vyos_logging_global:
+ config:
+ global_params:
+ facilities:
+ - facility: all
+ severity: notice
+ state: merged
+
+- name: Configure NTP for facts testing
+ vyos.rest.vyos_ntp_global:
+ config:
+ servers:
+ - server: time1.vyos.net
+ state: merged
diff --git a/tests/integration/targets/vyos_facts/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_facts/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..fbc2e73
--- /dev/null
+++ b/tests/integration/targets/vyos_facts/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove logging config
+ vyos.rest.vyos_logging_global:
+ state: deleted
+
+- name: Remove NTP config
+ vyos.rest.vyos_ntp_global:
+ state: deleted
diff --git a/tests/integration/targets/vyos_facts/tests/httpapi/all.yaml b/tests/integration/targets/vyos_facts/tests/httpapi/all.yaml
index 419634f..4d6ad53 100644
--- a/tests/integration/targets/vyos_facts/tests/httpapi/all.yaml
+++ b/tests/integration/targets/vyos_facts/tests/httpapi/all.yaml
@@ -3,6 +3,8 @@
msg: START vyos_facts all integration tests on connection={{ ansible_connection }}
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather all facts
vyos.rest.vyos_facts:
gather_subset: all
@@ -14,3 +16,6 @@
- ansible_facts.vyos_users is defined
- ansible_facts.vyos_config is defined
- ansible_facts.vyos_logging is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_facts/tests/httpapi/default.yaml b/tests/integration/targets/vyos_facts/tests/httpapi/default.yaml
index ff1caee..b5937be 100644
--- a/tests/integration/targets/vyos_facts/tests/httpapi/default.yaml
+++ b/tests/integration/targets/vyos_facts/tests/httpapi/default.yaml
@@ -5,9 +5,9 @@
- block:
- name: Gather default facts
vyos.rest.vyos_facts:
+ gather_subset: default
- assert:
that:
- ansible_facts.vyos_hostname is defined
- - ansible_facts.vyos_interfaces is defined
- - ansible_facts.vyos_hostname | length > 0
+ - ansible_facts.vyos_config is defined
diff --git a/tests/integration/targets/vyos_facts/tests/httpapi/subsets.yaml b/tests/integration/targets/vyos_facts/tests/httpapi/subsets.yaml
index eb4ca4f..5151b4a 100644
--- a/tests/integration/targets/vyos_facts/tests/httpapi/subsets.yaml
+++ b/tests/integration/targets/vyos_facts/tests/httpapi/subsets.yaml
@@ -3,31 +3,34 @@
msg: START vyos_facts subsets integration tests on connection={{ ansible_connection }}
- block:
- - name: Gather hostname only
+ - include_tasks: _populate_config.yaml
+
+ - name: Gather logging subset
vyos.rest.vyos_facts:
gather_subset:
- - hostname
+ - logging
- assert:
that:
- - ansible_facts.vyos_hostname is defined
+ - ansible_facts.vyos_logging is defined
- - name: Gather users
+ - name: Gather ntp subset
vyos.rest.vyos_facts:
gather_subset:
- - users
+ - ntp
- assert:
that:
- - ansible_facts.vyos_users is defined
- - ansible_facts.vyos_users | selectattr('name', 'eq', 'vyos') | list | length == 1
+ - ansible_facts.vyos_ntp is defined
- - name: Gather config
+ - name: Gather interfaces subset
vyos.rest.vyos_facts:
gather_subset:
- - config
+ - interfaces
- assert:
that:
- - ansible_facts.vyos_config is defined
- - ansible_facts.vyos_config.system is defined
+ - ansible_facts.vyos_interfaces is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_firewall_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_firewall_global/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_firewall_global/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_firewall_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_firewall_global/tests/httpapi/deleted.yaml
index ade5fe4..8f1b327 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_global deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete firewall global configuration
register: result
vyos.rest.vyos_firewall_global:
diff --git a/tests/integration/targets/vyos_firewall_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_firewall_global/tests/httpapi/gathered.yaml
index 6f470bd..50df093 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_global gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather firewall global configuration
register: result
vyos.rest.vyos_firewall_global:
diff --git a/tests/integration/targets/vyos_firewall_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_firewall_global/tests/httpapi/overridden.yaml
index 04d7c95..97e76b5 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_global overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override firewall global configuration
register: result
vyos.rest.vyos_firewall_global: &id001
diff --git a/tests/integration/targets/vyos_firewall_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_firewall_global/tests/httpapi/replaced.yaml
index b5af06f..661d983 100644
--- a/tests/integration/targets/vyos_firewall_global/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_firewall_global/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_global replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace firewall global configuration
register: result
vyos.rest.vyos_firewall_global: &id001
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_firewall_interfaces/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml
index 00025f7..9e76d63 100644
--- a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_interfaces deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all firewall interfaces configuration
register: result
vyos.rest.vyos_firewall_interfaces:
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml
index 27ad537..192f2f0 100644
--- a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_interfaces gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather firewall interfaces configuration
register: result
vyos.rest.vyos_firewall_interfaces:
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml
index 8a20a48..ff69cc1 100644
--- a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_interfaces overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override firewall interfaces configuration
register: result
vyos.rest.vyos_firewall_interfaces: &id001
diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml
index f782fc6..7109dd4 100644
--- a/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_firewall_interfaces/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_interfaces replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace firewall interfaces configuration
register: result
vyos.rest.vyos_firewall_interfaces: &id001
diff --git a/tests/integration/targets/vyos_firewall_rules/tasks/httpapi.yaml b/tests/integration/targets/vyos_firewall_rules/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_firewall_rules/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_firewall_rules/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/deleted.yaml
index db4cbf0..78a4d62 100644
--- a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_rules deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all firewall rules configuration
register: result
vyos.rest.vyos_firewall_rules:
diff --git a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/gathered.yaml
index 6729976..89f54ca 100644
--- a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_rules gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather firewall rules configuration
register: result
vyos.rest.vyos_firewall_rules:
diff --git a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/overridden.yaml
index d5db4b9..31dcc8d 100644
--- a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_rules overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override firewall rules configuration
register: result
vyos.rest.vyos_firewall_rules: &id001
diff --git a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/replaced.yaml
index 92033c4..1200fb7 100644
--- a/tests/integration/targets/vyos_firewall_rules/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_firewall_rules/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_firewall_rules replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace firewall rules configuration
register: result
vyos.rest.vyos_firewall_rules: &id001
diff --git a/tests/integration/targets/vyos_ha/aliases b/tests/integration/targets/vyos_ha/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_ha/defaults/main.yaml b/tests/integration/targets/vyos_ha/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_ha/tasks/httpapi.yaml b/tests/integration/targets/vyos_ha/tasks/httpapi.yaml
new file mode 100644
index 0000000..014aa9d
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tasks/httpapi.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "*.yaml"
+ excludes: "_*.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ loop: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_ha/tasks/main.yaml b/tests/integration/targets/vyos_ha/tasks/main.yaml
new file mode 100644
index 0000000..d14215c
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..0a73b89
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,40 @@
+---
+- name: Populate HA config for testing
+ vyos.rest.vyos_ha:
+ config:
+ vrrp:
+ global_parameters:
+ startup_delay: 30
+ garp:
+ master_repeat: 6
+ groups:
+ - name: g1
+ interface: eth0
+ vrid: 20
+ priority: 100
+ address:
+ - 192.168.1.100/24
+ peer_address: 192.168.1.3
+ - name: g2
+ interface: eth1
+ vrid: 21
+ priority: 50
+ address:
+ - 192.168.2.100/24
+ sync_groups:
+ - name: sg1
+ member: [g1]
+ health_check:
+ failure_count: 5
+ ping: 192.168.1.1
+ snmp: enabled
+ virtual_servers:
+ - name: s1
+ address: 10.10.10.5
+ algorithm: round-robin
+ port: 80
+ protocol: tcp
+ real_server:
+ - address: 10.10.50.2
+ port: 8080
+ state: merged
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..77a90d0
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Remove all HA configuration
+ vyos.rest.vyos_ha:
+ state: deleted
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..571e02d
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_ha deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Delete all HA configuration
+ vyos.rest.vyos_ha: &id001
+ state: deleted
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after delete
+ vyos.rest.vyos_ha:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered == {}
+
+ - name: Delete again (IDEMPOTENT)
+ vyos.rest.vyos_ha: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..cf261fb
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml
@@ -0,0 +1,29 @@
+---
+- debug:
+ msg: START vyos_ha gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Gather HA configuration
+ vyos.rest.vyos_ha:
+ state: gathered
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - "'vrrp' in result.gathered"
+ - "'virtual_servers' in result.gathered"
+ - result.gathered.vrrp.groups | length == 2
+ - result.gathered.vrrp.groups | selectattr('name','equalto','g1') | list | length == 1
+ - result.gathered.vrrp.groups | selectattr('name','equalto','g2') | list | length == 1
+ - result.gathered.vrrp.snmp == "enabled"
+ - result.gathered.vrrp.global_parameters.startup_delay == 30
+ - result.gathered.vrrp.sync_groups[0].name == "sg1"
+ - result.gathered.vrrp.sync_groups[0].member == ["g1"]
+ - result.gathered.virtual_servers[0].name == "s1"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..5614720
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml
@@ -0,0 +1,54 @@
+---
+- debug:
+ msg: START vyos_ha merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge HA configuration
+ vyos.rest.vyos_ha: &id001
+ config:
+ vrrp:
+ global_parameters:
+ startup_delay: 30
+ groups:
+ - name: g1
+ interface: eth0
+ vrid: 20
+ priority: 100
+ address:
+ - 192.168.1.100/24
+ sync_groups:
+ - name: sg1
+ member: [g1]
+ health_check:
+ failure_count: 3
+ ping: 192.168.1.1
+ snmp: enabled
+ virtual_servers:
+ - name: s1
+ address: 10.10.10.5
+ port: 80
+ protocol: tcp
+ real_server:
+ - address: 10.10.50.2
+ port: 8080
+ state: merged
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length > 0
+
+ - name: Merge again (IDEMPOTENT)
+ vyos.rest.vyos_ha: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..c916e2d
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml
@@ -0,0 +1,50 @@
+---
+- debug:
+ msg: START vyos_ha overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Override - only g1 remains, virtual_servers removed
+ vyos.rest.vyos_ha: &id001
+ config:
+ vrrp:
+ groups:
+ - name: g1
+ interface: eth0
+ vrid: 20
+ priority: 100
+ address:
+ - 192.168.1.100/24
+ state: overridden
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after override
+ vyos.rest.vyos_ha:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered.vrrp.groups | length == 1
+ - gathered.gathered.vrrp.groups[0].name == "g1"
+ - "'virtual_servers' not in gathered.gathered"
+ - "'sync_groups' not in gathered.gathered.vrrp"
+ - "'snmp' not in gathered.gathered.vrrp"
+
+ - name: Override again (IDEMPOTENT)
+ vyos.rest.vyos_ha: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..6ad458b
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_ha replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Replace vrrp groups - removes g2, keeps virtual_servers
+ vyos.rest.vyos_ha: &id001
+ config:
+ vrrp:
+ groups:
+ - name: g1
+ interface: eth0
+ vrid: 20
+ priority: 100
+ address:
+ - 192.168.1.100/24
+ state: replaced
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after replace
+ vyos.rest.vyos_ha:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered.vrrp.groups | length == 1
+ - gathered.gathered.vrrp.groups[0].name == "g1"
+ - "'virtual_servers' in gathered.gathered"
+
+ - name: Replace again (IDEMPOTENT)
+ vyos.rest.vyos_ha: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ha/vars/main.yaml b/tests/integration/targets/vyos_ha/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_ha/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml b/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml
index dfc8896..e8e0973 100644
--- a/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml
@@ -2,9 +2,9 @@
- debug:
msg: START vyos_hostname gathered integration tests on connection={{ ansible_connection }}
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather hostname configuration
register: result
vyos.rest.vyos_hostname:
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml
index b4e318d..0d418e2 100644
--- a/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml
@@ -2,9 +2,9 @@
- debug:
msg: START vyos_hostname replaced integration tests on connection={{ ansible_connection }}
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace hostname configuration
register: result
vyos.rest.vyos_hostname: &id001
diff --git a/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml
index d084d4a..bb0f7fc 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_lldp_global deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all lldp_global configuration
register: result
vyos.rest.vyos_lldp_global: &id001
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml
index 20ac2b2..58c55cf 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_lldp_global gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather lldp_global configuration
register: result
vyos.rest.vyos_lldp_global:
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml
index d5523eb..edc908a 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace lldp_global configuration
register: result
vyos.rest.vyos_lldp_global: &id001
diff --git a/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml
index 8c62627..6eb4ed9 100644
--- a/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_logging_global deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all logging_global configuration
register: result
vyos.rest.vyos_logging_global: &id001
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml
index 667c088..660d1fc 100644
--- a/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_logging_global gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather logging_global configuration
register: result
vyos.rest.vyos_logging_global:
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml
index a1c24c0..3ecd341 100644
--- a/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_logging_global replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace logging_global configuration
register: result
vyos.rest.vyos_logging_global: &id001
diff --git a/tests/integration/targets/vyos_nat/aliases b/tests/integration/targets/vyos_nat/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_nat/defaults/main.yaml b/tests/integration/targets/vyos_nat/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_nat/tasks/httpapi.yaml b/tests/integration/targets/vyos_nat/tasks/httpapi.yaml
new file mode 100644
index 0000000..014aa9d
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tasks/httpapi.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "*.yaml"
+ excludes: "_*.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ loop: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_nat/tasks/main.yaml b/tests/integration/targets/vyos_nat/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/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_nat/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..fd543d5
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,39 @@
+---
+- name: Populate NAT config for testing
+ vyos.rest.vyos_nat:
+ config:
+ nat:
+ source:
+ rule:
+ - id: 100
+ description: "Source rule 100"
+ outbound_interface:
+ name: eth0
+ translation:
+ address: masquerade
+ - id: 101
+ outbound_interface:
+ name: eth1
+ translation:
+ address: masquerade
+ destination:
+ rule:
+ - id: 200
+ protocol: tcp
+ inbound_interface:
+ name: eth0
+ destination:
+ address: 198.51.100.10
+ port: "80"
+ translation:
+ address: 192.168.1.10
+ port: "8080"
+ static:
+ rule:
+ - id: 300
+ inbound_interface: eth0
+ destination:
+ address: 198.51.100.20
+ translation:
+ address: 192.168.1.20
+ state: merged
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..8ee616b
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove all NAT configuration
+ vyos.rest.vyos_nat:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..2d0cff5
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/deleted.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_nat deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Delete all NAT configuration
+ vyos.rest.vyos_nat: &id001
+ state: deleted
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after delete
+ vyos.rest.vyos_nat:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered == {}
+
+ - name: Delete again (IDEMPOTENT)
+ vyos.rest.vyos_nat: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..1aca580
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/gathered.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_nat gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Gather NAT configuration
+ vyos.rest.vyos_nat:
+ state: gathered
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - "'nat' in result.gathered"
+ - "'source' in result.gathered.nat"
+ - "'destination' in result.gathered.nat"
+ - "'static' in result.gathered.nat"
+ - result.gathered.nat.source.rule | length == 2
+ - result.gathered.nat.source.rule[0].id == 100
+ - result.gathered.nat.source.rule[1].id == 101
+ - result.gathered.nat.destination.rule[0].id == 200
+ - result.gathered.nat.destination.rule[0].protocol == "tcp"
+ - result.gathered.nat.static.rule[0].id == 300
+ - result.gathered.nat.static.rule[0].inbound_interface == "eth0"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..c64fdb8
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/merged.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: START vyos_nat merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge NAT configuration
+ vyos.rest.vyos_nat: &id001
+ config:
+ nat:
+ source:
+ rule:
+ - id: 100
+ outbound_interface:
+ name: eth0
+ translation:
+ address: masquerade
+ destination:
+ rule:
+ - id: 200
+ protocol: tcp
+ inbound_interface:
+ name: eth0
+ destination:
+ address: 198.51.100.10
+ port: "80"
+ translation:
+ address: 192.168.1.10
+ port: "8080"
+ state: merged
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length > 0
+
+ - name: Merge again (IDEMPOTENT)
+ vyos.rest.vyos_nat: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..d753cc4
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/overridden.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: START vyos_nat overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Override - replaces all NAT with only one rule
+ vyos.rest.vyos_nat: &id001
+ config:
+ nat:
+ source:
+ rule:
+ - id: 999
+ outbound_interface:
+ name: eth0
+ translation:
+ address: masquerade
+ state: overridden
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after override
+ vyos.rest.vyos_nat:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered.nat.source.rule | length == 1
+ - gathered.gathered.nat.source.rule[0].id == 999
+ - "'destination' not in gathered.gathered.nat"
+ - "'static' not in gathered.gathered.nat"
+
+ - name: Override again (IDEMPOTENT)
+ vyos.rest.vyos_nat: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_nat/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_nat/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..67a16f7
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/tests/httpapi/replaced.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: START vyos_nat replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- block:
+ - include_tasks: _populate_config.yaml
+
+ - name: Replace source NAT - removes rule 101, keeps destination and static
+ vyos.rest.vyos_nat: &id001
+ config:
+ nat:
+ source:
+ rule:
+ - id: 100
+ outbound_interface:
+ name: eth0
+ translation:
+ address: masquerade
+ state: replaced
+ register: result
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather after replace
+ vyos.rest.vyos_nat:
+ state: gathered
+ register: gathered
+
+ - assert:
+ that:
+ - gathered.gathered.nat.source.rule | length == 1
+ - gathered.gathered.nat.source.rule[0].id == 100
+ - "'destination' in gathered.gathered.nat"
+ - "'static' in gathered.gathered.nat"
+
+ - name: Replace again (IDEMPOTENT)
+ vyos.rest.vyos_nat: *id001
+ register: result
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_nat/vars/main.yaml b/tests/integration/targets/vyos_nat/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_nat/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml
index 957e119..d831f18 100644
--- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_ntp_global deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all NTP configuration
register: result
vyos.rest.vyos_ntp_global: &id001
@@ -20,7 +20,7 @@
that:
- result.after.allow_clients == []
- result.after.listen_addresses == []
- - result.after.servers == {}
+ - result.after.servers == []
- name: Delete the existing configuration (IDEMPOTENT)
register: result
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml
index 73ee1ff..61a7d3d 100644
--- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_ntp_global gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather NTP configuration
register: result
vyos.rest.vyos_ntp_global:
@@ -16,8 +16,8 @@
- result.changed == false
- "'10.4.9.0/24' in result.gathered.allow_clients"
- "'10.1.9.16' in result.gathered.listen_addresses"
- - "'10.3.6.5' in result.gathered.servers"
- - "'server4.example.com' in result.gathered.servers"
+ - "'10.3.6.5' in result.gathered.servers | map(attribute='server')"
+ - "'server4.example.com' in result.gathered.servers | map(attribute='server')"
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml
index deee2c0..a405b81 100644
--- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml
@@ -3,9 +3,9 @@
msg: START vyos_ntp_global overridden integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Override the existing configuration with the provided configuration
register: result
vyos.rest.vyos_ntp_global: &id001
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml
index 77136fc..cd21412 100644
--- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_ntp_global replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace the existing configuration with the provided configuration
register: result
vyos.rest.vyos_ntp_global: &id001
@@ -31,8 +31,8 @@
that:
- "'10.4.9.0/24' not in gathered.gathered.allow_clients"
- "'10.99.99.0/24' in gathered.gathered.allow_clients"
- - "'server-new.example.com' in gathered.gathered.servers"
- - "'10.3.6.5' not in gathered.gathered.servers"
+ - "'server-new.example.com' in gathered.gathered.servers | map(attribute='server')"
+ - "'10.3.6.5' not in gathered.gathered.servers | map(attribute='server')"
- name: Replace the provided configuration (IDEMPOTENT)
register: result
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml
index d05e203..41daa42 100644
--- a/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml
@@ -8,58 +8,56 @@
- name: RTT - Apply base configuration
vyos.rest.vyos_ntp_global:
config:
+ allow_clients:
+ - 10.5.5.0/24
+ - 10.6.6.0/24
+ listen_addresses:
+ - 10.1.2.3
servers:
- - server: 10.3.6.5
+ - server: 203.0.113.10
options:
- - noselect
- prefer
- - server: server4.example.com
- options:
- - pool
- allow_clients:
- - 10.4.9.0/24
- listen_addresses:
- - 10.1.9.16
state: merged
- - name: RTT - Gather configuration
+ - name: RTT - Gather
register: gathered
vyos.rest.vyos_ntp_global:
state: gathered
- - name: RTT - Assert gathered matches applied
+ - name: RTT - Assert base configuration present
assert:
that:
- - "'10.3.6.5' in gathered.gathered.servers"
- - "'10.4.9.0/24' in gathered.gathered.allow_clients"
- - "'10.1.9.16' in gathered.gathered.listen_addresses"
+ - "'10.5.5.0/24' in gathered.gathered.allow_clients"
+ - "'10.6.6.0/24' in gathered.gathered.allow_clients"
+ - "'10.1.2.3' in gathered.gathered.listen_addresses"
+ - "'203.0.113.10' in gathered.gathered.servers | map(attribute='server')"
+ - (gathered.gathered.servers | selectattr('server', 'eq', '203.0.113.10') | first).options == ['prefer']
- - name: RTT - Modify configuration
+ - name: RTT - Modify configuration (remove a stale allow_client, add a server option)
vyos.rest.vyos_ntp_global:
config:
- servers:
- - server: 10.3.6.5
- options:
- - noselect
- - server: server5.example.com
allow_clients:
- - 10.4.8.0/24
+ - 10.5.5.0/24
listen_addresses:
- - 10.1.9.16
+ - 10.1.2.3
+ servers:
+ - server: 203.0.113.10
+ options:
+ - prefer
+ - nts
state: replaced
- - name: RTT - Gather modified configuration
+ - name: RTT - Gather after modify
register: gathered2
vyos.rest.vyos_ntp_global:
state: gathered
- - name: RTT - Assert modification applied correctly
+ - name: RTT - Assert stale entry removed and update applied
assert:
that:
- - "'server5.example.com' in gathered2.gathered.servers"
- - "'server4.example.com' not in gathered2.gathered.servers"
- - "'10.4.8.0/24' in gathered2.gathered.allow_clients"
- - "'10.4.9.0/24' not in gathered2.gathered.allow_clients"
+ - "'10.5.5.0/24' in gathered2.gathered.allow_clients"
+ - "'10.6.6.0/24' not in gathered2.gathered.allow_clients"
+ - (gathered2.gathered.servers | selectattr('server', 'eq', '203.0.113.10') | first).options | sort == ['nts', 'prefer']
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml
index 6cfb063..145cfaf 100644
--- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_prefix_lists deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all prefix_lists configuration
register: result
vyos.rest.vyos_prefix_lists: &id001
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml
index 083cb48..ce752a8 100644
--- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_prefix_lists gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather prefix_lists configuration
register: result
vyos.rest.vyos_prefix_lists:
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml
index bd8c5c1..8c9754a 100644
--- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_prefix_lists replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace prefix_lists configuration
register: result
vyos.rest.vyos_prefix_lists: &id001
diff --git a/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml b/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml
index ec80b23..f826d45 100644
--- a/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml
@@ -3,9 +3,9 @@
msg: START vyos_route_maps deleted integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all route_maps configuration
register: result
vyos.rest.vyos_route_maps: &id001
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml
index 494a23e..569d9b3 100644
--- a/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml
@@ -3,9 +3,9 @@
msg: START vyos_route_maps gathered integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather route_maps configuration
register: result
vyos.rest.vyos_route_maps:
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml
index dece9a8..6e06ab7 100644
--- a/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml
@@ -3,9 +3,9 @@
msg: START vyos_route_maps replaced integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace route_maps configuration
register: result
vyos.rest.vyos_route_maps: &id001
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml
index 641a46f..1646775 100644
--- a/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml
@@ -14,40 +14,150 @@
action: permit
match:
peer: 192.0.2.32
+ metric: 100
+ protocol: bgp
set:
- metric: "5"
+ metric: 5
+ as_path_exclude: "111"
+ aggregator:
+ as: 100
+ community:
+ add:
+ - "no-export"
+ - route_map: my_route_map
+ entries:
+ - sequence: 10
+ action: permit
+ continue_sequence: 20
+ - sequence: 20
+ action: permit
+ set:
+ large_community:
+ none: true
+ - route_map: test3
+ entries:
+ - sequence: 1
+ action: permit
+ match:
+ metric: 1
+ peer: 192.0.2.32
+ set:
+ local_preference: 4
+ metric: 5
+ metric_type: type-1
+ origin: egp
+ originator_id: 192.0.2.34
+ tag: 5
+ weight: 4
state: merged
- - name: RTT - Gather configuration
+ - name: RTT - Gather
register: gathered
vyos.rest.vyos_route_maps:
state: gathered
- - name: RTT - Assert gathered matches applied
+ - name: RTT - Assert base configuration present
assert:
that:
- - gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | list | length == 1
+ - "'RM-TEST-EXPORT-POLICY' in gathered.gathered | map(attribute='route_map')"
+ - "'my_route_map' in gathered.gathered | map(attribute='route_map')"
+ - "'test3' in gathered.gathered | map(attribute='route_map')"
+ - (gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].match.metric == 100
+ - (gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].match.protocol == 'bgp'
+ - (gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].set.aggregator.as_ == 100
+ - (gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].set.community.add == ['no-export']
+ - (gathered.gathered | selectattr('route_map', 'eq', 'my_route_map') | first).entries[0].continue_sequence == 20
+ - (gathered.gathered | selectattr('route_map', 'eq', 'my_route_map') | first).entries[1].set.large_community.none == true
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.local_preference == 4
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.metric_type == 'type-1'
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.origin == 'egp'
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.originator_id == '192.0.2.34'
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.tag == 5
+ - (gathered.gathered | selectattr('route_map', 'eq', 'test3') | first).entries[0].set.weight == 4
- - name: RTT - Modify configuration
+ - name: RTT - Modify configuration (replaced -- remove RM-TEST-EXPORT-POLICY's community, add a new route map)
vyos.rest.vyos_route_maps:
config:
- route_map: RM-TEST-EXPORT-POLICY
entries:
- sequence: 10
action: permit
+ match:
+ peer: 192.0.2.32
set:
- metric: "20"
+ metric: 5
+ as_path_exclude: "111"
+ aggregator:
+ as: 100
+ - route_map: my_route_map
+ entries:
+ - sequence: 10
+ action: permit
+ continue_sequence: 20
+ - sequence: 20
+ action: permit
+ set:
+ large_community:
+ none: true
state: replaced
- - name: RTT - Gather modified configuration
+ - name: RTT - Gather after modify
register: gathered2
vyos.rest.vyos_route_maps:
state: gathered
- - name: RTT - Assert modification applied correctly
+ - name: RTT - Assert stale community removed and match cleared, my_route_map untouched
+ assert:
+ that:
+ - "'community' not in (gathered2.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].set"
+ - "'metric' not in (gathered2.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].match"
+ - (gathered2.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | first).entries[0].set.aggregator.as_ == 100
+ - (gathered2.gathered | selectattr('route_map', 'eq', 'my_route_map') | first).entries[0].continue_sequence == 20
+
+ - name: RTT - Re-establish the original baseline
+ vyos.rest.vyos_route_maps: &baseline_config
+ config: "{{ gathered.gathered }}"
+ state: overridden
+
+ - name: RTT - Gather the re-established baseline
+ register: rebaselined
+ vyos.rest.vyos_route_maps:
+ state: gathered
+
+ - name: RTT - Apply an unrelated temporary route map
+ vyos.rest.vyos_route_maps:
+ config:
+ - route_map: temp_policy
+ entries:
+ - sequence: 5
+ action: deny
+ state: merged
+
+ - name: RTT - Revert to the original baseline via gather + overridden
+ register: reverted
+ vyos.rest.vyos_route_maps: *baseline_config
+
+ - name: RTT - Gather after revert
+ register: gathered3
+ vyos.rest.vyos_route_maps:
+ state: gathered
+
+ - name: RTT - Assert the revert exactly restores the baseline and is then idempotent
+ assert:
+ that:
+ - reverted.changed == true
+ - "'temp_policy' not in gathered3.gathered | map(attribute='route_map')"
+ - gathered3.gathered | symmetric_difference(rebaselined.gathered) == []
+
+ - name: RTT - Confirm reverted baseline is idempotent
+ register: reverted_again
+ vyos.rest.vyos_route_maps: *baseline_config
+
+ - name: RTT - Assert idempotent
assert:
that:
- - gathered2.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | list | length == 1
+ - reverted_again.changed == false
+ - reverted_again.commands == []
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml b/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml
index 1ba3569..80d9e23 100644
--- a/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml
index a626a26..9c1c288 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml
@@ -2,9 +2,9 @@
- debug:
msg: START vyos_snmp_server deleted integration tests on connection={{ ansible_connection }}
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Delete all snmp_server configuration
register: result
vyos.rest.vyos_snmp_server: &id001
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml
index 770845c..5956f51 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml
@@ -2,9 +2,9 @@
- debug:
msg: START vyos_snmp_server gathered integration tests on connection={{ ansible_connection }}
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Gather snmp_server configuration
register: result
vyos.rest.vyos_snmp_server:
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml
index d989272..e659731 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml
@@ -2,9 +2,9 @@
- debug:
msg: START vyos_snmp_server replaced integration tests on connection={{ ansible_connection }}
-- include_tasks: _populate_config.yaml
-
- block:
+ - include_tasks: _populate_config.yaml
+
- name: Replace snmp_server configuration
register: result
vyos.rest.vyos_snmp_server: &id001
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml
index 1d354b7..00bc93e 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml
@@ -8,46 +8,101 @@
- name: RTT - Apply base configuration
vyos.rest.vyos_snmp_server:
config:
+ contact: admin@example.com
communities:
- name: switches
authorization_type: rw
- contact: admin@example.com
+ - name: bridges
+ clients:
+ - 1.1.1.1
+ - 12.1.1.10
listen_addresses:
- address: 20.1.1.1
+ snmp_v3:
+ engine_id: "000000000000000000000002"
+ groups:
+ - group: admins
+ mode: rw
+ seclevel: priv
+ view: all
+ users:
+ - user: admin_user
+ group: admins
+ authentication:
+ type: sha
+ plaintext_key: authpass123
+ privacy:
+ type: aes
+ plaintext_key: privpass123
+ views:
+ - view: all
+ oid: "1.3.6.1.2.1.1"
+ mask: "ff.ff"
state: merged
- - name: RTT - Gather configuration
+ - name: RTT - Gather
register: gathered
vyos.rest.vyos_snmp_server:
state: gathered
- - name: RTT - Assert gathered matches applied
+ - name: RTT - Assert base configuration present
assert:
that:
- gathered.gathered.contact == "admin@example.com"
- - gathered.gathered.communities | selectattr('name', 'eq', 'switches') | list | length == 1
+ - "'switches' in gathered.gathered.communities | map(attribute='name')"
+ - "'bridges' in gathered.gathered.communities | map(attribute='name')"
+ - gathered.gathered.snmp_v3.engine_id == "000000000000000000000002"
+ - "'admins' in gathered.gathered.snmp_v3.groups | map(attribute='group')"
+ - (gathered.gathered.snmp_v3.users | selectattr('user', 'eq', 'admin_user') | first).authentication.type == 'sha'
+ - (gathered.gathered.snmp_v3.views | selectattr('view', 'eq', 'all') | first).oid == '1.3.6.1.2.1.1'
+ - (gathered.gathered.snmp_v3.views | selectattr('view', 'eq', 'all') | first).mask == 'ff.ff'
- - name: RTT - Modify configuration
+ - name: RTT - Modify configuration (remove a stale community, add a trap target)
vyos.rest.vyos_snmp_server:
config:
+ contact: admin@example.com
communities:
- name: switches
- authorization_type: ro
- contact: ops@example.com
+ authorization_type: rw
listen_addresses:
- address: 20.1.1.1
+ trap_target:
+ address: 203.0.113.5
+ community: switches
+ port: 162
+ snmp_v3:
+ engine_id: "000000000000000000000002"
+ groups:
+ - group: admins
+ mode: rw
+ seclevel: priv
+ view: all
+ users:
+ - user: admin_user
+ group: admins
+ authentication:
+ type: sha
+ privacy:
+ type: aes
+ views:
+ - view: all
+ oid: "1.3.6.1.2.1.1"
+ mask: "ff.ff"
state: replaced
- - name: RTT - Gather modified configuration
+ - name: RTT - Gather after modify
register: gathered2
vyos.rest.vyos_snmp_server:
state: gathered
- - name: RTT - Assert modification applied correctly
+ - name: RTT - Assert stale community removed and trap target added
assert:
that:
- - gathered2.gathered.contact == "ops@example.com"
- - gathered2.gathered.communities | selectattr('name', 'eq', 'switches') | map(attribute='authorization_type') | first == 'ro'
+ - "'bridges' not in gathered2.gathered.communities | map(attribute='name')"
+ - "'switches' in gathered2.gathered.communities | map(attribute='name')"
+ - gathered2.gathered.trap_target.address == "203.0.113.5"
+ - gathered2.gathered.trap_target.community == "switches"
+ - gathered2.gathered.trap_target.port == 162
always:
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_system/aliases b/tests/integration/targets/vyos_system/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_system/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_system/defaults/main.yaml b/tests/integration/targets/vyos_system/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_system/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_system/tasks/httpapi.yaml b/tests/integration/targets/vyos_system/tasks/httpapi.yaml
new file mode 100644
index 0000000..0ed3e42
--- /dev/null
+++ b/tests/integration/targets/vyos_system/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 | sort }}"
+
+- 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_system/tasks/main.yaml b/tests/integration/targets/vyos_system/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_system/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_system/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_system/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..f8a4750
--- /dev/null
+++ b/tests/integration/targets/vyos_system/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,12 @@
+---
+- name: Remove test system configuration
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ name_server:
+ - 8.8.8.8
+ - 8.8.4.4
+ - 1.1.1.1
+ domain_search:
+ - sub1.example.com
+ state: absent
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_system/tests/httpapi/absent.yaml b/tests/integration/targets/vyos_system/tests/httpapi/absent.yaml
new file mode 100644
index 0000000..f82e4d3
--- /dev/null
+++ b/tests/integration/targets/vyos_system/tests/httpapi/absent.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_system absent integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup system configuration
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ name_server:
+ - 8.8.8.8
+ state: present
+
+ - name: Remove domain name
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Remove domain name (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ - name: Remove name server
+ register: result
+ vyos.rest.vyos_system:
+ name_server:
+ - 8.8.8.8
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == true
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_system/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_system/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..cf5f46d
--- /dev/null
+++ b/tests/integration/targets/vyos_system/tests/httpapi/gathered.yaml
@@ -0,0 +1,14 @@
+---
+- debug:
+ msg: START vyos_system gathered integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Gather system configuration
+ register: result
+ vyos.rest.vyos_system:
+ state: present
+
+ - assert:
+ that:
+ - result.before['host-name'] is defined
+ - result.before['host-name'] | length > 0
diff --git a/tests/integration/targets/vyos_system/tests/httpapi/present.yaml b/tests/integration/targets/vyos_system/tests/httpapi/present.yaml
new file mode 100644
index 0000000..f830e60
--- /dev/null
+++ b/tests/integration/targets/vyos_system/tests/httpapi/present.yaml
@@ -0,0 +1,63 @@
+---
+- debug:
+ msg: START vyos_system present integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Configure domain and name servers
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ name_server:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: present
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Configure domain and name servers (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: lab.example.com
+ name_server:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: present
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ - name: Update domain name
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: new.example.com
+ state: present
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Update domain name (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_system:
+ domain_name: new.example.com
+ state: present
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
+
+ - name: Remove new domain name
+ vyos.rest.vyos_system:
+ domain_name: new.example.com
+ state: absent
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_system/vars/main.yaml b/tests/integration/targets/vyos_system/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_system/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_user/tasks/httpapi.yaml b/tests/integration/targets/vyos_user/tasks/httpapi.yaml
index 4147e6d..0ed3e42 100644
--- a/tests/integration/targets/vyos_user/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_user/tasks/httpapi.yaml
@@ -9,7 +9,7 @@
- name: Set test_items
ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
- name: Run test case (connection=httpapi)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
diff --git a/tests/integration/targets/vyos_vlan/aliases b/tests/integration/targets/vyos_vlan/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_vlan/defaults/main.yaml b/tests/integration/targets/vyos_vlan/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_vlan/tasks/httpapi.yaml b/tests/integration/targets/vyos_vlan/tasks/httpapi.yaml
new file mode 100644
index 0000000..217692f
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/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 | sort}}"
+
+- 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_vlan/tasks/main.yaml b/tests/integration/targets/vyos_vlan/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/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_vlan/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..a0959b8
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Remove test VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ - vlan_id: 20
+ interfaces: [eth1]
+ state: absent
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml
new file mode 100644
index 0000000..3547ed1
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: START vyos_vlan absent integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - name: Remove VLAN
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Remove VLAN (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..483f7ad
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_vlan gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ state: present
+
+ - name: Gather VLANs
+ register: result
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered | selectattr('vlan_id', 'eq', 10) | list | length == 1
+ - (result.gathered | selectattr('vlan_id', 'eq', 10) | first).description == 'VLAN10'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml
new file mode 100644
index 0000000..cfbec27
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_vlan present integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Configure VLANs
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Configure VLANs (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..e30032f
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml
@@ -0,0 +1,43 @@
+---
+- debug:
+ msg: START vyos_vlan round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Configure VLAN
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ interfaces: [eth1]
+ state: present
+
+ - name: RTT - Gather
+ register: gathered
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - gathered.gathered | selectattr('vlan_id', 'eq', 10) | list | length == 1
+
+ - name: RTT - Update description
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10-updated
+ interfaces: [eth1]
+ state: present
+
+ - name: RTT - Gather after update
+ register: gathered2
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - (gathered2.gathered | selectattr('vlan_id', 'eq', 10) | first).description == 'VLAN10-updated'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/vars/main.yaml b/tests/integration/targets/vyos_vlan/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here