mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
Add two tests for nested and templated extra_vars keys
This commit is contained in:
@@ -1209,6 +1209,42 @@ class TestJobCredentials(TestJobExecution):
|
|||||||
assert extra_vars["turbo_button"] == "True"
|
assert extra_vars["turbo_button"] == "True"
|
||||||
return ['successful', 0]
|
return ['successful', 0]
|
||||||
|
|
||||||
|
def test_custom_environment_injectors_with_nested_extra_vars(self, private_data_dir, job, mock_me):
|
||||||
|
task = jobs.RunJob()
|
||||||
|
some_cloud = CredentialType(
|
||||||
|
kind='cloud',
|
||||||
|
name='SomeCloud',
|
||||||
|
managed=False,
|
||||||
|
inputs={'fields': [{'id': 'host', 'label': 'Host', 'type': 'string'}]},
|
||||||
|
injectors={'extra_vars': {'auth': {'host': '{{host}}'}}},
|
||||||
|
)
|
||||||
|
credential = Credential(pk=1, credential_type=some_cloud, inputs={'host': 'example.com'})
|
||||||
|
job.credentials.add(credential)
|
||||||
|
|
||||||
|
args = task.build_args(job, private_data_dir, {})
|
||||||
|
credential.credential_type.inject_credential(credential, {}, {}, args, private_data_dir)
|
||||||
|
extra_vars = parse_extra_vars(args, private_data_dir)
|
||||||
|
|
||||||
|
assert extra_vars["auth"]["host"] == "example.com"
|
||||||
|
|
||||||
|
def test_custom_environment_injectors_with_templated_extra_vars_key(self, private_data_dir, job, mock_me):
|
||||||
|
task = jobs.RunJob()
|
||||||
|
some_cloud = CredentialType(
|
||||||
|
kind='cloud',
|
||||||
|
name='SomeCloud',
|
||||||
|
managed=False,
|
||||||
|
inputs={'fields': [{'id': 'environment', 'label': 'Environment', 'type': 'string'}, {'id': 'host', 'label': 'Host', 'type': 'string'}]},
|
||||||
|
injectors={'extra_vars': {'{{environment}}_auth': {'host': '{{host}}'}}},
|
||||||
|
)
|
||||||
|
credential = Credential(pk=1, credential_type=some_cloud, inputs={'environment': 'test', 'host': 'example.com'})
|
||||||
|
job.credentials.add(credential)
|
||||||
|
|
||||||
|
args = task.build_args(job, private_data_dir, {})
|
||||||
|
credential.credential_type.inject_credential(credential, {}, {}, args, private_data_dir)
|
||||||
|
extra_vars = parse_extra_vars(args, private_data_dir)
|
||||||
|
|
||||||
|
assert extra_vars["test_auth"]["host"] == "example.com"
|
||||||
|
|
||||||
def test_custom_environment_injectors_with_complicated_boolean_template(self, job, private_data_dir, mock_me):
|
def test_custom_environment_injectors_with_complicated_boolean_template(self, job, private_data_dir, mock_me):
|
||||||
task = jobs.RunJob()
|
task = jobs.RunJob()
|
||||||
some_cloud = CredentialType(
|
some_cloud = CredentialType(
|
||||||
|
|||||||
Reference in New Issue
Block a user