Files
awx/awx_collection/tests/integration/targets/user/tasks/main.yml
John Westcott IV b87ff45c07 Enhance collection test
ad_hoc_command_cancel really can no longer timeout on a cancel (it happens sub second) and remove unneeded block

Modified all test to respect test_id parameter so that all tests can be run togeather as a single ID

Fix a check in group since its group2 is deleted from being a sub group of group1

The UI now allows to propage sub groups to the inventory which we may want to support within the collection

Only run instance integration test if we are running on k8s and assume we are not by default

Fix hard coded names in manual_project
2023-04-25 13:48:37 -04:00

303 lines
7.0 KiB
YAML

---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
username: "AWX-Collection-tests-user-user-{{ test_id }}"
- name: Create a User
user:
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
register: result
- assert:
that:
- "result is changed"
- name: Change a User by ID
user:
username: "{{ result.id }}"
last_name: User
email: joe@example.org
state: present
register: result
- assert:
that:
- "result is changed"
- name: Check idempotency
user:
username: "{{ username }}"
first_name: Joe
last_name: User
register: result
- assert:
that:
- "result is not changed"
- name: Rename a User
user:
username: "{{ username }}"
new_username: "{{ username }}-renamed"
email: joe@example.org
register: result
- assert:
that:
- "result is changed"
- name: Delete a User
user:
username: "{{ username }}-renamed"
email: joe@example.org
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Create an Auditor
user:
first_name: Joe
last_name: Auditor
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
auditor: true
register: result
- assert:
that:
- "result is changed"
- name: Delete an Auditor
user:
username: "{{ username }}"
email: joe@example.org
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Create a Superuser
user:
first_name: Joe
last_name: Super
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
superuser: true
register: result
- assert:
that:
- "result is changed"
- name: Delete a Superuser
user:
username: "{{ username }}"
email: joe@example.org
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Test SSL parameter
user:
first_name: Joe
last_name: User
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
validate_certs: true
controller_host: http://foo.invalid
ignore_errors: true
register: result
- assert:
that:
- "'Unable to resolve controller_host' in result.msg or
'Can not verify ssl with non-https protocol' in result.exception"
- block:
- 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"
...