summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/network-integration.cfg4
-rw-r--r--tests/integration/targets/prepare_vyos_tests/meta/main.yaml2
-rw-r--r--tests/integration/targets/prepare_vyos_tests/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_banner/aliases1
-rw-r--r--tests/integration/targets/vyos_banner/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_banner/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_banner/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/_populate_config.yaml14
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml30
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml34
-rw-r--r--tests/integration/targets/vyos_banner/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_configure/aliases1
-rw-r--r--tests/integration/targets/vyos_configure/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_configure/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_configure/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_configure/tests/httpapi/configure.yaml52
-rw-r--r--tests/integration/targets/vyos_configure/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_hostname/aliases1
-rw-r--r--tests/integration/targets/vyos_hostname/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_hostname/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_hostname/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/_populate_config.yaml6
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/_remove_config.yaml7
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml19
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/merged.yaml30
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml30
-rw-r--r--tests/integration/targets/vyos_hostname/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_global/aliases1
-rw-r--r--tests/integration/targets/vyos_lldp_global/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_lldp_global/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/_populate_config.yaml20
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/merged.yaml36
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml35
-rw-r--r--tests/integration/targets/vyos_lldp_global/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_logging_global/aliases1
-rw-r--r--tests/integration/targets/vyos_logging_global/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_logging_global/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml21
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/merged.yaml44
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml33
-rw-r--r--tests/integration/targets/vyos_logging_global/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_ntp_global/aliases1
-rw-r--r--tests/integration/targets/vyos_ntp_global/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_ntp_global/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/_populate_config.yaml21
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml35
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml23
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/merged.yaml38
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml41
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml48
-rw-r--r--tests/integration/targets/vyos_ntp_global/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_prefix_lists/aliases1
-rw-r--r--tests/integration/targets/vyos_prefix_lists/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml42
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml28
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml37
-rw-r--r--tests/integration/targets/vyos_prefix_lists/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_route_maps/aliases1
-rw-r--r--tests/integration/targets/vyos_route_maps/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_route_maps/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/_populate_config.yaml17
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/merged.yaml40
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml36
-rw-r--r--tests/integration/targets/vyos_route_maps/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_snmp_server/aliases1
-rw-r--r--tests/integration/targets/vyos_snmp_server/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_snmp_server/meta/main.yaml3
-rw-r--r--tests/integration/targets/vyos_snmp_server/tasks/cleanup.yaml5
-rw-r--r--tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml24
-rw-r--r--tests/integration/targets/vyos_snmp_server/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/_populate_config.yaml16
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml27
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml19
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/merged.yaml36
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml33
-rw-r--r--tests/integration/targets/vyos_snmp_server/vars/main.yaml2
98 files changed, 1505 insertions, 0 deletions
diff --git a/tests/integration/network-integration.cfg b/tests/integration/network-integration.cfg
new file mode 100644
index 0000000..d12c1ef
--- /dev/null
+++ b/tests/integration/network-integration.cfg
@@ -0,0 +1,4 @@
+[persistent_connection]
+command_timeout = 100
+connect_timeout = 100
+connect_retry_timeout = 100
diff --git a/tests/integration/targets/prepare_vyos_tests/meta/main.yaml b/tests/integration/targets/prepare_vyos_tests/meta/main.yaml
new file mode 100644
index 0000000..61d3ffe
--- /dev/null
+++ b/tests/integration/targets/prepare_vyos_tests/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+allow_duplicates: true
diff --git a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
new file mode 100644
index 0000000..9527685
--- /dev/null
+++ b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Add dummy loopback address for SNMP listen test
+ vyos.rest.vyos_configure:
+ commands:
+ - set interfaces loopback lo address 20.1.1.1/32
diff --git a/tests/integration/targets/vyos_banner/aliases b/tests/integration/targets/vyos_banner/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_banner/defaults/main.yaml b/tests/integration/targets/vyos_banner/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_banner/tasks/httpapi.yaml b/tests/integration/targets/vyos_banner/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_banner/tasks/main.yaml b/tests/integration/targets/vyos_banner/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/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_banner/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..7bd2698
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,14 @@
+---
+- name: Populate pre-login banner for testing
+ vyos.rest.vyos_banner:
+ config:
+ banner: pre-login
+ text: "Ansible test pre-login banner"
+ state: merged
+
+- name: Populate post-login banner for testing
+ vyos.rest.vyos_banner:
+ config:
+ banner: post-login
+ text: "Ansible test post-login banner"
+ state: merged
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..2b43847
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove all banners
+ vyos.rest.vyos_banner:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..82e0f6e
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_banner deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete pre-login banner
+ register: result
+ vyos.rest.vyos_banner: &id001
+ config:
+ banner: pre-login
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete pre-login banner (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_banner: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..a51ff48
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_banner gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather banner configuration
+ register: result
+ vyos.rest.vyos_banner:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..96a984e
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_banner gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather all banners (no config specified)
+ register: result
+ vyos.rest.vyos_banner:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered is defined
+ - "'pre-login' in result.gathered"
+ - "'post-login' in result.gathered"
+
+ - name: Gather specific pre-login banner
+ register: result
+ vyos.rest.vyos_banner:
+ config:
+ banner: pre-login
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered.text == "Ansible test pre-login banner"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_banner/vars/main.yaml b/tests/integration/targets/vyos_banner/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_configure/aliases b/tests/integration/targets/vyos_configure/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_configure/defaults/main.yaml b/tests/integration/targets/vyos_configure/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_configure/tasks/httpapi.yaml b/tests/integration/targets/vyos_configure/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_configure/tasks/main.yaml b/tests/integration/targets/vyos_configure/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/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_configure/tests/httpapi/configure.yaml b/tests/integration/targets/vyos_configure/tests/httpapi/configure.yaml
new file mode 100644
index 0000000..2f95df3
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/tests/httpapi/configure.yaml
@@ -0,0 +1,52 @@
+---
+- debug:
+ msg: START vyos_configure integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Set a loopback address via vyos_configure
+ register: result
+ vyos.rest.vyos_configure:
+ commands:
+ - set interfaces loopback lo address 192.0.2.100/32
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length == 1
+ - result.commands[0][0] == "set"
+ - result.commands[0][1] == ["interfaces", "loopback", "lo", "address", "192.0.2.100/32"]
+
+ - name: Set multiple commands in one atomic commit
+ register: result
+ vyos.rest.vyos_configure:
+ commands:
+ - set interfaces loopback lo address 192.0.2.101/32
+ - set interfaces loopback lo address 192.0.2.102/32
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length == 2
+
+ - name: Delete loopback addresses
+ register: result
+ vyos.rest.vyos_configure:
+ commands:
+ - delete interfaces loopback lo address 192.0.2.100/32
+ - delete interfaces loopback lo address 192.0.2.101/32
+ - delete interfaces loopback lo address 192.0.2.102/32
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length == 3
+ - result.commands[0][0] == "delete"
+
+ always:
+ - name: Cleanup — remove test loopback addresses
+ vyos.rest.vyos_configure:
+ commands:
+ - delete interfaces loopback lo address 192.0.2.100/32
+ - delete interfaces loopback lo address 192.0.2.101/32
+ - delete interfaces loopback lo address 192.0.2.102/32
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_configure/vars/main.yaml b/tests/integration/targets/vyos_configure/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_configure/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_hostname/aliases b/tests/integration/targets/vyos_hostname/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_hostname/defaults/main.yaml b/tests/integration/targets/vyos_hostname/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml b/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_hostname/tasks/main.yaml b/tests/integration/targets/vyos_hostname/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/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_hostname/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..c6d2583
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Populate hostname for testing
+ vyos.rest.vyos_hostname:
+ config:
+ hostname: ansible-test-host
+ state: merged
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..a6f7aeb
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Reset hostname to default
+ vyos.rest.vyos_hostname:
+ config:
+ hostname: vyos
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..dfc8896
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/gathered.yaml
@@ -0,0 +1,19 @@
+---
+- debug:
+ msg: START vyos_hostname gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather hostname configuration
+ register: result
+ vyos.rest.vyos_hostname:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered.hostname == "ansible-test-host"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..d815d53
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/merged.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_hostname merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge hostname configuration
+ register: result
+ vyos.rest.vyos_hostname: &id001
+ config:
+ hostname: ansible-test-host
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge hostname configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_hostname: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..b4e318d
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/replaced.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_hostname replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace hostname configuration
+ register: result
+ vyos.rest.vyos_hostname: &id001
+ config:
+ hostname: ansible-replaced-host
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace hostname configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_hostname: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_hostname/vars/main.yaml b/tests/integration/targets/vyos_hostname/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_lldp_global/aliases b/tests/integration/targets/vyos_lldp_global/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_lldp_global/defaults/main.yaml b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lldp_global/tasks/main.yaml b/tests/integration/targets/vyos_lldp_global/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/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_lldp_global/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..6c3acf4
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,20 @@
+---
+- name: Configure SNMP first (required for LLDP snmp)
+ vyos.rest.vyos_snmp_server:
+ config:
+ communities:
+ - name: lldp-test
+ authorization_type: ro
+ state: merged
+
+- name: Populate lldp_global config for testing
+ vyos.rest.vyos_lldp_global:
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.17
+ snmp: enable
+ legacy_protocols:
+ - cdp
+ - sonmp
+ state: merged
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..9e3b01d
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing lldp_global config
+ vyos.rest.vyos_lldp_global:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..d084d4a
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_lldp_global deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all lldp_global configuration
+ register: result
+ vyos.rest.vyos_lldp_global: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete lldp_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..20ac2b2
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_lldp_global gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather lldp_global configuration
+ register: result
+ vyos.rest.vyos_lldp_global:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..a4c9bec
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/merged.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_lldp_global merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge lldp_global configuration
+ register: result
+ vyos.rest.vyos_lldp_global: &id001
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.17
+ snmp: enable
+ legacy_protocols:
+ - cdp
+ - sonmp
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge lldp_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..d5523eb
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/replaced.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace lldp_global configuration
+ register: result
+ vyos.rest.vyos_lldp_global: &id001
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.99
+ legacy_protocols:
+ - cdp
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace lldp_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/vars/main.yaml b/tests/integration/targets/vyos_lldp_global/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_logging_global/aliases b/tests/integration/targets/vyos_logging_global/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_logging_global/defaults/main.yaml b/tests/integration/targets/vyos_logging_global/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_logging_global/tasks/main.yaml b/tests/integration/targets/vyos_logging_global/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/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_logging_global/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..c081853
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,21 @@
+---
+- name: Populate logging_global config for testing
+ vyos.rest.vyos_logging_global:
+ config:
+ console:
+ facilities:
+ - facility: local7
+ severity: err
+ hosts:
+ - hostname: 172.16.0.1
+ port: 514
+ facilities:
+ - facility: local7
+ severity: all
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+ preserve_fqdn: true
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..14975a5
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing logging_global config
+ vyos.rest.vyos_logging_global:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..8c62627
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_logging_global deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all logging_global configuration
+ register: result
+ vyos.rest.vyos_logging_global: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete logging_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_logging_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..667c088
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_logging_global gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather logging_global configuration
+ register: result
+ vyos.rest.vyos_logging_global:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..daa1c2a
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/merged.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_logging_global merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge logging_global configuration
+ register: result
+ vyos.rest.vyos_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: local7
+ severity: err
+ hosts:
+ - hostname: 172.16.0.1
+ port: 514
+ facilities:
+ - facility: local7
+ severity: all
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+ preserve_fqdn: true
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge logging_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_logging_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..a1c24c0
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/replaced.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_logging_global replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace logging_global configuration
+ register: result
+ vyos.rest.vyos_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: local6
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace logging_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_logging_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/vars/main.yaml b/tests/integration/targets/vyos_logging_global/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_ntp_global/aliases b/tests/integration/targets/vyos_ntp_global/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_ntp_global/defaults/main.yaml b/tests/integration/targets/vyos_ntp_global/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_ntp_global/tasks/main.yaml b/tests/integration/targets/vyos_ntp_global/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/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_ntp_global/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..aac01d9
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,21 @@
+---
+- name: Populate NTP config for testing
+ vyos.rest.vyos_ntp_global:
+ config:
+ allow_clients:
+ - 10.4.9.0/24
+ - 10.4.7.0/24
+ listen_addresses:
+ - 10.1.9.16
+ servers:
+ - server: 10.3.6.5
+ options:
+ - noselect
+ - prefer
+ - server: server4.example.com
+ options:
+ - pool
+ - noselect
+ - server: server5.example.com
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..4355886
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing ntp_global config
+ vyos.rest.vyos_ntp_global:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..957e119
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/deleted.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_ntp_global deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all NTP configuration
+ register: result
+ vyos.rest.vyos_ntp_global: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Assert after is empty
+ assert:
+ that:
+ - result.after.allow_clients == []
+ - result.after.listen_addresses == []
+ - result.after.servers == {}
+
+ - name: Delete the existing configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ntp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..73ee1ff
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- debug:
+ msg: START vyos_ntp_global gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather NTP configuration
+ register: result
+ vyos.rest.vyos_ntp_global:
+ state: gathered
+
+ - assert:
+ that:
+ - 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"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..613704a
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/merged.yaml
@@ -0,0 +1,38 @@
+---
+- debug:
+ msg: START vyos_ntp_global merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ vyos.rest.vyos_ntp_global: &id001
+ config:
+ allow_clients:
+ - 10.6.6.0/24
+ listen_addresses:
+ - 10.1.3.1
+ servers:
+ - server: 203.0.113.0
+ options:
+ - prefer
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.commands | length > 0
+
+ - name: Merge the provided configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ntp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ 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
new file mode 100644
index 0000000..deee2c0
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/overridden.yaml
@@ -0,0 +1,41 @@
+---
+- debug:
+ msg: START vyos_ntp_global overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override the existing configuration with the provided configuration
+ register: result
+ vyos.rest.vyos_ntp_global: &id001
+ config:
+ allow_clients:
+ - 10.3.3.0/24
+ listen_addresses:
+ - 10.7.8.1
+ servers:
+ - server: server1
+ options:
+ - prefer
+ - server: server2
+ options:
+ - noselect
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override the provided configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ntp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..77136fc
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/replaced.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_ntp_global replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace the existing configuration with the provided configuration
+ register: result
+ vyos.rest.vyos_ntp_global: &id001
+ config:
+ allow_clients:
+ - 10.99.99.0/24
+ servers:
+ - server: server-new.example.com
+ options:
+ - prefer
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Verify old entries removed
+ vyos.rest.vyos_ntp_global:
+ state: gathered
+ register: gathered
+
+ - assert:
+ 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"
+
+ - name: Replace the provided configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ntp_global: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/vars/main.yaml b/tests/integration/targets/vyos_ntp_global/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_prefix_lists/aliases b/tests/integration/targets/vyos_prefix_lists/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml b/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml b/tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml b/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/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_prefix_lists/tests/httpapi/_deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml
new file mode 100644
index 0000000..6cfb063
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_prefix_lists deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all prefix_lists configuration
+ register: result
+ vyos.rest.vyos_prefix_lists: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete prefix_lists configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_prefix_lists: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml
new file mode 100644
index 0000000..083cb48
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_prefix_lists gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather prefix_lists configuration
+ register: result
+ vyos.rest.vyos_prefix_lists:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('afi','eq','ipv4') | list | length > 0
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml
new file mode 100644
index 0000000..a70f826
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_merged.yaml
@@ -0,0 +1,42 @@
+---
+- debug:
+ msg: START vyos_prefix_lists merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge prefix_lists configuration
+ register: result
+ vyos.rest.vyos_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: AnsibleIPv4PrefixList
+ description: PL configured by ansible
+ entries:
+ - sequence: 2
+ action: permit
+ prefix: 92.168.10.0/26
+ le: 32
+ - sequence: 3
+ action: deny
+ prefix: 72.168.2.0/24
+ ge: 26
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge prefix_lists configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_prefix_lists: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..9d73f0b
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,28 @@
+---
+- name: Populate prefix_lists config for testing
+ vyos.rest.vyos_prefix_lists:
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: AnsibleIPv4PrefixList
+ description: PL configured by ansible
+ entries:
+ - sequence: 2
+ action: permit
+ prefix: 92.168.10.0/26
+ le: 32
+ - sequence: 3
+ action: deny
+ prefix: 72.168.2.0/24
+ ge: 26
+ - afi: ipv6
+ prefix_lists:
+ - name: AllowIPv6Prefix
+ description: Configured by ansible for allowing IPv6 networks
+ entries:
+ - sequence: 5
+ action: permit
+ prefix: 2001:db8:8000::/35
+ le: 37
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..043fb3e
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing prefix_lists config
+ vyos.rest.vyos_prefix_lists:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml
new file mode 100644
index 0000000..bd8c5c1
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_replaced.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_prefix_lists replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace prefix_lists configuration
+ register: result
+ vyos.rest.vyos_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: AnsibleIPv4PrefixList
+ entries:
+ - sequence: 10
+ action: permit
+ prefix: 10.0.0.0/8
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace prefix_lists configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_prefix_lists: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_route_maps/aliases b/tests/integration/targets/vyos_route_maps/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_route_maps/defaults/main.yaml b/tests/integration/targets/vyos_route_maps/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml b/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_route_maps/tasks/main.yaml b/tests/integration/targets/vyos_route_maps/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/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_route_maps/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..adcaf55
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,17 @@
+---
+- name: Populate route_maps config for testing
+ 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: "5"
+ as_path_exclude: "111"
+ aggregator:
+ as: 100
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..de02f54
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing route_maps config
+ vyos.rest.vyos_route_maps:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..ec80b23
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_route_maps deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all route_maps configuration
+ register: result
+ vyos.rest.vyos_route_maps: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete route_maps configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_route_maps: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..494a23e
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_route_maps gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather route_maps configuration
+ register: result
+ vyos.rest.vyos_route_maps:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('route_map','eq','RM-TEST-EXPORT-POLICY') | list | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..c8c9474
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/merged.yaml
@@ -0,0 +1,40 @@
+---
+- debug:
+ msg: START vyos_route_maps merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge route_maps configuration
+ register: result
+ vyos.rest.vyos_route_maps: &id001
+ config:
+ - route_map: RM-TEST-EXPORT-POLICY
+ entries:
+ - sequence: 10
+ action: permit
+ match:
+ peer: 192.0.2.32
+ set:
+ metric: "5"
+ as_path_exclude: "111"
+ aggregator:
+ as: 100
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge route_maps configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_route_maps: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..dece9a8
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/replaced.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_route_maps replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace route_maps configuration
+ register: result
+ vyos.rest.vyos_route_maps: &id001
+ config:
+ - route_map: RM-TEST-EXPORT-POLICY
+ entries:
+ - sequence: 10
+ action: permit
+ set:
+ metric: "10"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace route_maps configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_route_maps: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_route_maps/vars/main.yaml b/tests/integration/targets/vyos_route_maps/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_snmp_server/aliases b/tests/integration/targets/vyos_snmp_server/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_snmp_server/defaults/main.yaml b/tests/integration/targets/vyos_snmp_server/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_snmp_server/meta/main.yaml b/tests/integration/targets/vyos_snmp_server/meta/main.yaml
new file mode 100644
index 0000000..7413320
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_vyos_tests
diff --git a/tests/integration/targets/vyos_snmp_server/tasks/cleanup.yaml b/tests/integration/targets/vyos_snmp_server/tasks/cleanup.yaml
new file mode 100644
index 0000000..d861c1b
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tasks/cleanup.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove dummy loopback address
+ vyos.rest.vyos_configure:
+ commands:
+ - delete interfaces loopback lo address 20.1.1.1/32
diff --git a/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml b/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml
new file mode 100644
index 0000000..1ba3569
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml
@@ -0,0 +1,24 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: Post-test cleanup
+ ansible.builtin.include_tasks: cleanup.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tasks/main.yaml b/tests/integration/targets/vyos_snmp_server/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/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_snmp_server/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..d3762c1
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,16 @@
+---
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- name: Populate snmp_server config for testing
+ vyos.rest.vyos_snmp_server:
+ config:
+ communities:
+ - name: switches
+ authorization_type: rw
+ - name: bridges
+ clients:
+ - 1.1.1.1
+ contact: admin@example.com
+ listen_addresses:
+ - address: 20.1.1.1
+ state: merged
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..e954df7
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+# _remove_config.yaml
+---
+- name: Remove pre-existing snmp_server config
+ vyos.rest.vyos_snmp_server:
+ state: deleted
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..a626a26
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml
@@ -0,0 +1,27 @@
+---
+- debug:
+ msg: START vyos_snmp_server deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all snmp_server configuration
+ register: result
+ vyos.rest.vyos_snmp_server: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete snmp_server configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_snmp_server: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..770845c
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml
@@ -0,0 +1,19 @@
+---
+- debug:
+ msg: START vyos_snmp_server gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather snmp_server configuration
+ register: result
+ vyos.rest.vyos_snmp_server:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered is defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..e1c6531
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/merged.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_snmp_server merged integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Merge snmp_server configuration
+ register: result
+ vyos.rest.vyos_snmp_server: &id001
+ config:
+ communities:
+ - name: switches
+ authorization_type: rw
+ - name: bridges
+ clients:
+ - 1.1.1.1
+ contact: admin@example.com
+ listen_addresses:
+ - address: 20.1.1.1
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge snmp_server configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_snmp_server: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..d989272
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_snmp_server replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace snmp_server configuration
+ register: result
+ vyos.rest.vyos_snmp_server: &id001
+ config:
+ communities:
+ - name: routers
+ authorization_type: ro
+ location: "RDU, NC"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace snmp_server configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_snmp_server: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/vars/main.yaml b/tests/integration/targets/vyos_snmp_server/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here