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:
Ryan Petrello 2017-11-28 14:49:54 -05:00 committed by GitHub
commit 7b42316366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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