From 901af011a10e360c12d6d3488496a83a4a7ff771 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 15 Dec 2014 14:56:09 -0500 Subject: [PATCH] Verify that we are passed a source script if a 'custom' source is provided --- awx/api/serializers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index f198566c55..2f32657f29 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1015,6 +1015,13 @@ class InventorySourceOptionsSerializer(BaseSerializer): # FIXME return attrs + def validate_source_script(self, attrs, source): + src = attrs.get(source, None) + if 'source' in attrs and attrs.get('source', '') == 'custom': + if src is None or src == '': + raise serializers.ValidationError("source_script must be provided") + return attrs + def validate_source_vars(self, attrs, source): # source_env must be blank, a valid JSON or YAML dict, or ... # FIXME: support key=value pairs.