From 9180ede6e09083b9248680bd7f1fdf412fa98934 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 11 May 2015 17:37:35 +0200 Subject: [PATCH] cloudstack: add test for cs_account --- test/integration/cloudstack.yml | 1 + .../roles/test_cs_account/meta/main.yml | 3 + .../roles/test_cs_account/tasks/main.yml | 226 ++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 test/integration/roles/test_cs_account/meta/main.yml create mode 100644 test/integration/roles/test_cs_account/tasks/main.yml diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index 5f5e65c6cd..7cdf593a8c 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -11,3 +11,4 @@ - { role: test_cs_securitygroup_rule, tags: test_cs_securitygroup_rule } - { role: test_cs_instance, tags: test_cs_instance } - { role: test_cs_instancegroup, tags: test_cs_instancegroup } + - { role: test_cs_account, tags: test_cs_account } diff --git a/test/integration/roles/test_cs_account/meta/main.yml b/test/integration/roles/test_cs_account/meta/main.yml new file mode 100644 index 0000000000..03e38bd4f7 --- /dev/null +++ b/test/integration/roles/test_cs_account/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - test_cs_common diff --git a/test/integration/roles/test_cs_account/tasks/main.yml b/test/integration/roles/test_cs_account/tasks/main.yml new file mode 100644 index 0000000000..5bcea07ef2 --- /dev/null +++ b/test/integration/roles/test_cs_account/tasks/main.yml @@ -0,0 +1,226 @@ +--- +- name: setup + cs_account: name={{ cs_resource_prefix }}_user state=absent + register: acc +- name: verify setup + assert: + that: + - acc|success + +- name: test fail if missing name + action: cs_account + register: acc + ignore_errors: true +- name: verify results of fail if missing params + assert: + that: + - acc|failed + - 'acc.msg == "missing required arguments: name"' + +- name: test fail if missing params if state=present + cs_account: + name: "{{ cs_resource_prefix }}_user" + register: acc + ignore_errors: true +- name: verify results of fail if missing params if state=present + assert: + that: + - acc|failed + - 'acc.msg == "missing required arguments: email,username,password,first_name,last_name"' + +- name: test create user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + username: "{{ cs_resource_prefix }}_username" + password: "{{ cs_resource_prefix }}_password" + last_name: "{{ cs_resource_prefix }}_last_name" + first_name: "{{ cs_resource_prefix }}_first_name" + email: "{{ cs_resource_prefix }}@example.com" + network_domain: "{{ cs_resource_prefix }}.local" + register: acc +- name: verify results of create account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "enabled" + - acc.domain == "ROOT" + +- name: test create user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + username: "{{ cs_resource_prefix }}_username" + password: "{{ cs_resource_prefix }}_password" + last_name: "{{ cs_resource_prefix }}_last_name" + first_name: "{{ cs_resource_prefix }}_first_name" + email: "{{ cs_resource_prefix }}@example.com" + network_domain: "{{ cs_resource_prefix }}.local" + register: acc +- name: verify results of create account idempotence + assert: + that: + - acc|success + - not acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "enabled" + - acc.domain == "ROOT" + +- name: test lock user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: locked + register: acc +- name: verify results of lock user account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "locked" + - acc.domain == "ROOT" + +- name: test lock user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: locked + register: acc +- name: verify results of lock user account idempotence + assert: + that: + - acc|success + - not acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "locked" + - acc.domain == "ROOT" + +- name: test disable user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: disabled + register: acc +- name: verify results of disable user account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "disabled" + - acc.domain == "ROOT" + +- name: test disable user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: disabled + register: acc +- name: verify results of disable user account idempotence + assert: + that: + - acc|success + - not acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "disabled" + - acc.domain == "ROOT" + +- name: test lock disabled user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: locked + register: acc +- name: verify results of lock disabled user account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "locked" + - acc.domain == "ROOT" + +- name: test lock disabled user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: locked + register: acc +- name: verify results of lock disabled user account idempotence + assert: + that: + - acc|success + - not acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "locked" + - acc.domain == "ROOT" + +- name: test enable user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: enabled + register: acc +- name: verify results of enable user account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "enabled" + - acc.domain == "ROOT" + +- name: test enable user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: enabled + register: acc +- name: verify results of enable user account idempotence + assert: + that: + - acc|success + - not acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "enabled" + - acc.domain == "ROOT" + +- name: test remove user account + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: absent + register: acc +- name: verify results of remove user account + assert: + that: + - acc|success + - acc|changed + - acc.name == "{{ cs_resource_prefix }}_user" + - acc.network_domain == "{{ cs_resource_prefix }}.local" + - acc.account_type == "user" + - acc.account_state == "enabled" + - acc.domain == "ROOT" + +- name: test remove user account idempotence + cs_account: + name: "{{ cs_resource_prefix }}_user" + state: absent + register: acc +- name: verify results of remove user account idempotence + assert: + that: + - acc|success + - not acc|changed