summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_system
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_system')
-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
9 files changed, 169 insertions, 0 deletions
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