Disallow posting dictionary as credentials to JT launch API endpoint.

This commit is contained in:
Yunfan Zhang
2018-06-20 13:05:47 -04:00
parent 1b5ea07745
commit 9fec43c643
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)