mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 22:48:02 -03:30
add tests
This commit is contained in:
parent
6c1f688bf1
commit
c0e1ac266c
@ -48,6 +48,28 @@ def test_grant_workflow_permission(run_module, admin_user, organization, state):
|
||||
else:
|
||||
assert rando not in wfjt.execute_role
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('state', ('present', 'absent'))
|
||||
def test_grant_workflow_list_permission(run_module, admin_user, organization, state):
|
||||
wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow')
|
||||
rando = User.objects.create(username='rando')
|
||||
if state == 'absent':
|
||||
wfjt.execute_role.members.add(rando)
|
||||
|
||||
result = run_module('tower_role', {
|
||||
'user': rando.username,
|
||||
'lookup_organization': wfjt.organization.name,
|
||||
'workflows': [wfjt.name],
|
||||
'role': 'execute',
|
||||
'state': state
|
||||
}, admin_user)
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
|
||||
if state == 'present':
|
||||
assert rando in wfjt.execute_role
|
||||
else:
|
||||
assert rando not in wfjt.execute_role
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('state', ('present', 'absent'))
|
||||
def test_grant_workflow_approval_permission(run_module, admin_user, organization, state):
|
||||
|
||||
@ -5,8 +5,11 @@
|
||||
|
||||
- name: Generate names
|
||||
set_fact:
|
||||
username: "AWX-Collection-tests-tower_role-user-{{ test_id }}"
|
||||
project_name: "AWX-Collection-tests-tower_role-project-{{ test_id }}"
|
||||
username: "AWX-Collection-tests-tower_role-user-{{ test_id }}"
|
||||
project_name: "AWX-Collection-tests-tower_role-project-1-{{ test_id }}"
|
||||
jt1: "AWX-Collection-tests-tower_role-jt1-{{ test_id }}"
|
||||
jt2: "AWX-Collection-tests-tower_role-jt2-{{ test_id }}"
|
||||
wfjt_name: "AWX-Collection-tests-tower_role-project-wfjt-{{ test_id }}"
|
||||
|
||||
- block:
|
||||
- name: Create a User
|
||||
@ -29,17 +32,33 @@
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: false
|
||||
wait: true
|
||||
register: project_info
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- project_info is changed
|
||||
|
||||
- name: Add Joe to the update role of the default Project
|
||||
- name: Create job templates
|
||||
tower_job_template:
|
||||
name: "{{ item }}"
|
||||
project: "{{ project_name }}"
|
||||
inventory: "Demo Inventory"
|
||||
playbook: become.yml
|
||||
with_items:
|
||||
- jt1
|
||||
- jt2
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Add Joe to the update role of the default Project with lookup Organization
|
||||
tower_role:
|
||||
user: "{{ username }}"
|
||||
role: update
|
||||
lookup_organization: Default
|
||||
project: "Demo Project"
|
||||
state: "{{ item }}"
|
||||
register: result
|
||||
@ -77,6 +96,9 @@
|
||||
user: "{{ username }}"
|
||||
role: execute
|
||||
workflow: test-role-workflow
|
||||
job_templates:
|
||||
- jt1
|
||||
- jt2
|
||||
state: present
|
||||
register: result
|
||||
|
||||
@ -116,6 +138,18 @@
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: Delete job templates
|
||||
tower_job_template:
|
||||
name: "{{ item }}"
|
||||
project: "{{ project_name }}"
|
||||
inventory: "Demo Inventory"
|
||||
playbook: debug.yml
|
||||
state: absent
|
||||
with_items:
|
||||
- jt1
|
||||
- jt2
|
||||
register: result
|
||||
|
||||
- name: Delete the project
|
||||
tower_project:
|
||||
name: "{{ project_name }}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user