diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 7d6c350274..7d9069e4f0 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1163,13 +1163,6 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions, CustomVirtualE source_vars = dict(self.source_vars_dict) # make a copy if injector and self.source_vars_dict.get('plugin', '') != injector.get_proper_name(): source_vars['plugin'] = injector.get_proper_name() - elif not injector: - source_vars = dict(self.source_vars_dict) # make a copy - collection_pattern = re.compile("^(.+)\.(.+)\.(.+)$") # noqa - if 'plugin' not in source_vars: - raise ValidationError(_("plugin: must be present and of the form namespace.collection.inv_plugin")) - elif not bool(collection_pattern.match(source_vars['plugin'])): - raise ValidationError(_("plugin: must be of the form namespace.collection.inv_plugin")) return json.dumps(source_vars) ''' diff --git a/awx/main/tests/functional/api/test_inventory.py b/awx/main/tests/functional/api/test_inventory.py index 8eda9cddd0..a04a68c9bb 100644 --- a/awx/main/tests/functional/api/test_inventory.py +++ b/awx/main/tests/functional/api/test_inventory.py @@ -471,7 +471,10 @@ def test_inventory_source_vars_source_plugin_ok(post, inventory, admin_user, sou @pytest.mark.django_db @pytest.mark.parametrize('source_var_actual,description', [ - ({'plugin': 'namespace.collection.script'}, 'valid scm user plugin'), + ({'plugin': 'namespace.collection.script'}, 'scm source type source_vars are ignored valid'), + ({'plugin': 'namespace.collection.script'}, 'scm source type source_vars are ignored invalid'), + ({'plugin': ''}, 'scm source type source_vars are ignored blank'), + ({}, 'scm source type source_vars are ignored non-existent'), ]) def test_inventory_source_vars_source_plugin_scm_ok(post, inventory, admin_user, project, source_var_actual, description): r = post(reverse('api:inventory_source_list'), @@ -485,27 +488,6 @@ def test_inventory_source_vars_source_plugin_scm_ok(post, inventory, admin_user, assert r.data['source_vars'] == json.dumps(source_var_actual) -@pytest.mark.django_db -@pytest.mark.parametrize('source_var_actual,err_msg,description', [ - ({'foo': 'bar'}, 'plugin: must be present and of the form namespace.collection.inv_plugin', 'no plugin line'), - ({'plugin': ''}, 'plugin: must be of the form namespace.collection.inv_plugin', 'blank plugin line'), - ({'plugin': '.'}, 'plugin: must be of the form namespace.collection.inv_plugin', 'missing namespace, collection name, and inventory plugin'), - ({'plugin': 'a.'}, 'plugin: must be of the form namespace.collection.inv_plugin', 'missing collection name and inventory plugin'), - ({'plugin': 'a.b'}, 'plugin: must be of the form namespace.collection.inv_plugin', 'missing inventory plugin'), - ({'plugin': 'a.b.'}, 'plugin: must be of the form namespace.collection.inv_plugin', 'missing inventory plugin'), -]) -def test_inventory_source_vars_source_plugin_scm_invalid(post, inventory, admin_user, project, source_var_actual, err_msg, description): - r = post(reverse('api:inventory_source_list'), - {'name': 'new inv src', - 'source_vars': json.dumps(source_var_actual), - 'inventory': inventory.pk, - 'source': 'scm', - 'source_project': project.id,}, - admin_user, expect=400) - - assert err_msg in r.data['source_vars'][0] - - @pytest.mark.django_db @pytest.mark.parametrize('role,expect', [ ('admin_role', 200),