1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

allow null data cases in credential can_change

This commit is contained in:
AlanCoding 2016-07-05 15:06:40 -04:00
parent c21d560cfd
commit ddbe54f841
2 changed files with 3 additions and 1 deletions

View File

@ -616,7 +616,7 @@ class CredentialAccess(BaseAccess):
# Check access to organizations
organization_pk = get_pk_from_dict(data, 'organization')
if organization_pk != getattr(obj, 'organization_id', None):
if data and 'organization' in data and organization_pk != getattr(obj, 'organization_id', None):
if organization_pk:
# admin permission to destination organization is mandatory
new_organization_obj = get_object_or_400(Organization, pk=organization_pk)

View File

@ -125,6 +125,8 @@ def test_org_credential_access_member(alice, org_credential, credential):
assert access.can_change(org_credential, {
'description': 'New description.',
'organization': org_credential.organization.pk})
assert access.can_change(org_credential, {
'description': 'New description.'})
assert access.can_change(credential, {
'description': 'New description.',
'organization': None})