1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-29 20:55:32 +03:00

Fixing test issue and 'modornizing' test

This commit is contained in:
John Westcott IV 2020-09-08 15:28:21 -04:00
parent 4c0e288fee
commit 09b8f82bbb

View File

@ -1,105 +1,113 @@
---
- name: Generate a random string for test
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
src_cred_name: src_cred
target_cred_name: target_cred
src_cred_name: "AWX-Collection-tests-tower_credential_input_source-src_cred-{{ test_id }}"
target_cred_name: "AWX-Collection-tests-tower_credential_input_source-target_cred-{{ test_id }}"
- name: Add Tower credential Lookup
tower_credential:
description: Credential for Testing Source
name: "{{ src_cred_name }}"
credential_type: CyberArk AIM Central Credential Provider Lookup
inputs:
url: "https://cyberark.example.com"
app_id: "My-App-ID"
organization: Default
register: src_cred_result
- block:
- name: Add Tower credential Lookup
tower_credential:
description: Credential for Testing Source
name: "{{ src_cred_name }}"
credential_type: CyberArk AIM Central Credential Provider Lookup
inputs:
url: "https://cyberark.example.com"
app_id: "My-App-ID"
organization: Default
register: src_cred_result
- assert:
that:
- "src_cred_result is changed"
- assert:
that:
- "src_cred_result is changed"
- name: Add Tower credential Target
tower_credential:
description: Credential for Testing Target
name: "{{ target_cred_name }}"
credential_type: Machine
inputs:
username: user
organization: Default
register: target_cred_result
- name: Add Tower credential Target
tower_credential:
description: Credential for Testing Target
name: "{{ target_cred_name }}"
credential_type: Machine
inputs:
username: user
organization: Default
register: target_cred_result
- assert:
that:
- "target_cred_result is changed"
- assert:
that:
- "target_cred_result is changed"
- name: Add credential Input Source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_result.id }}"
source_credential: "{{ src_cred_result.id }}"
metadata:
object_query: "Safe=MY_SAFE;Object=AWX-user"
object_query_format: "Exact"
state: present
- name: Add credential Input Source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_result.id }}"
source_credential: "{{ src_cred_result.id }}"
metadata:
object_query: "Safe=MY_SAFE;Object=AWX-user"
object_query_format: "Exact"
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Add Second Tower credential Lookup
tower_credential:
description: Credential for Testing Source Change
name: "{{ src_cred_name }}-2"
credential_type: CyberArk AIM Central Credential Provider Lookup
inputs:
url: "https://cyberark-prod.example.com"
app_id: "My-App-ID"
organization: Default
register: result
- name: Add Second Tower credential Lookup
tower_credential:
description: Credential for Testing Source Change
name: "{{ src_cred_name }}-2"
credential_type: CyberArk AIM Central Credential Provider Lookup
inputs:
url: "https://cyberark-prod.example.com"
app_id: "My-App-ID"
organization: Default
register: result
- name: Change credential Input Source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_name }}"
source_credential: "{{ src_cred_name }}-2"
state: present
- name: Change credential Input Source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_name }}"
source_credential: "{{ src_cred_name }}-2"
state: present
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Remove a Tower credential source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_name }}"
state: absent
register: result
always:
- name: Remove a Tower credential source
tower_credential_input_source:
input_field_name: password
target_credential: "{{ target_cred_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Remove Tower credential Lookup
tower_credential:
name: "{{ src_cred_name }}"
organization: Default
credential_type: CyberArk AIM Central Credential Provider Lookup
state: absent
register: result
- name: Remove Tower credential Lookup
tower_credential:
name: "{{ src_cred_name }}"
organization: Default
credential_type: CyberArk AIM Central Credential Provider Lookup
state: absent
register: result
- name: Remove Alt Tower credential Lookup
tower_credential:
name: "{{ src_cred_name }}-2"
organization: Default
credential_type: CyberArk AIM Central Credential Provider Lookup
state: absent
register: result
- name: Remove Alt Tower credential Lookup
tower_credential:
name: "{{ src_cred_name }}-2"
organization: Default
credential_type: CyberArk AIM Central Credential Provider Lookup
state: absent
register: result
- name: Remove Tower credential
tower_credential:
name: "{{ target_cred_name }}"
organization: Default
credential_type: Machine
state: absent
register: result
- name: Remove Tower credential
tower_credential:
name: "{{ target_cred_name }}"
organization: Default
credential_type: Machine
state: absent
register: result