mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
fix bug of system auditor 404 viewing job
This commit is contained in:
@@ -1357,12 +1357,6 @@ class JobAccess(BaseAccess):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@check_superuser
|
|
||||||
def can_read(self, obj):
|
|
||||||
if obj.job_template and self.user in obj.job_template.read_role:
|
|
||||||
return True
|
|
||||||
return self.org_access(obj, role_types=['auditor_role', 'admin_role'])
|
|
||||||
|
|
||||||
def can_add(self, data, validate_license=True):
|
def can_add(self, data, validate_license=True):
|
||||||
if validate_license:
|
if validate_license:
|
||||||
self.check_license()
|
self.check_license()
|
||||||
|
|||||||
@@ -51,12 +51,20 @@ def proj_updater(project, rando):
|
|||||||
return rando
|
return rando
|
||||||
|
|
||||||
|
|
||||||
# Read permissions testing
|
# Check that superuser & system auditors can see fully orphaned jobs
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_superuser_sees_orphans(normal_job, admin_user):
|
@pytest.mark.parametrize("superuser", [True, False])
|
||||||
|
def test_superuser_superauditor_sees_orphans(normal_job, superuser, admin_user, system_auditor):
|
||||||
|
if superuser:
|
||||||
|
u = admin_user
|
||||||
|
else:
|
||||||
|
u = system_auditor
|
||||||
normal_job.job_template = None
|
normal_job.job_template = None
|
||||||
access = JobAccess(admin_user)
|
normal_job.project = None
|
||||||
assert access.can_read(normal_job)
|
normal_job.inventory = None
|
||||||
|
access = JobAccess(u)
|
||||||
|
assert access.can_read(normal_job), "User sys auditor: {}, sys admin: {}".format(
|
||||||
|
u.is_system_auditor, u.is_superuser)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user