diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:27 +0000 |
commit | 3b0807ad7b283c46c21862eb826dcbb4ad04e5e2 (patch) | |
tree | 6461ea75f03eca87a5a90c86c3c9a787a6ad037e /ansible_collections/infoblox/nios_modules/tests | |
parent | Adding debian version 7.7.0+dfsg-3. (diff) | |
download | ansible-3b0807ad7b283c46c21862eb826dcbb4ad04e5e2.tar.xz ansible-3b0807ad7b283c46c21862eb826dcbb4ad04e5e2.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/infoblox/nios_modules/tests')
60 files changed, 1604 insertions, 20 deletions
diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml index b3fa8014d..0955a39f4 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_a_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_a_record_idempotence.yml +- include_tasks: nios_a_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml index 2fec2adb2..9096b63d8 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_aaaa_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_aaaa_record_idempotence.yml +- include_tasks: nios_aaaa_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml index b30f250a5..df8ff758d 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_cname_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_cname_record_idempotence.yml +- include_tasks: nios_cname_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml index 1eb9c07ab..2b9ca3a01 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dns_view/tasks/main.yml @@ -1 +1 @@ -- include: nios_dns_view_idempotence.yml +- include_tasks: nios_dns_view_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml new file mode 100644 index 000000000..f774bfbfb --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_http_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml new file mode 100644 index 000000000..8b3a4f404 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_http/tasks/nios_dtc_monitor_http_idempotence.yaml @@ -0,0 +1,75 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_create1 + +- name: Recreate a DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + port: 443 + secure: true + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_create2 + +- name: Add a comment to an existing DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_update1 + +- name: Readd a comment to an existing DTC HTTPS monitor + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_http_update2 + +- name: Remove a DTC HTTPS monitor from the system + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_http_delete1 + +- name: Reremove a DTC HTTPS monitor from the system + infoblox.nios_modules.nios_dtc_monitor_http: + name: https_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_http_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_http_create1.changed" + - "not dtc_monitor_http_create2.changed" + - "dtc_monitor_http_update1.changed" + - "not dtc_monitor_http_update2.changed" + - "dtc_monitor_http_delete1.changed" + - "not dtc_monitor_http_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml new file mode 100644 index 000000000..28bf85bde --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_icmp_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml new file mode 100644 index 000000000..984aa59a8 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_icmp/tasks/nios_dtc_monitor_icmp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_create1 + +- name: Recreate a DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_create2 + +- name: Add a comment to an existing DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_update1 + +- name: Readd a comment to an existing DTC ICMP monitor + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_update2 + +- name: Remove a DTC ICMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_delete1 + +- name: Reremove a DTC ICMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_icmp: + name: icmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_icmp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_icmp_create1.changed" + - "not dtc_monitor_icmp_create2.changed" + - "dtc_monitor_icmp_update1.changed" + - "not dtc_monitor_icmp_update2.changed" + - "dtc_monitor_icmp_delete1.changed" + - "not dtc_monitor_icmp_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml new file mode 100644 index 000000000..55829c8dc --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_pdp_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml new file mode 100644 index 000000000..022f12d76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_pdp/tasks/nios_dtc_monitor_pdp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_create1 + +- name: Recreate a DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_create2 + +- name: Add a comment to an existing DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_update1 + +- name: Readd a comment to an existing DTC PDP monitor + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_update2 + +- name: Remove a DTC PDP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_delete1 + +- name: Reremove a DTC PDP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_pdp: + name: pdp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_pdp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_pdp_create1.changed" + - "not dtc_monitor_pdp_create2.changed" + - "dtc_monitor_pdp_update1.changed" + - "not dtc_monitor_pdp_update2.changed" + - "dtc_monitor_pdp_delete1.changed" + - "not dtc_monitor_pdp_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml new file mode 100644 index 000000000..e5e1b33f5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_sip_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml new file mode 100644 index 000000000..68187a12b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_sip/tasks/nios_dtc_monitor_sip_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_create1 + +- name: Recreate a DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_create2 + +- name: Add a comment to an existing DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_update1 + +- name: Readd a comment to an existing DTC SIP monitor + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_update2 + +- name: Remove a DTC SIP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_delete1 + +- name: Reremove a DTC SIP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_sip: + name: sip_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_sip_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_sip_create1.changed" + - "not dtc_monitor_sip_create2.changed" + - "dtc_monitor_sip_update1.changed" + - "not dtc_monitor_sip_update2.changed" + - "dtc_monitor_sip_delete1.changed" + - "not dtc_monitor_sip_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml new file mode 100644 index 000000000..02c852d38 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_snmp_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml new file mode 100644 index 000000000..12b560470 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_snmp/tasks/nios_dtc_monitor_snmp_idempotence.yaml @@ -0,0 +1,71 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_create1 + +- name: Recreate a DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_create2 + +- name: Add a comment to an existing DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_update1 + +- name: Readd a comment to an existing DTC SNMP monitor + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_update2 + +- name: Remove a DTC SNMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_delete1 + +- name: Reremove a DTC SNMP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_snmp: + name: snmp_monitor + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_snmp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_snmp_create1.changed" + - "not dtc_monitor_snmp_create2.changed" + - "dtc_monitor_snmp_update1.changed" + - "not dtc_monitor_snmp_update2.changed" + - "dtc_monitor_snmp_delete1.changed" + - "not dtc_monitor_snmp_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml new file mode 100644 index 000000000..e24c82651 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_monitor_tcp_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml new file mode 100644 index 000000000..1c025b93b --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_monitor_tcp/tasks/nios_dtc_monitor_tcp_idempotence.yaml @@ -0,0 +1,78 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: absent + provider: "{{ nios_provider }}" + +- name: Create a DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_create1 + +- name: Recreate a DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_create2 + +- name: Add a comment to an existing DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_update1 + +- name: Readd a comment to an existing DTC TCP monitor + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_update2 + +- name: Remove a DTC TCP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_delete1 + +- name: Reremove a DTC TCP monitor from the system + infoblox.nios_modules.nios_dtc_monitor_tcp: + name: tcp_monitor + port: 8080 + state: absent + provider: "{{ nios_provider }}" + register: dtc_monitor_tcp_delete2 + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_monitor_tcp_create1.changed" + - "not dtc_monitor_tcp_create2.changed" + - "dtc_monitor_tcp_update1.changed" + - "not dtc_monitor_tcp_update2.changed" + - "dtc_monitor_tcp_delete1.changed" + - "not dtc_monitor_tcp_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/aliases b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/aliases new file mode 100644 index 000000000..b3138dc76 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/defaults/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/meta/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/meta/main.yaml new file mode 100644 index 000000000..1b01a972f --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/main.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/main.yaml new file mode 100644 index 000000000..8873ef552 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/main.yaml @@ -0,0 +1 @@ +- include_tasks: nios_dtc_topology_idempotence.yaml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml new file mode 100644 index 000000000..a24a9c31a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_dtc_topology/tasks/nios_dtc_topology_idempotence.yaml @@ -0,0 +1,122 @@ +- name: Clean up the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: absent + provider: "{{ nios_provider }}" + +- name: Create the parent object + infoblox.nios_modules.nios_zone: + name: ansible.com + state: present + provider: "{{ nios_provider }}" + +- name: Clean up the DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + +- name: Clean up the DTC pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + state: absent + provider: "{{ nios_provider }}" + +- name: Clean up the DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + state: absent + provider: "{{ nios_provider }}" + +- name: Create DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" + +- name: Create DTC Pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + servers: + - server: Server1 + ratio: 1 + comment: Created with Ansible + state: present + provider: "{{ nios_provider }}" + +- name: Create a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + rules: + - dest_type: POOL + destination_link: web_pool + return_type: REGULAR + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_create1 + +- name: Recreate a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_create2 + +- name: Add a comment to an existing DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_update1 + +- name: Readd a comment to an existing DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + comment: this is a test comment + state: present + provider: "{{ nios_provider }}" + register: dtc_topology_update2 + +- name: Remove a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + register: dtc_topology_delete1 + +- name: Reremove a DTC Topology + infoblox.nios_modules.nios_dtc_topology: + name: a_topology + state: absent + provider: "{{ nios_provider }}" + register: dtc_topology_delete2 + +- name: Remove the DTC pool + infoblox.nios_modules.nios_dtc_pool: + name: web_pool + lb_preferred_method: ROUND_ROBIN + state: absent + provider: "{{ nios_provider }}" + +- name: Remove the DTC server + infoblox.nios_modules.nios_dtc_server: + name: Server1 + host: 192.168.10.1 + state: absent + provider: "{{ nios_provider }}" + +- name: Verify outcomes + ansible.builtin.assert: + that: + - "dtc_topology_create1.changed" + - "not dtc_topology_create2.changed" + - "dtc_topology_update1.changed" + - "not dtc_topology_update2.changed" + - "dtc_topology_delete1.changed" + - "not dtc_topology_delete2.changed" diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml index 2f1dcc55e..3c626f557 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_host_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_host_record_idempotence.yml +- include_tasks: nios_host_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml index fe687173b..ebffb41ac 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_mx_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_mx_record_idempotence.yml +- include_tasks: nios_mx_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml index a22a8018c..ed94e8a3f 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_naptr_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_naptr_record_idempotence.yml +- include_tasks: nios_naptr_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml index c147af8f4..040cb8a8e 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network/tasks/main.yml @@ -1 +1 @@ -- include: nios_network_idempotence.yml +- include_tasks: nios_network_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml index 97e87148b..0acf4a4c3 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_network_view/tasks/main.yml @@ -1 +1 @@ -- include: nios_network_view_idempotence.yml +- include_tasks: nios_network_view_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml index ec33e8f53..29fbb5fe5 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_ptr_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_ptr_record_idempotence.yml +- include_tasks: nios_ptr_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml index 1c8476732..4e4dd1660 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_srv_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_srv_record_idempotence.yml +- include_tasks: nios_srv_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml index e15b4c55d..0acbc091f 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_txt_record/tasks/main.yml @@ -1 +1 @@ -- include: nios_txt_record_idempotence.yml +- include_tasks: nios_txt_record_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml index f066edcdb..cb335970a 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/nios_zone/tasks/main.yml @@ -1 +1 @@ -- include: nios_zone_idempotence.yml +- include_tasks: nios_zone_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml index 2a3092f3a..e3c03fb33 100644 --- a/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml +++ b/ansible_collections/infoblox/nios_modules/tests/integration/targets/prepare_nios_tests/tasks/main.yml @@ -1 +1 @@ -- include: prepare_nios_tests_idempotence.yml +- include_tasks: prepare_nios_tests_idempotence.yml diff --git a/ansible_collections/infoblox/nios_modules/tests/requirements.txt b/ansible_collections/infoblox/nios_modules/tests/requirements.txt index 7f835e9f4..708b417d1 100644 --- a/ansible_collections/infoblox/nios_modules/tests/requirements.txt +++ b/ansible_collections/infoblox/nios_modules/tests/requirements.txt @@ -4,6 +4,6 @@ pytest-xdist mock pytest-mock pytest-cov==2.8.0 -coverage +coverage==7.3.2 pygobject launchpadlib diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py index 9636c05bb..18d02fafa 100644 --- a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/module_utils/test_api.py @@ -5,8 +5,10 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type import copy - -from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest +try: + from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest +except ImportError: + import unittest from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock from ansible_collections.infoblox.nios_modules.plugins.module_utils import api diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py new file mode 100644 index 000000000..d053f0bfe --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py @@ -0,0 +1,136 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_http +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcHttpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_http + + def setUp(self): + super(TestNiosDtcHttpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_http.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcHttpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_http_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', + 'port': 443, 'secure': True, 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "port": {}, + "secure": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'https_monitor', + 'port': 443, 'secure': True}) + + def test_nios_dtc_monitor_http_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "https_monitor", + "port": 443, + "secure": True, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_http_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'https_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "https_monitor", + "port": 443, + "secure": True, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py new file mode 100644 index 000000000..fb4b300dd --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py @@ -0,0 +1,129 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_icmp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcIcmpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_icmp + + def setUp(self): + super(TestNiosDtcIcmpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_icmp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcIcmpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_icmp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'icmp_monitor'}) + + def test_nios_dtc_monitor_icmp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "icmp_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_icmp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'icmp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "icmp_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py new file mode 100644 index 000000000..802637840 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py @@ -0,0 +1,131 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_pdp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTcpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_pdp + + def setUp(self): + super(TestNiosDtcTcpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_pdp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTcpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_pdp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'pdp_monitor'}) + + def test_nios_dtc_monitor_pdp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "pdp_monitor", + "port": 2123, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_pdp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'pdp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "pdp_monitor", + "port": 2123, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py new file mode 100644 index 000000000..90b86bfa5 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py @@ -0,0 +1,129 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_sip +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcSipMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_sip + + def setUp(self): + super(TestNiosDtcSipMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_sip.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcSipMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_sip_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'sip_monitor'}) + + def test_nios_dtc_monitor_sip_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "sip_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_sip_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'sip_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "sip_monitor", + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py new file mode 100644 index 000000000..838a35ebd --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py @@ -0,0 +1,143 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_snmp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcSnmpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_snmp + + def setUp(self): + super(TestNiosDtcSnmpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_snmp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcSnmpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_snmp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', + 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'snmp_monitor'}) + + def test_nios_dtc_monitor_snmp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "snmp_monitor", + "port": 161, + "version": "V2C", + "community": "public", + "interval": 5, + "retry_down": 1, + "retry_up": 1, + "timeout": 15, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_snmp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'snmp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "snmp_monitor", + "port": 161, + "version": "V2C", + "community": "public", + "interval": 5, + "retry_down": 1, + "retry_up": 1, + "timeout": 15, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py new file mode 100644 index 000000000..072ba1a37 --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py @@ -0,0 +1,133 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_monitor_tcp +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTcpMonitorModule(TestNiosModule): + + module = nios_dtc_monitor_tcp + + def setUp(self): + super(TestNiosDtcTcpMonitorModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_monitor_tcp.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTcpMonitorModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_monitor_tcp_create(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', + 'port': 8080, 'comment': None, 'extattrs': None} + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "port": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with('testobject', {'name': 'tcp_monitor', + 'port': 8080}) + + def test_nios_dtc_monitor_tcp_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + "comment": "test comment", + "_ref": "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "name": "tcp_monitor", + "port": 8080, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_monitor_tcp_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'tcp_monitor', + 'comment': None, 'extattrs': None} + + ref = "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": "test comment", + "_ref": ref, + "name": "tcp_monitor", + "port": 8080, + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_topology.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_topology.py new file mode 100644 index 000000000..d0ee4c69a --- /dev/null +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/test_nios_dtc_topology.py @@ -0,0 +1,156 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dtc_topology +from ansible_collections.infoblox.nios_modules.plugins.module_utils import api +from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock +from .test_nios_module import TestNiosModule, load_fixture + + +class TestNiosDtcTopologyModule(TestNiosModule): + + module = nios_dtc_topology + + def setUp(self): + super(TestNiosDtcTopologyModule, self).setUp() + self.module = MagicMock(name='ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule') + self.module.check_mode = False + self.module.params = {'provider': None} + self.mock_wapi = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule') + self.exec_command = self.mock_wapi.start() + self.mock_wapi_run = patch('ansible_collections.infoblox.nios_modules.plugins.modules.nios_dtc_topology.WapiModule.run') + self.mock_wapi_run.start() + self.load_config = self.mock_wapi_run.start() + self.mock_check_type_dict = patch('ansible.module_utils.common.validation.check_type_dict') + self.mock_check_type_dict_obj = self.mock_check_type_dict.start() + + def tearDown(self): + super(TestNiosDtcTopologyModule, self).tearDown() + self.mock_wapi.stop() + self.mock_wapi_run.stop() + self.mock_check_type_dict.stop() + + def _get_wapi(self, test_object): + wapi = api.WapiModule(self.module) + wapi.get_object = Mock(name='get_object', return_value=test_object) + wapi.create_object = Mock(name='create_object') + wapi.update_object = Mock(name='update_object') + wapi.delete_object = Mock(name='delete_object') + return wapi + + def load_fixtures(self, commands=None): + self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) + self.load_config.return_value = dict(diff=None, session='session') + + def test_nios_dtc_topology_create(self): + self.module.params = { + 'provider': None, + 'state': 'present', + 'name': 'a_topology', + 'rules': [{ + 'dest_type': 'POOL', + 'destination_link': 'web_pool', + 'return_type': 'REGULAR' + }], + 'comment': None, + 'extattrs': None + } + + test_object = None + + test_spec = { + "name": {"ib_req": True}, + "rules": {}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.create_object.assert_called_once_with( + 'testobject', + { + 'name': 'a_topology', + 'rules': [{ + 'dest_type': 'POOL', + 'destination_link': 'web_pool', + 'return_type': 'REGULAR' + }] + } + ) + + def test_nios_dtc_topology_update_comment(self): + self.module.params = {'provider': None, 'state': 'present', 'name': 'a_topology', + 'comment': 'updated comment', 'extattrs': None} + + test_object = [ + { + '_ref': 'dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true', + 'name': 'a_topology', + 'rules': [{ + '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' + }], + 'comment': "test comment", + 'extattrs': {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + + def test_nios_dtc_topology_remove(self): + self.module.params = {'provider': None, 'state': 'absent', 'name': 'a_topology', + 'comment': None, 'extattrs': None} + + ref = "dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/false" + + test_object = [ + { + "comment": {}, + "_ref": ref, + "name": "a_topology", + 'rules': [{ + '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' + }], + "extattrs": {} + } + ] + + test_spec = { + "name": {"ib_req": True}, + "comment": {}, + "extattrs": {} + } + + wapi = self._get_wapi(test_object) + res = wapi.run('testobject', test_spec) + + self.assertTrue(res['changed']) + wapi.delete_object.assert_called_once_with(ref) diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py index 6a00fd25f..15e7ec14d 100644 --- a/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py +++ b/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/utils.py @@ -4,8 +4,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json - -from ansible_collections.community.general.tests.unit.compat import unittest +try: + from ansible_collections.community.general.tests.unit.compat import unittest +except ImportError: + import unittest from ansible_collections.community.general.tests.unit.compat.mock import patch from ansible.module_utils import basic from ansible.module_utils.common.text.converters import to_bytes diff --git a/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt b/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt index a0a2eb7ec..fc67ca9e7 100644 --- a/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt +++ b/ansible_collections/infoblox/nios_modules/tests/unit/requirements.txt @@ -5,4 +5,5 @@ pytest-xdist mock pytest-mock pytest-cov -coverage==4.5.4 +coverage==7.3.2 + |