mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Merge pull request #6304 from AlanCoding/workflow_role
Add workflow to tower_role module Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -50,6 +50,10 @@ options:
|
|||||||
description:
|
description:
|
||||||
- The job template the role acts on.
|
- The job template the role acts on.
|
||||||
type: str
|
type: str
|
||||||
|
workflow:
|
||||||
|
description:
|
||||||
|
- The job template the role acts on.
|
||||||
|
type: str
|
||||||
credential:
|
credential:
|
||||||
description:
|
description:
|
||||||
- Credential the role acts on.
|
- Credential the role acts on.
|
||||||
@@ -108,6 +112,7 @@ def update_resources(module, p):
|
|||||||
'target_team': 'name',
|
'target_team': 'name',
|
||||||
'inventory': 'name',
|
'inventory': 'name',
|
||||||
'job_template': 'name',
|
'job_template': 'name',
|
||||||
|
'workflow': 'name',
|
||||||
'credential': 'name',
|
'credential': 'name',
|
||||||
'organization': 'name',
|
'organization': 'name',
|
||||||
'project': 'name',
|
'project': 'name',
|
||||||
@@ -133,6 +138,7 @@ def main():
|
|||||||
target_team=dict(),
|
target_team=dict(),
|
||||||
inventory=dict(),
|
inventory=dict(),
|
||||||
job_template=dict(),
|
job_template=dict(),
|
||||||
|
workflow=dict(),
|
||||||
credential=dict(),
|
credential=dict(),
|
||||||
organization=dict(),
|
organization=dict(),
|
||||||
project=dict(),
|
project=dict(),
|
||||||
|
|||||||
37
awx_collection/test/awx/test_role.py
Normal file
37
awx_collection/test/awx/test_role.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from awx.main.models import WorkflowJobTemplate, User
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_grant_organization_permission(run_module, admin_user, organization):
|
||||||
|
rando = User.objects.create(username='rando')
|
||||||
|
|
||||||
|
result = run_module('tower_role', {
|
||||||
|
'user': rando.username,
|
||||||
|
'organization': organization.name,
|
||||||
|
'role': 'admin',
|
||||||
|
'state': 'present'
|
||||||
|
}, admin_user)
|
||||||
|
assert not result.get('failed', False), result.get('msg', result)
|
||||||
|
|
||||||
|
assert rando in organization.execute_role
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_grant_workflow_permission(run_module, admin_user, organization):
|
||||||
|
wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow')
|
||||||
|
rando = User.objects.create(username='rando')
|
||||||
|
|
||||||
|
result = run_module('tower_role', {
|
||||||
|
'user': rando.username,
|
||||||
|
'workflow': wfjt.name,
|
||||||
|
'role': 'execute',
|
||||||
|
'state': 'present'
|
||||||
|
}, admin_user)
|
||||||
|
assert not result.get('failed', False), result.get('msg', result)
|
||||||
|
|
||||||
|
assert rando in wfjt.execute_role
|
||||||
@@ -28,6 +28,24 @@
|
|||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a workflow
|
||||||
|
tower_workflow_template:
|
||||||
|
name: test-role-workflow
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Joe to workflow execute role
|
||||||
|
tower_role:
|
||||||
|
user: joe
|
||||||
|
role: execute
|
||||||
|
workflow: test-role-workflow
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
- name: Delete a User
|
- name: Delete a User
|
||||||
tower_user:
|
tower_user:
|
||||||
username: joe
|
username: joe
|
||||||
|
|||||||
Reference in New Issue
Block a user