Merge pull request #1806 from AlanCoding/660_extra_vars_nondict

Raise error when runtime extra_vars are not dictionaries
This commit is contained in:
Alan Rominger 2016-05-05 08:14:45 -04:00
commit 11796ade45
2 changed files with 4 additions and 3 deletions

View File

@ -2234,8 +2234,9 @@ class JobLaunchSerializer(BaseSerializer):
except (ValueError, TypeError):
try:
extra_vars = yaml.safe_load(extra_vars)
except (yaml.YAMLError, TypeError, AttributeError):
errors['extra_vars'] = 'Must be valid JSON or YAML'
assert isinstance(extra_vars, dict)
except (yaml.YAMLError, TypeError, AttributeError, AssertionError):
errors['extra_vars'] = 'Must be a valid JSON or YAML dictionary'
if not isinstance(extra_vars, dict):
extra_vars = {}

View File

@ -159,7 +159,7 @@ def test_job_reject_invalid_prompted_extra_vars(runtime_data, job_template_promp
dict(extra_vars='{"unbalanced brackets":'), user('admin', True))
assert response.status_code == 400
assert response.data['extra_vars'] == ['Must be valid JSON or YAML']
assert response.data['extra_vars'] == ['Must be a valid JSON or YAML dictionary']
@pytest.mark.django_db
@pytest.mark.job_runtime_vars