From f6382a160d1ee4eda393c6bc7138cf08bab5ef26 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 9 Sep 2015 22:36:19 +0200 Subject: [PATCH] cloudstack: new integration test role test_cs_user --- test/integration/cloudstack.yml | 1 + .../roles/test_cs_user/meta/main.yml | 3 + .../roles/test_cs_user/tasks/main.yml | 276 ++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 test/integration/roles/test_cs_user/meta/main.yml create mode 100644 test/integration/roles/test_cs_user/tasks/main.yml diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index 486bd6e158..be36cc615a 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -7,6 +7,7 @@ vars: cs_resource_prefix: "{{ resource_prefix | default('cs-') }}" roles: + - { role: test_cs_user, tags: test_cs_user } - { role: test_cs_project, tags: test_cs_project } - { role: test_cs_iso, tags: test_cs_iso } - { role: test_cs_domain, tags: test_cs_domain } diff --git a/test/integration/roles/test_cs_user/meta/main.yml b/test/integration/roles/test_cs_user/meta/main.yml new file mode 100644 index 0000000000..03e38bd4f7 --- /dev/null +++ b/test/integration/roles/test_cs_user/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - test_cs_common diff --git a/test/integration/roles/test_cs_user/tasks/main.yml b/test/integration/roles/test_cs_user/tasks/main.yml new file mode 100644 index 0000000000..c5aaed8d58 --- /dev/null +++ b/test/integration/roles/test_cs_user/tasks/main.yml @@ -0,0 +1,276 @@ +--- +- name: setup + cs_user: username={{ cs_resource_prefix }}_user state=absent + register: user +- name: verify setup + assert: + that: + - user|success + +- name: test fail if missing username + action: cs_user + register: user + ignore_errors: true +- name: verify results of fail if missing params + assert: + that: + - user|failed + - 'user.msg == "missing required arguments: username"' + +- name: test fail if missing params if state=present + cs_user: + username: "{{ cs_resource_prefix }}_user" + register: user + ignore_errors: true +- name: verify results of fail if missing params if state=present + assert: + that: + - user|failed + - 'user.msg == "missing required arguments: account,email,password,first_name,last_name"' + +- name: test create user + cs_user: + username: "{{ cs_resource_prefix }}_user" + 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" + account: "admin" + register: user +- name: verify results of create user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.first_name == "{{ cs_resource_prefix }}_first_name" + - user.last_name == "{{ cs_resource_prefix }}_last_name" + - user.email == "{{ cs_resource_prefix }}@example.com" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test create user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + 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" + account: "admin" + register: user +- name: verify results of create user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.first_name == "{{ cs_resource_prefix }}_first_name" + - user.last_name == "{{ cs_resource_prefix }}_last_name" + - user.email == "{{ cs_resource_prefix }}@example.com" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test update user + cs_user: + username: "{{ cs_resource_prefix }}_user" + password: "{{ cs_resource_prefix }}_password" + last_name: "{{ cs_resource_prefix }}_last_name1" + first_name: "{{ cs_resource_prefix }}_first_name1" + email: "{{ cs_resource_prefix }}@example.com1" + account: "admin" + register: user +- name: verify results of update user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.first_name == "{{ cs_resource_prefix }}_first_name1" + - user.last_name == "{{ cs_resource_prefix }}_last_name1" + - user.email == "{{ cs_resource_prefix }}@example.com1" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test update user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + password: "{{ cs_resource_prefix }}_password" + last_name: "{{ cs_resource_prefix }}_last_name1" + first_name: "{{ cs_resource_prefix }}_first_name1" + email: "{{ cs_resource_prefix }}@example.com1" + account: "admin" + register: user +- name: verify results of update user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.first_name == "{{ cs_resource_prefix }}_first_name1" + - user.last_name == "{{ cs_resource_prefix }}_last_name1" + - user.email == "{{ cs_resource_prefix }}@example.com1" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test lock user + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: locked + register: user +- name: verify results of lock user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "locked" + - user.domain == "ROOT" + +- name: test lock user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: locked + register: user +- name: verify results of lock user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "locked" + - user.domain == "ROOT" + +- name: test disable user + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: disabled + register: user +- name: verify results of disable user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "disabled" + - user.domain == "ROOT" + +- name: test disable user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: disabled + register: user +- name: verify results of disable user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "disabled" + - user.domain == "ROOT" + +- name: test lock disabled user + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: locked + register: user +- name: verify results of lock disabled user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "locked" + - user.domain == "ROOT" + +- name: test lock disabled user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: locked + register: user +- name: verify results of lock disabled user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "locked" + - user.domain == "ROOT" + +- name: test enable user + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: enabled + register: user +- name: verify results of enable user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test enable user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: enabled + register: user +- name: verify results of enable user idempotence + assert: + that: + - user|success + - not user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test remove user + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: absent + register: user +- name: verify results of remove user + assert: + that: + - user|success + - user|changed + - user.username == "{{ cs_resource_prefix }}_user" + - user.account_type == "root_admin" + - user.account == "admin" + - user.state == "enabled" + - user.domain == "ROOT" + +- name: test remove user idempotence + cs_user: + username: "{{ cs_resource_prefix }}_user" + state: absent + register: user +- name: verify results of remove user idempotence + assert: + that: + - user|success + - not user|changed