Pull in functionality from lookup plugin get_id into tower_api itself

This commit is contained in:
AlanCoding
2020-06-18 12:44:39 -04:00
committed by John Westcott IV
parent f4454a6c93
commit 30ff112c87
3 changed files with 129 additions and 34 deletions

View File

@@ -42,9 +42,9 @@
- result is failed
- "'The requested object could not be found at' in result.msg"
- name: Load user of a specific name
- name: Load user of a specific name without promoting objects
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }) }}"
users: "{{ lookup('awx.awx.tower_api', 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }, return_objects=False) }}"
- assert:
that:
@@ -52,34 +52,66 @@
- users['count'] == 1
- users['results'][0]['id'] == user_creation_results['results'][0]['id']
- name: Get a page of users
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 2 } ) }}"
- name: Loop over one user with the loop syntax
assert:
that:
- item['id'] == user_creation_results['results'][0]['id']
loop: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }) }}"
loop_control:
label: "{{ item['id'] }}"
- assert:
that: users['results'] | length() == 2
- name: Get a page of users as just ids
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 2 }, return_ids=True ) }}"
- name: Assert that user list has 2 integer ids only
assert:
that:
- users | length() == 2
- user_creation_results['results'][0]['id'] in users
- name: Get all users of a system through next attribute
set_fact:
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, get_all=true ) }}"
users: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, return_all=true ) }}"
- assert:
that:
- users['results'] | length() >= 3
- users | length() >= 3
- name: Get the ID of the first user created and verify that it is correct
assert:
that: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }, return_ids=True) }}[0] == {{ user_creation_results['results'][0]['id'] }}"
- name: Try to get an ID of someone who does not exist
set_fact:
failed_user_id: "{{ query('awx.awx.tower_api', 'users', query_params={ 'username': 'john jacob jingleheimer schmidt' }, expect_one=True) }}"
register: result
ignore_errors: true
- assert:
that:
- result is failed
- "'Expected one object from endpoint users' in result['msg']"
- name: Lookup too many users
set_fact:
too_many_user_ids: " {{ query('awx.awx.tower_api', 'users', query_params={ 'username__endswith': test_id }, expect_one=True) }}"
register: results
ignore_errors: true
- assert:
that:
- results is failed
- "'Expected one object from endpoint users, but obtained 3' in results['msg']"
- name: Get the settings page
set_fact:
settings: "{{ query('awx.awx.tower_api', 'settings/ui' ) }}"
register: results
- assert:
assert:
that:
- results is succeeded
- "'CUSTOM_LOGO' in settings"
- "'CUSTOM_LOGO' in {{ lookup('awx.awx.tower_api', 'settings/ui' ) }}"
- name: Get the ping page
set_fact:
ping_data: "{{ query('awx.awx.tower_api', 'ping' ) }}"
ping_data: "{{ lookup('awx.awx.tower_api', 'ping' ) }}"
register: results
- assert: