diff options
| author | omnom62 <75066712+omnom62@users.noreply.github.com> | 2026-08-22 01:36:21 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-21 10:36:21 -0500 |
| commit | 7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff (patch) | |
| tree | 82dad9c7ca58b7c88ac25f2ef7b04413e259a260 /tests/integration/targets/vyos_user | |
| parent | cb738721c15ac01f49f66144dae80eb478331f77 (diff) | |
| download | rest.vyos-7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff.tar.gz rest.vyos-7a6b5e4f3a7a021cfa75faa7bf833741dfc09cff.zip | |
T8989: wave3 user, bgp_global, bgp_address_family, facts, firewall_global
* T8989: vyos_user module
* T8989: Wave 3 vyos_user module with integration and unit tests
* T8989: Wave 3 vyos_bgp_global module with integration and unit tests
* T8989: Wave 3 vyos_bgp_address_family module with integration and unit tests
* T8989: Add overridden integration tests for vyos_bgp_global and vyos_bgp_address_family
* T8989: vyos_facts
* T8989: Add vyos_facts integration and unit tests with fixtures
* T8989: vyos_firewall_global module
* T8989: vyos_firewall_global module with integration and unit tests
* T8989: vyos_firewall_rules module
* T8989: vyos_firewall_rules module with integration and unit tests
* T8989: vyos_firewall_interfaces module
* T8989: vyos_firewall_interfaces module
* T8989: vyos_firewall_interfaces UAT & SIT
* T8989: vyos_firewall_interfaces UAT & SIT
Diffstat (limited to 'tests/integration/targets/vyos_user')
10 files changed, 219 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_user/aliases b/tests/integration/targets/vyos_user/aliases new file mode 100644 index 0000000..cc0afef --- /dev/null +++ b/tests/integration/targets/vyos_user/aliases @@ -0,0 +1 @@ +network/vyos diff --git a/tests/integration/targets/vyos_user/defaults/main.yaml b/tests/integration/targets/vyos_user/defaults/main.yaml new file mode 100644 index 0000000..164afea --- /dev/null +++ b/tests/integration/targets/vyos_user/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/tests/integration/targets/vyos_user/tasks/httpapi.yaml b/tests/integration/targets/vyos_user/tasks/httpapi.yaml new file mode 100644 index 0000000..4147e6d --- /dev/null +++ b/tests/integration/targets/vyos_user/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_user/tasks/main.yaml b/tests/integration/targets/vyos_user/tasks/main.yaml new file mode 100644 index 0000000..b1f6193 --- /dev/null +++ b/tests/integration/targets/vyos_user/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_user/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_user/tests/httpapi/_remove_config.yaml new file mode 100644 index 0000000..54cf0f9 --- /dev/null +++ b/tests/integration/targets/vyos_user/tests/httpapi/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Remove test users + vyos.rest.vyos_user: + users: + - name: testuser + - name: testuser2 + state: absent + ignore_errors: true diff --git a/tests/integration/targets/vyos_user/tests/httpapi/absent.yaml b/tests/integration/targets/vyos_user/tests/httpapi/absent.yaml new file mode 100644 index 0000000..c89da2e --- /dev/null +++ b/tests/integration/targets/vyos_user/tests/httpapi/absent.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: START vyos_user absent integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Create users for deletion test + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User + password: S3cur3P@ss! + - name: testuser2 + full_name: Test User 2 + password: S3cur3P@ss! + state: present + + - name: Delete specific user + register: result + vyos.rest.vyos_user: + users: + - name: testuser + state: absent + + - assert: + that: + - result.changed == true + + - name: Delete specific user (IDEMPOTENT) + register: result + vyos.rest.vyos_user: + users: + - name: testuser + state: absent + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_user/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_user/tests/httpapi/gathered.yaml new file mode 100644 index 0000000..0f651e7 --- /dev/null +++ b/tests/integration/targets/vyos_user/tests/httpapi/gathered.yaml @@ -0,0 +1,28 @@ +--- +- debug: + msg: START vyos_user gathered integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Create user for gathering + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User + password: S3cur3P@ss! + state: present + + - name: Gather users + register: result + vyos.rest.vyos_user: + state: gathered + + - assert: + that: + - result.gathered | selectattr('name', 'eq', 'testuser') | list | length == 1 + - result.gathered | selectattr('name', 'eq', 'vyos') | list | length == 1 + - (result.gathered | selectattr('name', 'eq', 'testuser') | first).full_name == 'Test User' + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_user/tests/httpapi/present.yaml b/tests/integration/targets/vyos_user/tests/httpapi/present.yaml new file mode 100644 index 0000000..1797772 --- /dev/null +++ b/tests/integration/targets/vyos_user/tests/httpapi/present.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: START vyos_user present integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Create user + register: result + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User + password: S3cur3P@ss! + update_password: on_create + state: present + + - assert: + that: + - result.changed == true + + - name: Create user (IDEMPOTENT) + register: result + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User + password: S3cur3P@ss! + update_password: on_create + state: present + + - assert: + that: + - result.changed == false + - result.commands == [] + + - name: Update full_name + register: result + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User Updated + state: present + + - assert: + that: + - result.changed == true + + - name: Update full_name (IDEMPOTENT) + register: result + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User Updated + state: present + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_user/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_user/tests/httpapi/rtt.yaml new file mode 100644 index 0000000..6f35676 --- /dev/null +++ b/tests/integration/targets/vyos_user/tests/httpapi/rtt.yaml @@ -0,0 +1,45 @@ +--- +- debug: + msg: START vyos_user round trip integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: RTT - Create user + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User + password: S3cur3P@ss! + update_password: on_create + state: present + + - name: RTT - Gather + register: gathered + vyos.rest.vyos_user: + state: gathered + + - name: RTT - Assert user exists + assert: + that: + - gathered.gathered | selectattr('name', 'eq', 'testuser') | list | length == 1 + + - name: RTT - Update full_name + vyos.rest.vyos_user: + users: + - name: testuser + full_name: Test User Modified + state: present + + - name: RTT - Gather after update + register: gathered2 + vyos.rest.vyos_user: + state: gathered + + - name: RTT - Assert update applied + assert: + that: + - (gathered2.gathered | selectattr('name', 'eq', 'testuser') | first).full_name == 'Test User Modified' + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_user/vars/main.yaml b/tests/integration/targets/vyos_user/vars/main.yaml new file mode 100644 index 0000000..4303881 --- /dev/null +++ b/tests/integration/targets/vyos_user/vars/main.yaml @@ -0,0 +1,2 @@ +--- +# only common vars here |
