diff options
| author | omnom62 <omnom62@outlook.com> | 2026-05-31 07:25:03 +1000 |
|---|---|---|
| committer | omnom62 <omnom62@outlook.com> | 2026-05-31 07:25:03 +1000 |
| commit | 6a161ed8f263e152ebfd227e669a51773de5a028 (patch) | |
| tree | efd9cef101e459daa021b98ba00e5f75d897048e /tests | |
| parent | f37d4e313154ea7ea40250849549065196fab722 (diff) | |
| download | rest.vyos-6a161ed8f263e152ebfd227e669a51773de5a028.tar.gz rest.vyos-6a161ed8f263e152ebfd227e669a51773de5a028.zip | |
updated tests
Diffstat (limited to 'tests')
70 files changed, 1281 insertions, 407 deletions
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..2557b70 --- /dev/null +++ b/tests/integration/targets/vyos_banner/tests/httpapi/_populate_config.yaml @@ -0,0 +1,11 @@ +--- +- name: Populate banner config for testing + vyos.rest.vyos_banner: + config: + banners: + - banner: pre-login + text: "Ansible test pre-login banner" + - banner: post-login + text: "Ansible test post-login banner" + state: merged + ignore_errors: true 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..cc56d27 --- /dev/null +++ b/tests/integration/targets/vyos_banner/tests/httpapi/_remove_config.yaml @@ -0,0 +1,5 @@ +--- +- name: Remove pre-existing banner config + 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..5d0db34 --- /dev/null +++ b/tests/integration/targets/vyos_banner/tests/httpapi/deleted.yaml @@ -0,0 +1,28 @@ +--- +- 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 all banner configuration + register: result + vyos.rest.vyos_banner: &id001 + state: deleted + + - assert: + that: + - result.changed == true + + - name: Delete banner configuration (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..027702a --- /dev/null +++ b/tests/integration/targets/vyos_banner/tests/httpapi/merged.yaml @@ -0,0 +1,32 @@ +--- +- debug: + msg: START vyos_banner merged integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge banner configuration + register: result + vyos.rest.vyos_banner: &id001 + config: + banners: + - banner: pre-login + text: "Ansible test pre-login banner" + state: merged + + - assert: + that: + - result.changed == true + + - name: Merge banner configuration (IDEMPOTENT) + register: result + vyos.rest.vyos_banner: *id001 + + - name: Assert idempotent + assert: + that: + - result.changed == false + - result.commands == [] + + 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_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/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..3bf4fb0 --- /dev/null +++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/_populate_config.yaml @@ -0,0 +1,13 @@ +--- +- 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 + ignore_errors: true 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/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 index f5a1f31..b1f6193 100644 --- a/tests/integration/targets/vyos_logging_global/tasks/main.yaml +++ b/tests/integration/targets/vyos_logging_global/tasks/main.yaml @@ -1,133 +1,5 @@ --- -# tests/integration/targets/vyos_logging_global/tasks/main.yaml - -- name: TEARDOWN — delete all syslog config before tests - vyos.rest.vyos_logging_global: - state: deleted - -# ------------------------------------------------------------------ -# MERGED -# ------------------------------------------------------------------ - -- name: MERGED — set initial logging config - register: result - 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 - -- name: ASSERT — merged changed - assert: - that: - - result.changed == true - -- name: MERGED — idempotency check - register: result - 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 - -- name: ASSERT — merged idempotent - assert: - that: - - result.changed == false - - result.commands | length == 0 - -# ------------------------------------------------------------------ -# GATHERED -# ------------------------------------------------------------------ - -- name: GATHERED — read current config - register: result - vyos.rest.vyos_logging_global: - state: gathered - -- name: ASSERT — gathered returns expected data - assert: - that: - - result.gathered is defined - -# ------------------------------------------------------------------ -# REPLACED -# ------------------------------------------------------------------ - -- name: REPLACED — replace with minimal config - register: result - vyos.rest.vyos_logging_global: - config: - console: - facilities: - - facility: local6 - state: replaced - -- name: ASSERT — replaced changed - assert: - that: - - result.changed == true - -- name: REPLACED — idempotency check - register: result - vyos.rest.vyos_logging_global: - config: - console: - facilities: - - facility: local6 - state: replaced - -- name: ASSERT — replaced idempotent - assert: - that: - - result.changed == false - -# ------------------------------------------------------------------ -# DELETED -# ------------------------------------------------------------------ - -- name: DELETED — remove all syslog config - register: result - vyos.rest.vyos_logging_global: - state: deleted - -- name: ASSERT — deleted changed - assert: - that: - - result.changed == true - -- name: DELETED — idempotency check - register: result - vyos.rest.vyos_logging_global: - state: deleted - -- name: ASSERT — deleted idempotent - assert: - that: - - result.changed == false +- 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_prefix_lists.old/aliases b/tests/integration/targets/vyos_prefix_lists.old/aliases new file mode 100644 index 0000000..cc0afef --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists.old/aliases @@ -0,0 +1 @@ +network/vyos diff --git a/tests/integration/targets/vyos_prefix_lists.old/tasks/main.yaml b/tests/integration/targets/vyos_prefix_lists.old/tasks/main.yaml new file mode 100644 index 0000000..e5c62cd --- /dev/null +++ b/tests/integration/targets/vyos_prefix_lists.old/tasks/main.yaml @@ -0,0 +1,144 @@ +--- +# tests/integration/targets/vyos_prefix_lists/tasks/main.yaml + +- name: TEARDOWN — delete all prefix lists before tests + vyos.rest.vyos_prefix_lists: + state: deleted + +# ------------------------------------------------------------------ +# MERGED +# ------------------------------------------------------------------ + +- name: MERGED — create prefix lists + register: result + 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 + +- name: ASSERT — merged changed + assert: + that: + - result.changed == true + +- name: MERGED — idempotency check + register: result + 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 + state: merged + +- name: ASSERT — merged idempotent + assert: + that: + - result.changed == false + - result.commands | length == 0 + +# ------------------------------------------------------------------ +# GATHERED +# ------------------------------------------------------------------ + +- name: GATHERED — read current prefix lists + register: result + vyos.rest.vyos_prefix_lists: + state: gathered + +- name: ASSERT — gathered has ipv4 entry + assert: + that: + - result.gathered | selectattr('afi','eq','ipv4') | list | length > 0 + +# ------------------------------------------------------------------ +# REPLACED +# ------------------------------------------------------------------ + +- name: REPLACED — replace AnsibleIPv4PrefixList + register: result + vyos.rest.vyos_prefix_lists: + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + entries: + - sequence: 10 + action: permit + prefix: 10.0.0.0/8 + state: replaced + +- name: ASSERT — replaced changed + assert: + that: + - result.changed == true + +- name: REPLACED — idempotency check + register: result + vyos.rest.vyos_prefix_lists: + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + entries: + - sequence: 10 + action: permit + prefix: 10.0.0.0/8 + state: replaced + +- name: ASSERT — replaced idempotent + assert: + that: + - result.changed == false + +# ------------------------------------------------------------------ +# DELETED +# ------------------------------------------------------------------ + +- name: DELETED — remove specific prefix list + register: result + vyos.rest.vyos_prefix_lists: + config: + - afi: ipv4 + prefix_lists: + - name: AnsibleIPv4PrefixList + state: deleted + +- name: ASSERT — deleted changed + assert: + that: + - result.changed == true + +- name: DELETED — remove all remaining + vyos.rest.vyos_prefix_lists: + state: deleted 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 index e5c62cd..b1f6193 100644 --- a/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml @@ -1,144 +1,5 @@ --- -# tests/integration/targets/vyos_prefix_lists/tasks/main.yaml - -- name: TEARDOWN — delete all prefix lists before tests - vyos.rest.vyos_prefix_lists: - state: deleted - -# ------------------------------------------------------------------ -# MERGED -# ------------------------------------------------------------------ - -- name: MERGED — create prefix lists - register: result - 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 - -- name: ASSERT — merged changed - assert: - that: - - result.changed == true - -- name: MERGED — idempotency check - register: result - 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 - state: merged - -- name: ASSERT — merged idempotent - assert: - that: - - result.changed == false - - result.commands | length == 0 - -# ------------------------------------------------------------------ -# GATHERED -# ------------------------------------------------------------------ - -- name: GATHERED — read current prefix lists - register: result - vyos.rest.vyos_prefix_lists: - state: gathered - -- name: ASSERT — gathered has ipv4 entry - assert: - that: - - result.gathered | selectattr('afi','eq','ipv4') | list | length > 0 - -# ------------------------------------------------------------------ -# REPLACED -# ------------------------------------------------------------------ - -- name: REPLACED — replace AnsibleIPv4PrefixList - register: result - vyos.rest.vyos_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: AnsibleIPv4PrefixList - entries: - - sequence: 10 - action: permit - prefix: 10.0.0.0/8 - state: replaced - -- name: ASSERT — replaced changed - assert: - that: - - result.changed == true - -- name: REPLACED — idempotency check - register: result - vyos.rest.vyos_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: AnsibleIPv4PrefixList - entries: - - sequence: 10 - action: permit - prefix: 10.0.0.0/8 - state: replaced - -- name: ASSERT — replaced idempotent - assert: - that: - - result.changed == false - -# ------------------------------------------------------------------ -# DELETED -# ------------------------------------------------------------------ - -- name: DELETED — remove specific prefix list - register: result - vyos.rest.vyos_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: AnsibleIPv4PrefixList - state: deleted - -- name: ASSERT — deleted changed - assert: - that: - - result.changed == true - -- name: DELETED — remove all remaining - vyos.rest.vyos_prefix_lists: - state: deleted +- name: Run httpapi tests + ansible.builtin.include_tasks: httpapi.yaml + tags: + - httpapi 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/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/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/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 index e8171dd..b1f6193 100644 --- a/tests/integration/targets/vyos_route_maps/tasks/main.yaml +++ b/tests/integration/targets/vyos_route_maps/tasks/main.yaml @@ -1,133 +1,5 @@ --- -# tests/integration/targets/vyos_route_maps/tasks/main.yaml - -- name: TEARDOWN — delete all route maps before tests - vyos.rest.vyos_route_maps: - state: deleted - -# ------------------------------------------------------------------ -# MERGED -# ------------------------------------------------------------------ - -- name: MERGED — create route map - register: result - 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 - -- name: ASSERT — merged changed - assert: - that: - - result.changed == true - -- name: MERGED — idempotency check - register: result - 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 - -- name: ASSERT — merged idempotent - assert: - that: - - result.changed == false - - result.commands | length == 0 - -# ------------------------------------------------------------------ -# GATHERED -# ------------------------------------------------------------------ - -- name: GATHERED — read current route maps - register: result - vyos.rest.vyos_route_maps: - state: gathered - -- name: ASSERT — gathered has expected route map - assert: - that: - - result.gathered | selectattr('route_map','eq','RM-TEST-EXPORT-POLICY') | list | length == 1 - -# ------------------------------------------------------------------ -# REPLACED -# ------------------------------------------------------------------ - -- name: REPLACED — replace route map with updated set - register: result - vyos.rest.vyos_route_maps: - config: - - route_map: RM-TEST-EXPORT-POLICY - entries: - - sequence: 10 - action: permit - set: - metric: "10" - state: replaced - -- name: ASSERT — replaced changed - assert: - that: - - result.changed == true - -- name: REPLACED — idempotency check - register: result - vyos.rest.vyos_route_maps: - config: - - route_map: RM-TEST-EXPORT-POLICY - entries: - - sequence: 10 - action: permit - set: - metric: "10" - state: replaced - -- name: ASSERT — replaced idempotent - assert: - that: - - result.changed == false - -# ------------------------------------------------------------------ -# DELETED -# ------------------------------------------------------------------ - -- name: DELETED — remove specific route map - register: result - vyos.rest.vyos_route_maps: - config: - - route_map: RM-TEST-EXPORT-POLICY - state: deleted - -- name: ASSERT — deleted changed - assert: - that: - - result.changed == true - -- name: DELETED — idempotency check - register: result - vyos.rest.vyos_route_maps: - state: deleted - -- name: ASSERT — deleted idempotent - assert: - that: - - result.changed == false +- 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/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/tasks/httpapi.yaml b/tests/integration/targets/vyos_snmp_server/tasks/httpapi.yaml new file mode 100644 index 0000000..4147e6d --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/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_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..c847765 --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_populate_config.yaml @@ -0,0 +1,15 @@ +--- +- 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 + ignore_errors: true 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..c77493a --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/_remove_config.yaml @@ -0,0 +1,5 @@ +--- +- name: Remove pre-existing snmp_server config + vyos.rest.vyos_snmp_server: + state: deleted + ignore_errors: true 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..90ee0ae --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/deleted.yaml @@ -0,0 +1,28 @@ +--- +- debug: + msg: START vyos_snmp_server deleted integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- 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..740446f --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/gathered.yaml @@ -0,0 +1,20 @@ +--- +- debug: + msg: START vyos_snmp_server gathered integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- 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..475b5fe --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/merged.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START vyos_snmp_server merged integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- 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..cd9bef2 --- /dev/null +++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/replaced.yaml @@ -0,0 +1,34 @@ +--- +- debug: + msg: START vyos_snmp_server replaced integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- 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 |
