mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 14:11:24 -03:30
Unit test & project access refactoring to prevent potential issue.
This commit is contained in:
parent
f301cb0f9b
commit
3999ffd52a
@ -871,10 +871,8 @@ class ProjectAccess(BaseAccess):
|
||||
|
||||
@check_superuser
|
||||
def can_change(self, obj, data):
|
||||
if obj.organization is None:
|
||||
return False
|
||||
org_pk = get_pk_from_dict(data, 'organization')
|
||||
if obj and org_pk and obj.organization.pk != org_pk:
|
||||
if obj and org_pk and obj.organization and obj.organization.pk != org_pk:
|
||||
org = get_object_or_400(Organization, pk=org_pk)
|
||||
if self.user not in org.admin_role:
|
||||
return False
|
||||
|
||||
@ -32,9 +32,8 @@ def test_custom_inv_script_access(organization, user):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_modify_inv_script_foreign_org_admin(org_admin, organization, organization_factory, project):
|
||||
custom_inv = CustomInventoryScript.objects.create(name='test', script='test', description='test')
|
||||
custom_inv.organization = organization
|
||||
custom_inv.save()
|
||||
custom_inv = CustomInventoryScript.objects.create(name='test', script='test', description='test',
|
||||
organization=organization)
|
||||
|
||||
other_org = organization_factory('not-my-org').organization
|
||||
access = CustomInventoryScriptAccess(org_admin)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user