Merge pull request #2177 from YunfanZhang42/disallow_dict_on_credentials

Disallow posting dictionary as credentials to JT launch API endpoint.
This commit is contained in:
Yunfan Zhang
2018-06-20 13:37:21 -04:00
committed by GitHub
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
# Python
import pytest
# Django Rest Framework
from rest_framework.exceptions import ValidationError
# AWX
from awx.api.serializers import JobLaunchSerializer
def test_primary_key_related_field():
# We are testing if the PrimaryKeyRelatedField in this serializer can take dictionary.
# PrimaryKeyRelatedField should not be able to take dictionary as input, and should raise a ValidationError.
data = {'credentials' : {'1': '2', '3':'4'}}
with pytest.raises(ValidationError):
JobLaunchSerializer(data=data)