mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Do not set the default if the field was not passed in to kwargs_extra_vars
This commit is contained in:
parent
5907b3dcad
commit
c99d4659da
@ -130,12 +130,14 @@ class SurveyJobTemplateMixin(models.Model):
|
||||
for survey_element in self.survey_spec.get("spec", []):
|
||||
default = survey_element.get('default')
|
||||
variable_key = survey_element.get('variable')
|
||||
|
||||
if survey_element.get('type') == 'password':
|
||||
if variable_key in kwargs_extra_vars and default:
|
||||
kw_value = kwargs_extra_vars[variable_key]
|
||||
if kw_value.startswith('$encrypted$') and kw_value != default:
|
||||
kwargs_extra_vars[variable_key] = default
|
||||
if default is not None:
|
||||
|
||||
if default is not None and variable_key in extra_vars:
|
||||
extra_vars[variable_key] = default
|
||||
|
||||
# Overwrite job template extra vars with explicit job extra vars
|
||||
|
||||
@ -211,7 +211,7 @@ def test_launch_with_non_empty_survey_spec_no_license(job_template_factory, post
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.survey
|
||||
def test_redact_survey_passwords_in_activity_stream(job_template_with_survey_passwords):
|
||||
job_template_with_survey_passwords.create_unified_job()
|
||||
job_template_with_survey_passwords.create_unified_job(extra_vars={'secret_key':''})
|
||||
AS_record = ActivityStream.objects.filter(object1='job').all()[0]
|
||||
changes_dict = json.loads(AS_record.changes)
|
||||
extra_vars = json.loads(changes_dict['extra_vars'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user