mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: cs_domain: tests: add update tests (#27791)
This commit is contained in:
parent
e1cfcdbbc6
commit
f1ef61da4e
2 changed files with 108 additions and 34 deletions
|
@ -40,13 +40,10 @@ options:
|
|||
network_domain:
|
||||
description:
|
||||
- Network domain for networks in the domain.
|
||||
required: false
|
||||
default: null
|
||||
clean_up:
|
||||
description:
|
||||
- Clean up all domain resources like child domains and accounts.
|
||||
- Considered on C(state=absent).
|
||||
required: false
|
||||
default: false
|
||||
state:
|
||||
description:
|
||||
|
@ -57,29 +54,28 @@ options:
|
|||
poll_async:
|
||||
description:
|
||||
- Poll async jobs until job has finished.
|
||||
required: false
|
||||
default: true
|
||||
extends_documentation_fragment: cloudstack
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a domain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers
|
||||
network_domain: customers.example.com
|
||||
- name: Create a domain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers
|
||||
network_domain: customers.example.com
|
||||
|
||||
# Create another subdomain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers/xy
|
||||
network_domain: xy.customers.example.com
|
||||
- name: Create another subdomain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers/xy
|
||||
network_domain: xy.customers.example.com
|
||||
|
||||
# Remove a domain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers/xy
|
||||
state: absent
|
||||
- name: Remove a domain
|
||||
local_action:
|
||||
module: cs_domain
|
||||
path: ROOT/customers/xy
|
||||
state: absent
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
---
|
||||
- name: setup
|
||||
cs_domain: path={{ cs_resource_prefix }}_domain state=absent
|
||||
cs_domain:
|
||||
path: "{{ cs_resource_prefix }}_domain"
|
||||
state: absent
|
||||
register: dom
|
||||
- name: verify setup
|
||||
assert:
|
||||
|
@ -18,7 +20,8 @@
|
|||
- 'dom.msg == "missing required arguments: path"'
|
||||
|
||||
- name: test fail if ends with /
|
||||
cs_domain: path={{ cs_resource_prefix }}_domain/
|
||||
cs_domain:
|
||||
path: "{{ cs_resource_prefix }}_domain/"
|
||||
register: dom
|
||||
ignore_errors: true
|
||||
- name: verify results of fail if ends with /
|
||||
|
@ -28,7 +31,8 @@
|
|||
- dom.msg == "Path '{{ cs_resource_prefix }}_domain/' must not end with /"
|
||||
|
||||
- name: test create a domain in check mode
|
||||
cs_domain: path={{ cs_resource_prefix }}_domain
|
||||
cs_domain:
|
||||
path: "{{ cs_resource_prefix }}_domain"
|
||||
register: dom
|
||||
check_mode: true
|
||||
- name: verify results of test create a domain in check mode
|
||||
|
@ -37,7 +41,8 @@
|
|||
- dom|changed
|
||||
|
||||
- name: test create a domain
|
||||
cs_domain: path={{ cs_resource_prefix }}_domain
|
||||
cs_domain:
|
||||
path: "{{ cs_resource_prefix }}_domain"
|
||||
register: dom
|
||||
- name: verify results of test create a domain
|
||||
assert:
|
||||
|
@ -47,7 +52,8 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_domain"
|
||||
|
||||
- name: test create a domain idempotence
|
||||
cs_domain: path={{ cs_resource_prefix }}_domain
|
||||
cs_domain:
|
||||
path: "{{ cs_resource_prefix }}_domain"
|
||||
register: dom
|
||||
- name: verify results of test create a domain idempotence
|
||||
assert:
|
||||
|
@ -56,6 +62,17 @@
|
|||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_domain"
|
||||
|
||||
- name: test create a domain idempotence2
|
||||
cs_domain:
|
||||
path: "/{{ cs_resource_prefix }}_domain"
|
||||
register: dom
|
||||
- name: verify results of test create a domain idempotence2
|
||||
assert:
|
||||
that:
|
||||
- not dom|changed
|
||||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_domain"
|
||||
|
||||
- name: test fail to create a subdomain for inexistent domain
|
||||
cs_domain:
|
||||
path: ROOT/inexistent/{{ cs_resource_prefix }}_subdomain
|
||||
|
@ -68,7 +85,8 @@
|
|||
- dom.msg == "Parent domain path ROOT/inexistent does not exist"
|
||||
|
||||
- name: test create a subdomain in check mode
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
register: dom
|
||||
check_mode: true
|
||||
- name: verify results of test create a domain in check mode
|
||||
|
@ -77,7 +95,8 @@
|
|||
- dom|changed
|
||||
|
||||
- name: test create a subdomain
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
register: dom
|
||||
- name: verify results of test create a domain
|
||||
assert:
|
||||
|
@ -87,15 +106,60 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test create a subdomain idempotence
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
register: dom
|
||||
- name: verify results of test create a subdomain idempotence
|
||||
assert:
|
||||
that:
|
||||
- not dom|changed
|
||||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test update a subdomain in check mode
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
network_domain: domain.example.com
|
||||
register: dom
|
||||
check_mode: true
|
||||
- name: verify results of test update a subdomain in check mode
|
||||
assert:
|
||||
that:
|
||||
- dom|changed
|
||||
- dom.network_domain is undefined
|
||||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test update a subdomain
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
network_domain: domain.example.com
|
||||
register: dom
|
||||
- name: verify results of test update a subdomain
|
||||
assert:
|
||||
that:
|
||||
- dom|changed
|
||||
- dom.network_domain == "domain.example.com"
|
||||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test update a subdomain idempotence
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
network_domain: domain.example.com
|
||||
register: dom
|
||||
- name: verify results of test update a subdomain idempotence
|
||||
assert:
|
||||
that:
|
||||
- not dom|changed
|
||||
- dom.network_domain == "domain.example.com"
|
||||
- dom.path == "ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain"
|
||||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test delete a subdomain in check mode
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
state: absent
|
||||
register: dom
|
||||
check_mode: true
|
||||
- name: verify results of test delete a subdomain in check mode
|
||||
|
@ -106,7 +170,9 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test delete a subdomain
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
state: absent
|
||||
register: dom
|
||||
- name: verify results of test delete a subdomain
|
||||
assert:
|
||||
|
@ -116,7 +182,9 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test delete a subdomain idempotence
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain state=absent
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
state: absent
|
||||
register: dom
|
||||
- name: verify results of test delete a subdomain idempotence
|
||||
assert:
|
||||
|
@ -124,7 +192,8 @@
|
|||
- not dom|changed
|
||||
|
||||
- name: test create a subdomain 2
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain/{{ cs_resource_prefix }}_subdomain
|
||||
register: dom
|
||||
- name: verify results of test create a subdomain 2
|
||||
assert:
|
||||
|
@ -134,7 +203,10 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_subdomain"
|
||||
|
||||
- name: test delete a domain with clean up in check mode
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain
|
||||
state: absent
|
||||
clean_up: true
|
||||
register: dom
|
||||
check_mode: true
|
||||
- name: verify results of test delete a domain with clean up in check mode
|
||||
|
@ -145,7 +217,10 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_domain"
|
||||
|
||||
- name: test delete a domain with clean up
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain
|
||||
state: absent
|
||||
clean_up: true
|
||||
register: dom
|
||||
- name: verify results of test delete a domain with clean up
|
||||
assert:
|
||||
|
@ -155,7 +230,10 @@
|
|||
- dom.name == "{{ cs_resource_prefix }}_domain"
|
||||
|
||||
- name: test delete a domain with clean up idempotence
|
||||
cs_domain: path=ROOT/{{ cs_resource_prefix }}_domain state=absent clean_up=true
|
||||
cs_domain:
|
||||
path: ROOT/{{ cs_resource_prefix }}_domain
|
||||
state: absent
|
||||
clean_up: true
|
||||
register: dom
|
||||
- name: verify results of test delete a domain with clean up idempotence
|
||||
assert:
|
||||
|
|
Loading…
Reference in a new issue