mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02: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:
@@ -2127,7 +2127,7 @@ class CredentialSerializer(BaseSerializer):
|
|||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
# TODO: remove when API v1 is removed
|
# 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
|
# If `credential_type` is not provided, assume the payload is a
|
||||||
# v1 credential payload that specifies a `kind` and a flat list
|
# v1 credential payload that specifies a `kind` and a flat list
|
||||||
# of field values
|
# of field values
|
||||||
|
|||||||
@@ -588,7 +588,7 @@ def test_create_org_credential_as_admin(post, organization, org_admin, credentia
|
|||||||
params['name'] = 'Some name'
|
params['name'] = 'Some name'
|
||||||
params['organization'] = organization.id
|
params['organization'] = organization.id
|
||||||
response = post(
|
response = post(
|
||||||
reverse('api:credential_list'),
|
reverse('api:credential_list', kwargs={'version': version}),
|
||||||
params,
|
params,
|
||||||
org_admin
|
org_admin
|
||||||
)
|
)
|
||||||
@@ -604,7 +604,7 @@ def test_credential_detail(post, get, organization, org_admin, credentialtype_ss
|
|||||||
params['name'] = 'Some name'
|
params['name'] = 'Some name'
|
||||||
params['organization'] = organization.id
|
params['organization'] = organization.id
|
||||||
response = post(
|
response = post(
|
||||||
reverse('api:credential_list'),
|
reverse('api:credential_list', kwargs={'version': version}),
|
||||||
params,
|
params,
|
||||||
org_admin
|
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.']
|
'as it may break the functionality of the resources using it.']
|
||||||
assert response.data['credential_type'] == expected
|
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()
|
related_obj.delete()
|
||||||
response = _change_credential_type()
|
response = _change_credential_type()
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|||||||
Reference in New Issue
Block a user