diff --git a/awx_collection/tests/integration/targets/credential/tasks/main.yml b/awx_collection/tests/integration/targets/credential/tasks/main.yml index aa5eee661580..be137b0c5d4a 100644 --- a/awx_collection/tests/integration/targets/credential/tasks/main.yml +++ b/awx_collection/tests/integration/targets/credential/tasks/main.yml @@ -25,26 +25,19 @@ tower_cred_name1: "AWX-Collection-tests-credential-tower-cred1-{{ test_id }}" - name: Get current Credential Types available - ansible.builtin.uri: - url: "https://localhost:8043/api/v2/credential_types/" - force_basic_auth: true - user: admin - password: password - method: GET - return_content: yes - validate_certs: false - register: credentials + ansible.builtin.set_fact: + credentials: "{{ lookup('awx.awx.controller_api', 'credential_types') }}" - name: Register Credentials found set_fact: - aws_found: "{{ 'Amazon Web Services' in credentials.json.results | map(attribute='name') | list }}" - vmware_found: "{{ 'VMware vCenter' in credentials.json.results | map(attribute='name') | list }}" - azure_found: "{{ 'Microsoft Azure Resource Manager' in credentials.json.results | map(attribute='name') | list }}" - gce_found: "{{ 'Google Compute Engine' in credentials.json.results | map(attribute='name') | list }}" - insights_found: "{{ 'Red Hat Insights' in credentials.json.results | map(attribute='name') | list }}" - satellite_found: "{{ 'Red Hat Satellite 6' in credentials.json.results | map(attribute='name') | list }}" - openstack_found: "{{ 'OpenStack' in credentials.json.results | map(attribute='name') | list }}" - rhv_found: "{{ 'Red Hat Virtualization' in credentials.json.results | map(attribute='name') | list }}" + aws_found: "{{ 'Amazon Web Services' in credentials | map(attribute='name') | list }}" + vmware_found: "{{ 'VMware vCenter' in credentials | map(attribute='name') | list }}" + azure_found: "{{ 'Microsoft Azure Resource Manager' in credentials | map(attribute='name') | list }}" + gce_found: "{{ 'Google Compute Engine' in credentials | map(attribute='name') | list }}" + insights_found: "{{ 'Red Hat Insights' in credentials | map(attribute='name') | list }}" + satellite_found: "{{ 'Red Hat Satellite 6' in credentials | map(attribute='name') | list }}" + openstack_found: "{{ 'OpenStack' in credentials | map(attribute='name') | list }}" + rhv_found: "{{ 'Red Hat Virtualization' in credentials | map(attribute='name') | list }}" - name: create a tempdir for an SSH key local_action: shell mktemp -d diff --git a/awx_collection/tests/integration/targets/credential_input_source/tasks/main.yml b/awx_collection/tests/integration/targets/credential_input_source/tasks/main.yml index 1d56d5e4b1a2..d5568fdd8d04 100644 --- a/awx_collection/tests/integration/targets/credential_input_source/tasks/main.yml +++ b/awx_collection/tests/integration/targets/credential_input_source/tasks/main.yml @@ -9,7 +9,17 @@ src_cred_name: "AWX-Collection-tests-credential_input_source-src_cred-{{ test_id }}" target_cred_name: "AWX-Collection-tests-credential_input_source-target_cred-{{ test_id }}" -- block: +- name: detect credential types + ansible.builtin.set_fact: + credentials: "{{ lookup('awx.awx.controller_api', 'credential_types') }}" + +- name: Register Credentials found + set_fact: + cyberark_found: "{{ 'CyberArk Central Credential Provider Lookup' in credentials | map(attribute='name') | list }}" + +- name: Test credential lookup workflow + when: cyberark_found + block: - name: Add credential Lookup credential: description: Credential for Testing Source @@ -121,7 +131,9 @@ that: - "result is changed" - always: +- name: Clean up if previous block ran + when: cyberark_found + block: - name: Remove a credential source credential_input_source: input_field_name: password diff --git a/awx_collection/tests/integration/targets/inventory/tasks/main.yml b/awx_collection/tests/integration/targets/inventory/tasks/main.yml index dbaf7dbcece2..8a01abcb2378 100644 --- a/awx_collection/tests/integration/targets/inventory/tasks/main.yml +++ b/awx_collection/tests/integration/targets/inventory/tasks/main.yml @@ -8,7 +8,6 @@ set_fact: inv_name1: "AWX-Collection-tests-inventory-inv1-{{ test_id }}" inv_name2: "AWX-Collection-tests-inventory-inv2-{{ test_id }}" - cred_name1: "AWX-Collection-tests-inventory-cred1-{{ test_id }}" group_name1: "AWX-Collection-tests-instance_group-group1-{{ test_id }}" - block: @@ -23,21 +22,6 @@ that: - "result is changed" - - name: Create an Insights Credential - credential: - name: "{{ cred_name1 }}" - organization: Default - credential_type: Insights - inputs: - username: joe - password: secret - state: present - register: result - - - assert: - that: - - "result is changed" - - name: Create an Inventory inventory: name: "{{ inv_name1 }}" @@ -228,9 +212,3 @@ name: "{{ group_name1 }}" state: absent - - name: Delete Insights Credential - credential: - name: "{{ cred_name1 }}" - organization: "Default" - credential_type: Insights - state: absent diff --git a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml index f051e47ad99d..6928b63e21da 100644 --- a/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml +++ b/awx_collection/tests/integration/targets/workflow_job_template/tasks/main.yml @@ -28,6 +28,14 @@ ig2: "AWX-Collection-tests-workflow_job_template-ig2-{{ test_id }}" host1: "AWX-Collection-tests-workflow_job_template-h1-{{ test_id }}" +- name: detect credential types + ansible.builtin.set_fact: + credentials: "{{ lookup('awx.awx.controller_api', 'credential_types') }}" + +- name: Register Credentials found + set_fact: + github_found: "{{ 'Github Personal Access Token' in credentials | map(attribute='name') | list }}" + - block: - name: "Create a new organization" organization: @@ -36,21 +44,29 @@ - Ansible Galaxy register: result - - name: Create Credentials + - name: Create SCM Credential credential: - name: "{{ item.name }}" + name: "{{ scm_cred_name }}" organization: Default - credential_type: "{{ item.type }}" + credential_type: Source Control register: result - loop: - - name: "{{ scm_cred_name }}" - type: Source Control - - name: "{{ github_webhook_credential_name }}" - type: GitHub Personal Access Token - assert: that: - "result is changed" + + - name: Create Github PAT Credential + credential: + name: "{{ github_webhook_credential_name }}" + organization: Default + credential_type: Github Personal Access Token + register: result + when: github_found + + - assert: + that: + - "result is changed" + when: github_found - name: Add email notification notification_template: @@ -867,8 +883,8 @@ name: "{{ webhook_wfjt_name }}" organization: Default inventory: Demo Inventory - webhook_service: gitlab - webhook_credential: "{{ github_webhook_credential_name }}" + webhook_service: "{{ 'gitlab' if github_found else omit }}" + webhook_credential: "{{ github_webhook_credential_name if github_found else omit }}" ignore_errors: true register: result @@ -882,8 +898,8 @@ name: "{{ webhook_wfjt_name }}" organization: Default inventory: Demo Inventory - webhook_service: github - webhook_credential: "{{ github_webhook_credential_name }}" + webhook_service: "{{ 'github' if github_found else omit }}" + webhook_credential: "{{ github_webhook_credential_name if github_found else omit }}" register: result - assert: