mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Merge pull request #592 from ryanpetrello/fix-7793
fix a bug which caused v1 cred backwards-compat to apply to v2 requests
This commit is contained in:
commit
7b42316366
@ -2127,7 +2127,7 @@ class CredentialSerializer(BaseSerializer):
|
||||
|
||||
def to_internal_value(self, data):
|
||||
# TODO: remove when API v1 is removed
|
||||
if 'credential_type' not in data:
|
||||
if 'credential_type' not in data and self.version == 1:
|
||||
# If `credential_type` is not provided, assume the payload is a
|
||||
# v1 credential payload that specifies a `kind` and a flat list
|
||||
# of field values
|
||||
|
||||
@ -588,7 +588,7 @@ def test_create_org_credential_as_admin(post, organization, org_admin, credentia
|
||||
params['name'] = 'Some name'
|
||||
params['organization'] = organization.id
|
||||
response = post(
|
||||
reverse('api:credential_list'),
|
||||
reverse('api:credential_list', kwargs={'version': version}),
|
||||
params,
|
||||
org_admin
|
||||
)
|
||||
@ -604,7 +604,7 @@ def test_credential_detail(post, get, organization, org_admin, credentialtype_ss
|
||||
params['name'] = 'Some name'
|
||||
params['organization'] = organization.id
|
||||
response = post(
|
||||
reverse('api:credential_list'),
|
||||
reverse('api:credential_list', kwargs={'version': version}),
|
||||
params,
|
||||
org_admin
|
||||
)
|
||||
@ -1467,6 +1467,14 @@ def test_credential_type_mutability(patch, organization, admin, credentialtype_s
|
||||
'as it may break the functionality of the resources using it.']
|
||||
assert response.data['credential_type'] == expected
|
||||
|
||||
response = patch(
|
||||
reverse('api:credential_detail', kwargs={'version': 'v2', 'pk': cred.pk}),
|
||||
{'name': 'Worst credential ever'},
|
||||
admin
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert Credential.objects.get(pk=cred.pk).name == 'Worst credential ever'
|
||||
|
||||
related_obj.delete()
|
||||
response = _change_credential_type()
|
||||
assert response.status_code == 200
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user