mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
fix WFJT user_capabilities special-case
This commit is contained in:
parent
c2446beb6e
commit
133cca1446
@ -348,10 +348,9 @@ class BaseAccess(object):
|
||||
if obj.validation_errors:
|
||||
user_capabilities[display_method] = False
|
||||
continue
|
||||
elif isinstance(obj, (WorkflowJobTemplate, WorkflowJob)):
|
||||
if not feature_enabled('workflows'):
|
||||
user_capabilities[display_method] = (display_method == 'delete')
|
||||
continue
|
||||
elif isinstance(obj, (WorkflowJobTemplate, WorkflowJob)) and (not feature_enabled('workflows')):
|
||||
user_capabilities[display_method] = (display_method == 'delete')
|
||||
continue
|
||||
elif display_method == 'copy' and isinstance(obj, WorkflowJobTemplate) and obj.organization_id is None:
|
||||
user_capabilities[display_method] = self.user.is_superuser
|
||||
continue
|
||||
|
@ -3,8 +3,8 @@ import pytest
|
||||
from awx.api.versioning import reverse
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from awx.main.models import Role, Group, UnifiedJobTemplate, JobTemplate
|
||||
from awx.main.access import access_registry
|
||||
from awx.main.models import Role, Group, UnifiedJobTemplate, JobTemplate, WorkflowJobTemplate
|
||||
from awx.main.access import access_registry, WorkflowJobTemplateAccess
|
||||
from awx.main.utils import prefetch_page_capabilities
|
||||
from awx.api.serializers import JobTemplateSerializer, UnifiedJobTemplateSerializer
|
||||
|
||||
@ -322,6 +322,17 @@ def test_prefetch_jt_copy_capability(job_template, project, inventory, rando):
|
||||
assert mapping[job_template.id] == {'copy': True}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_workflow_orphaned_capabilities(rando):
|
||||
wfjt = WorkflowJobTemplate.objects.create(name='test', organization=None)
|
||||
wfjt.admin_role.members.add(rando)
|
||||
access = WorkflowJobTemplateAccess(rando)
|
||||
assert not access.get_user_capabilities(
|
||||
wfjt, method_list=['edit', 'copy'],
|
||||
capabilities_cache={'copy': True}
|
||||
)['copy']
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_manual_projects_no_update(manual_project, get, admin_user):
|
||||
response = get(reverse('api:project_detail', kwargs={'pk': manual_project.pk}), admin_user, expect=200)
|
||||
|
Loading…
Reference in New Issue
Block a user