mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Nios integration and unit tests for all remaining nios new modules (#43399)
* new nios module support * new nios module support * new nios module support * new nios module support * new nios module support * new nios module support * new nios module support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * new nios module integration test support * test/integration/targets/nios_naptr_record/tasks/nios_naptr_record_idempotence.yml new nios module integration test support * fix pep8 error * fix pep8 error * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end * adding newline at end
This commit is contained in:
parent
7314aa7298
commit
e96f90b440
45 changed files with 1414 additions and 8 deletions
|
@ -47,6 +47,13 @@ NIOS_IPV4_NETWORK = 'network'
|
|||
NIOS_IPV6_NETWORK = 'ipv6network'
|
||||
NIOS_ZONE = 'zone_auth'
|
||||
NIOS_PTR_RECORD = 'record:ptr'
|
||||
NIOS_A_RECORD = 'record:a'
|
||||
NIOS_AAAA_RECORD = 'record:aaaa'
|
||||
NIOS_CNAME_RECORD = 'record:cname'
|
||||
NIOS_MX_RECORD = 'record:mx'
|
||||
NIOS_SRV_RECORD = 'record:srv'
|
||||
NIOS_NAPTR_RECORD = 'record:naptr'
|
||||
NIOS_TXT_RECORD = 'record:txt'
|
||||
|
||||
|
||||
NIOS_PROVIDER_SPEC = {
|
||||
|
|
|
@ -109,6 +109,7 @@ RETURN = ''' # '''
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.net_tools.nios.api import WapiModule
|
||||
from ansible.module_utils.net_tools.nios.api import NIOS_A_RECORD
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -139,7 +140,7 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
wapi = WapiModule(module)
|
||||
result = wapi.run('record:a', ib_spec)
|
||||
result = wapi.run(NIOS_A_RECORD, ib_spec)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ RETURN = ''' # '''
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.net_tools.nios.api import WapiModule
|
||||
from ansible.module_utils.net_tools.nios.api import NIOS_AAAA_RECORD
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -139,7 +140,7 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
wapi = WapiModule(module)
|
||||
result = wapi.run('record:aaaa', ib_spec)
|
||||
result = wapi.run(NIOS_AAAA_RECORD, ib_spec)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ RETURN = ''' # '''
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.net_tools.nios.api import WapiModule
|
||||
from ansible.module_utils.net_tools.nios.api import NIOS_CNAME_RECORD
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -139,7 +140,7 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
wapi = WapiModule(module)
|
||||
result = wapi.run('record:cname', ib_spec)
|
||||
result = wapi.run(NIOS_CNAME_RECORD, ib_spec)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ RETURN = ''' # '''
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.net_tools.nios.api import WapiModule
|
||||
from ansible.module_utils.net_tools.nios.api import NIOS_MX_RECORD
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -147,7 +148,7 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
wapi = WapiModule(module)
|
||||
result = wapi.run('record:mx', ib_spec)
|
||||
result = wapi.run(NIOS_MX_RECORD, ib_spec)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ RETURN = ''' # '''
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.net_tools.nios.api import WapiModule
|
||||
from ansible.module_utils.net_tools.nios.api import NIOS_SRV_RECORD
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -161,7 +162,7 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
wapi = WapiModule(module)
|
||||
result = wapi.run('record:srv', ib_spec)
|
||||
result = wapi.run(NIOS_SRV_RECORD, ib_spec)
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
3
test/integration/targets/nios_a_record/aliases
Normal file
3
test/integration/targets/nios_a_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/nios_a_record/meta/main.yaml
Normal file
2
test/integration/targets/nios_a_record/meta/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
1
test/integration/targets/nios_a_record/tasks/main.yml
Normal file
1
test/integration/targets/nios_a_record/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- include: nios_a_record_idempotence.yml
|
|
@ -0,0 +1,77 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup a_record
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an a_record
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_create1
|
||||
|
||||
- name: recreate an a_record
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_create2
|
||||
|
||||
- name: add a comment to an existing a_record
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_update1
|
||||
|
||||
- name: add a comment to an existing a_record
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_update2
|
||||
|
||||
- name: remove a a_record from the system
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_delete1
|
||||
|
||||
- name: remove a a_record from the system
|
||||
nios_a_record:
|
||||
name: a.ansible.com
|
||||
ipv4: 192.168.10.1
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: a_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "a_record_create1.changed"
|
||||
- "not a_record_create2.changed"
|
||||
- "a_record_update1.changed"
|
||||
- "not a_record_update2.changed"
|
||||
- "a_record_delete1.changed"
|
||||
- "not a_record_delete2.changed"
|
3
test/integration/targets/nios_aaaa_record/aliases
Normal file
3
test/integration/targets/nios_aaaa_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/nios_aaaa_record/meta/main.yaml
Normal file
2
test/integration/targets/nios_aaaa_record/meta/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
1
test/integration/targets/nios_aaaa_record/tasks/main.yml
Normal file
1
test/integration/targets/nios_aaaa_record/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- include: nios_aaaa_record_idempotence.yml
|
|
@ -0,0 +1,77 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup aaaa record
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an aaaa record
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_create1
|
||||
|
||||
- name: recreate an aaaa record
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_create2
|
||||
|
||||
- name: add a comment to an existing aaaa record
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_update1
|
||||
|
||||
- name: add a comment to an existing aaaa record
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_update2
|
||||
|
||||
- name: remove a aaaa record from the system
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_delete1
|
||||
|
||||
- name: remove a aaaa record from the system
|
||||
nios_aaaa_record:
|
||||
name: aaaa.ansible.com
|
||||
ipv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: aaaa_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "aaaa_record_create1.changed"
|
||||
- "not aaaa_record_create2.changed"
|
||||
- "aaaa_record_update1.changed"
|
||||
- "not aaaa_record_update2.changed"
|
||||
- "aaaa_record_delete1.changed"
|
||||
- "not aaaa_record_delete2.changed"
|
3
test/integration/targets/nios_cname_record/aliases
Normal file
3
test/integration/targets/nios_cname_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
|
@ -0,0 +1 @@
|
|||
- include: nios_cname_record_idempotence.yml
|
|
@ -0,0 +1,77 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup cname record
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an cname record
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_create1
|
||||
|
||||
- name: recreate an cname record
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_create2
|
||||
|
||||
- name: add a comment to an existing cname record
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_update1
|
||||
|
||||
- name: add a comment to an existing cname record
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_update2
|
||||
|
||||
- name: remove a cname record from the system
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_delete1
|
||||
|
||||
- name: remove a cname record from the system
|
||||
nios_cname_record:
|
||||
name: cname.ansible.com
|
||||
canonical: realhost.ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: cname_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "cname_record_create1.changed"
|
||||
- "not cname_record_create2.changed"
|
||||
- "cname_record_update1.changed"
|
||||
- "not cname_record_update2.changed"
|
||||
- "cname_record_delete1.changed"
|
||||
- "not cname_record_delete2.changed"
|
3
test/integration/targets/nios_mx_record/aliases
Normal file
3
test/integration/targets/nios_mx_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/nios_mx_record/meta/main.yaml
Normal file
2
test/integration/targets/nios_mx_record/meta/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
1
test/integration/targets/nios_mx_record/tasks/main.yml
Normal file
1
test/integration/targets/nios_mx_record/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- include: nios_mx_record_idempotence.yml
|
|
@ -0,0 +1,84 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup mx record
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an mx record
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_create1
|
||||
|
||||
- name: recreate an mx record
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_create2
|
||||
|
||||
- name: add a comment to an existing mx record
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_update1
|
||||
|
||||
- name: add a comment to an existing mx record
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_update2
|
||||
|
||||
- name: remove a mx record from the system
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_delete1
|
||||
|
||||
- name: remove a mx record from the system
|
||||
nios_mx_record:
|
||||
name: ansible.com
|
||||
mx: mailhost.ansible.com
|
||||
preference: 0
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: mx_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "mx_record_create1.changed"
|
||||
- "not mx_record_create2.changed"
|
||||
- "mx_record_update1.changed"
|
||||
- "not mx_record_update2.changed"
|
||||
- "mx_record_delete1.changed"
|
||||
- "not mx_record_delete2.changed"
|
3
test/integration/targets/nios_naptr_record/aliases
Normal file
3
test/integration/targets/nios_naptr_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
|
@ -0,0 +1 @@
|
|||
- include: nios_naptr_record_idempotence.yml
|
|
@ -0,0 +1,91 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup naptr record
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an naptr record
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_create1
|
||||
|
||||
- name: recreate an naptr record
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_create2
|
||||
|
||||
- name: add a comment to an existing naptr record
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_update1
|
||||
|
||||
- name: add a comment to an existing naptr record
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_update2
|
||||
|
||||
- name: remove a naptr record from the system
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_delete1
|
||||
|
||||
- name: remove a naptr record from the system
|
||||
nios_naptr_record:
|
||||
name: '*.subscriber-100.ansiblezone.com'
|
||||
order: 1000
|
||||
preference: 10
|
||||
replacement: replacement1.network.ansiblezone.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: naptr_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "naptr_record_create1.changed"
|
||||
- "not naptr_record_create2.changed"
|
||||
- "naptr_record_update1.changed"
|
||||
- "not naptr_record_update2.changed"
|
||||
- "naptr_record_delete1.changed"
|
||||
- "not naptr_record_delete2.changed"
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
test_items: []
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
||||
- prepare_nios_tests
|
||||
|
|
3
test/integration/targets/nios_srv_record/aliases
Normal file
3
test/integration/targets/nios_srv_record/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
shippable/cloud/group1
|
||||
cloud/nios
|
||||
destructive
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/nios_srv_record/meta/main.yaml
Normal file
2
test/integration/targets/nios_srv_record/meta/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nios_tests
|
1
test/integration/targets/nios_srv_record/tasks/main.yml
Normal file
1
test/integration/targets/nios_srv_record/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- include: nios_srv_record_idempotence.yml
|
|
@ -0,0 +1,98 @@
|
|||
- name: cleanup the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create the parent object
|
||||
nios_zone:
|
||||
name: ansible.com
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: cleanup srv record
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
|
||||
- name: create an srv record
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_create1
|
||||
|
||||
- name: recreate an srv record
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_create2
|
||||
|
||||
- name: add a comment to an existing srv record
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_update1
|
||||
|
||||
- name: add a comment to an existing srv record
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
comment: this is a test comment
|
||||
state: present
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_update2
|
||||
|
||||
- name: remove a srv record from the system
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_delete1
|
||||
|
||||
- name: remove a srv record from the system
|
||||
nios_srv_record:
|
||||
name: ansible.com
|
||||
port: 5080
|
||||
priority: 10
|
||||
target: service1.ansible.com
|
||||
weight: 10
|
||||
state: absent
|
||||
provider: "{{ nios_provider }}"
|
||||
register: srv_record_delete2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "srv_record_create1.changed"
|
||||
- "not srv_record_create2.changed"
|
||||
- "srv_record_update1.changed"
|
||||
- "not srv_record_update2.changed"
|
||||
- "srv_record_delete1.changed"
|
||||
- "not srv_record_delete2.changed"
|
|
@ -31,7 +31,7 @@ class NiosProvider(CloudProvider):
|
|||
|
||||
DOCKER_SIMULATOR_NAME = 'nios-simulator'
|
||||
|
||||
DOCKER_IMAGE = 'quay.io/ansible/nios-test-container:1.1.0'
|
||||
DOCKER_IMAGE = 'quay.io/ansible/nios-test-container:1.2.0'
|
||||
"""Default image to run the nios simulator.
|
||||
|
||||
The simulator must be pinned to a specific version
|
||||
|
|
133
test/units/modules/net_tools/nios/test_nios_a_record.py
Normal file
133
test/units/modules/net_tools/nios/test_nios_a_record.py
Normal file
|
@ -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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_a_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosARecordModule(TestNiosModule):
|
||||
|
||||
module = nios_a_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosARecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_a_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_a_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_a_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosARecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_a_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com',
|
||||
'ipv4': '192.168.10.1', 'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv4": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi.__dict__)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'ipv4': '192.168.10.1'})
|
||||
|
||||
def test_nios_a_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1',
|
||||
'comment': 'updated comment', 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "a.ansible.com",
|
||||
"ipv4": "192.168.10.1",
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv4": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_a_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1',
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "a.ansible.com",
|
||||
"ipv4": "192.168.10.1",
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv4": {"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)
|
133
test/units/modules/net_tools/nios/test_nios_aaaa_record.py
Normal file
133
test/units/modules/net_tools/nios/test_nios_aaaa_record.py
Normal file
|
@ -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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_aaaa_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosAAAARecordModule(TestNiosModule):
|
||||
|
||||
module = nios_aaaa_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosAAAARecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_aaaa_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_aaaa_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_aaaa_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosAAAARecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_aaaa_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com',
|
||||
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv6": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi.__dict__)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'})
|
||||
|
||||
def test_nios_aaaa_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com',
|
||||
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': 'updated comment', 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "aaaa.ansible.com",
|
||||
"ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv6": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_aaaa_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': 'aaaa.ansible.com',
|
||||
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "aaaa.ansible.com",
|
||||
"ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"ipv6": {"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)
|
133
test/units/modules/net_tools/nios/test_nios_cname_record.py
Normal file
133
test/units/modules/net_tools/nios/test_nios_cname_record.py
Normal file
|
@ -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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_cname_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosCNameRecordModule(TestNiosModule):
|
||||
|
||||
module = nios_cname_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosCNameRecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_cname_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_cname_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_cname_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosCNameRecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_a_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com',
|
||||
'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"canonical": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi.__dict__)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'canonical': 'realhost.ansible.com'})
|
||||
|
||||
def test_nios_a_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com',
|
||||
'canonical': 'realhost.ansible.com', 'comment': 'updated comment', 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "cname.ansible.com",
|
||||
"canonical": "realhost.ansible.com",
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"canonical": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_a_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': 'cname.ansible.com',
|
||||
'canonical': 'realhost.ansible.com', 'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "cname.ansible.com",
|
||||
"canonical": "realhost.ansible.com",
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"canonical": {"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)
|
137
test/units/modules/net_tools/nios/test_nios_mx_record.py
Normal file
137
test/units/modules/net_tools/nios/test_nios_mx_record.py
Normal file
|
@ -0,0 +1,137 @@
|
|||
# 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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_mx_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosMXRecordModule(TestNiosModule):
|
||||
|
||||
module = nios_mx_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosMXRecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_mx_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_mx_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_mx_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosMXRecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_mx_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com',
|
||||
'mx': 'mailhost.ansible.com', 'preference': 0, 'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"mx": {"ib_req": True},
|
||||
"preference": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'mx': 'mailhost.ansible.com', 'preference': 0})
|
||||
|
||||
def test_nios_mx_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com',
|
||||
'preference': 0, 'comment': 'updated comment', 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "ansible.com",
|
||||
"mx": "mailhost.ansible.com",
|
||||
"preference": 0,
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"mx": {"ib_req": True},
|
||||
"preference": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_mx_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com',
|
||||
'preference': 0, 'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "ansible.com",
|
||||
"mx": "mailhost.ansible.com",
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"mx": {"ib_req": True},
|
||||
"preference": {"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)
|
147
test/units/modules/net_tools/nios/test_nios_naptr_record.py
Normal file
147
test/units/modules/net_tools/nios/test_nios_naptr_record.py
Normal file
|
@ -0,0 +1,147 @@
|
|||
# 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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_naptr_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosNAPTRRecordModule(TestNiosModule):
|
||||
|
||||
module = nios_naptr_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosNAPTRRecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_naptr_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_naptr_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_naptr_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosNAPTRRecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_naptr_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com',
|
||||
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"order": {"ib_req": True},
|
||||
"preference": {"ib_req": True},
|
||||
"replacement": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi.__dict__)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'order': '1000', 'preference': '10',
|
||||
'replacement': 'replacement1.network.ansiblezone.com'})
|
||||
|
||||
def test_nios_naptr_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': '*.subscriber-100.ansiblezone.com',
|
||||
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
|
||||
'comment': 'updated comment', 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "*.subscriber-100.ansiblezone.com",
|
||||
"order": "1000",
|
||||
"preference": "10",
|
||||
"replacement": "replacement1.network.ansiblezone.com",
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"order": {"ib_req": True},
|
||||
"preference": {"ib_req": True},
|
||||
"replacement": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_naptr_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': '*.subscriber-100.ansiblezone.com',
|
||||
'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com',
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "*.subscriber-100.ansiblezone.com",
|
||||
"order": "1000",
|
||||
"preference": "10",
|
||||
"replacement": "replacement1.network.ansiblezone.com",
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"order": {"ib_req": True},
|
||||
"preference": {"ib_req": True},
|
||||
"replacement": {"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)
|
153
test/units/modules/net_tools/nios/test_nios_srv_record.py
Normal file
153
test/units/modules/net_tools/nios/test_nios_srv_record.py
Normal file
|
@ -0,0 +1,153 @@
|
|||
# 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/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
from ansible.modules.net_tools.nios import nios_srv_record
|
||||
from ansible.module_utils.net_tools.nios import api
|
||||
from ansible.compat.tests.mock import patch, MagicMock, Mock
|
||||
from .test_nios_module import TestNiosModule, load_fixture
|
||||
|
||||
|
||||
class TestNiosSRVRecordModule(TestNiosModule):
|
||||
|
||||
module = nios_srv_record
|
||||
|
||||
def setUp(self):
|
||||
super(TestNiosSRVRecordModule, self).setUp()
|
||||
self.module = MagicMock(name='ansible.modules.net_tools.nios.nios_srv_record.WapiModule')
|
||||
self.module.check_mode = False
|
||||
self.module.params = {'provider': None}
|
||||
self.mock_wapi = patch('ansible.modules.net_tools.nios.nios_srv_record.WapiModule')
|
||||
self.exec_command = self.mock_wapi.start()
|
||||
self.mock_wapi_run = patch('ansible.modules.net_tools.nios.nios_srv_record.WapiModule.run')
|
||||
self.mock_wapi_run.start()
|
||||
self.load_config = self.mock_wapi_run.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNiosSRVRecordModule, self).tearDown()
|
||||
self.mock_wapi.stop()
|
||||
self.mock_wapi_run.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_srv_record_create(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com',
|
||||
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = None
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"port": {"ib_req": True},
|
||||
"target": {"ib_req": True},
|
||||
"priority": {"ib_req": True},
|
||||
"weight": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
print("WAPI: ", wapi)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
|
||||
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10})
|
||||
|
||||
def test_nios_srv_record_update_comment(self):
|
||||
self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com',
|
||||
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": "_sip._tcp.service.ansible.com",
|
||||
'port': 5080,
|
||||
"target": "mailhost.ansible.com",
|
||||
"priority": 10,
|
||||
'weight': 10,
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"port": {"ib_req": True},
|
||||
"target": {"ib_req": True},
|
||||
"priority": {"ib_req": True},
|
||||
"weight": {"ib_req": True},
|
||||
"comment": {},
|
||||
"extattrs": {}
|
||||
}
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
res = wapi.run('testobject', test_spec)
|
||||
|
||||
self.assertTrue(res['changed'])
|
||||
|
||||
def test_nios_srv_record_remove(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': '_sip._tcp.service.ansible.com',
|
||||
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10,
|
||||
'comment': None, 'extattrs': None}
|
||||
|
||||
ref = "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/false"
|
||||
|
||||
test_object = [
|
||||
{
|
||||
"comment": "test comment",
|
||||
"_ref": ref,
|
||||
"name": "_sip._tcp.service.ansible.com",
|
||||
"port": 5080,
|
||||
"target": "mailhost.ansible.com",
|
||||
"priority": 10,
|
||||
"weight": 10,
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}
|
||||
]
|
||||
|
||||
test_spec = {
|
||||
"name": {"ib_req": True},
|
||||
"port": {"ib_req": True},
|
||||
"target": {"ib_req": True},
|
||||
"priority": {"ib_req": True},
|
||||
"weight": {"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)
|
Loading…
Reference in a new issue