let an organization admin to add new users to it's tower organization

This commit is contained in:
Ivan Aragonés Muniesa
2022-02-09 18:58:51 +01:00
parent f8e680867b
commit 9cd43d044e
3 changed files with 193 additions and 4 deletions

View File

@@ -129,3 +129,173 @@
that:
- "'Unable to resolve controller_host' in result.msg or
'Can not verify ssl with non-https protocol' in result.exception"
- block:
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate an org name
set_fact:
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
- name: Make sure {{ org_name }} is not there
organization:
name: "{{ org_name }}"
state: absent
register: result
- name: Create a new Organization
organization:
name: "{{ org_name }}"
galaxy_credentials:
- Ansible Galaxy
register: result
- assert:
that: "result is changed"
- name: Create a User to become admin of an organization {{ org_name }}
user:
username: "{{ username }}-orgadmin"
password: "{{ username }}-orgadmin"
state: present
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Add the user {{ username }}-orgadmin as an admin of the organization {{ org_name }}
role:
user: "{{ username }}-orgadmin"
role: admin
organization: "{{ org_name }}"
state: present
register: result
- assert:
that:
- "result is changed"
- name: Create a User as {{ username }}-orgadmin without using an organization (must fail)
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
register: result
ignore_errors: true
- assert:
that:
- "result is failed"
- name: Create a User as {{ username }}-orgadmin using an organization
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Change a User as {{ username }}-orgadmin by ID using an organization
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ result.id }}"
last_name: User
email: joe@example.org
state: present
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Check idempotency as {{ username }}-orgadmin using an organization
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ username }}"
first_name: Joe
last_name: User
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is not changed"
- name: Rename a User as {{ username }}-orgadmin using an organization
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ username }}"
new_username: "{{ username }}-renamed"
email: joe@example.org
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Delete a User as {{ username }}-orgadmin using an organization
user:
controller_username: "{{ username }}-orgadmin"
controller_password: "{{ username }}-orgadmin"
username: "{{ username }}-renamed"
email: joe@example.org
state: absent
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Remove the user {{ username }}-orgadmin as an admin of the organization {{ org_name }}
role:
user: "{{ username }}-orgadmin"
role: admin
organization: "{{ org_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Delete the User {{ username }}-orgadmin
user:
username: "{{ username }}-orgadmin"
password: "{{ username }}-orgadmin"
state: absent
organization: "{{ org_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Delete the Organization {{ org_name }}
organization:
name: "{{ org_name }}"
state: absent
register: result
- assert:
that: "result is changed"
...