diff --git a/awx/main/fields.py b/awx/main/fields.py index 6e8d3bb1f3..d63d1a30b8 100644 --- a/awx/main/fields.py +++ b/awx/main/fields.py @@ -763,7 +763,7 @@ class CredentialTypeInjectorField(JSONSchemaField): if 'template' not in template_names: valid_namespace['tower'].filename = TowerNamespace() for template_name in template_names: - template_name = template_name[9:] + template_name = template_name.split('.')[1] setattr(valid_namespace['tower'].filename, template_name, 'EXAMPLE') for type_, injector in value.items(): diff --git a/awx/main/tests/functional/test_credential.py b/awx/main/tests/functional/test_credential.py index 2bf15b3f8e..37609cd222 100644 --- a/awx/main/tests/functional/test_credential.py +++ b/awx/main/tests/functional/test_credential.py @@ -107,10 +107,11 @@ def test_cred_type_input_schema_validity(input_, valid): ({}, True), ({'invalid-injector': {}}, False), ({'file': 123}, False), - ({'file': {}}, False), + ({'file': {}}, True), ({'file': {'template': '{{username}}'}}, True), ({'file': {'template.username': '{{username}}'}}, True), ({'file': {'template.username': '{{username}}', 'template.password': '{{pass}}'}}, True), + ({'file': {'template': '{{username}}', 'template.password': '{{pass}}'}}, False), ({'file': {'foo': 'bar'}}, False), ({'env': 123}, False), ({'env': {}}, True),