mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 01:38:50 -03:30
block system auditors from attaching notification templates
This commit is contained in:
@@ -1229,6 +1229,13 @@ class JobTemplateAccess(BaseAccess):
|
|||||||
"active_jobs": active_jobs})
|
"active_jobs": active_jobs})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@check_superuser
|
||||||
|
def can_attach(self, obj, sub_obj, relationship, data, skip_sub_obj_read_check=False):
|
||||||
|
if isinstance(sub_obj, NotificationTemplate):
|
||||||
|
return self.check_related('organization', Organization, {}, obj=sub_obj, mandatory=True)
|
||||||
|
return super(JobTemplateAccess, self).can_attach(
|
||||||
|
obj, sub_obj, relationship, data, skip_sub_obj_read_check=skip_sub_obj_read_check)
|
||||||
|
|
||||||
|
|
||||||
class JobAccess(BaseAccess):
|
class JobAccess(BaseAccess):
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import pytest
|
|||||||
|
|
||||||
from awx.main.access import (
|
from awx.main.access import (
|
||||||
NotificationTemplateAccess,
|
NotificationTemplateAccess,
|
||||||
NotificationAccess
|
NotificationAccess,
|
||||||
|
JobTemplateAccess
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -119,6 +120,15 @@ def test_notification_access_system_admin(notification, admin):
|
|||||||
assert access.can_delete(notification)
|
assert access.can_delete(notification)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_system_auditor_JT_attach(system_auditor, job_template, notification_template):
|
||||||
|
job_template.admin_role.members.add(system_auditor)
|
||||||
|
access = JobTemplateAccess(system_auditor)
|
||||||
|
assert not access.can_attach(
|
||||||
|
job_template, notification_template, 'notification_templates_success',
|
||||||
|
{'id': notification_template.id})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_notification_access_org_admin(notification, org_admin):
|
def test_notification_access_org_admin(notification, org_admin):
|
||||||
access = NotificationAccess(org_admin)
|
access = NotificationAccess(org_admin)
|
||||||
|
|||||||
Reference in New Issue
Block a user