mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Merge pull request #3320 from jangsutsr/3248_resolve_extra_var_n_survey_mess_up
Resolve extra vars display mix-up with passworded survey questions.
This commit is contained in:
@@ -747,7 +747,9 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
'''
|
'''
|
||||||
if self.survey_passwords:
|
if self.survey_passwords:
|
||||||
extra_vars = json.loads(self.extra_vars)
|
extra_vars = json.loads(self.extra_vars)
|
||||||
extra_vars.update(self.survey_passwords)
|
for key, value in self.survey_passwords.items():
|
||||||
|
if key in extra_vars:
|
||||||
|
extra_vars[key] = value
|
||||||
return json.dumps(extra_vars)
|
return json.dumps(extra_vars)
|
||||||
else:
|
else:
|
||||||
return self.extra_vars
|
return self.extra_vars
|
||||||
|
|||||||
@@ -32,6 +32,21 @@ def test_job_survey_password_redaction():
|
|||||||
'secret_key': '$encrypted$',
|
'secret_key': '$encrypted$',
|
||||||
'SSN': '$encrypted$'}
|
'SSN': '$encrypted$'}
|
||||||
|
|
||||||
|
@pytest.mark.survey
|
||||||
|
def test_survey_passwords_not_in_extra_vars():
|
||||||
|
"""Tests that survey passwords not included in extra_vars are
|
||||||
|
not included when displaying job information"""
|
||||||
|
job = Job(
|
||||||
|
name="test-survey-not-in",
|
||||||
|
extra_vars=json.dumps({
|
||||||
|
'submitter_email': 'foobar@redhat.com'}),
|
||||||
|
survey_passwords={
|
||||||
|
'secret_key': '$encrypted$',
|
||||||
|
'SSN': '$encrypted$'})
|
||||||
|
assert json.loads(job.display_extra_vars()) == {
|
||||||
|
'submitter_email': 'foobar@redhat.com',
|
||||||
|
}
|
||||||
|
|
||||||
def test_job_safe_args_redacted_passwords(job):
|
def test_job_safe_args_redacted_passwords(job):
|
||||||
"""Verify that safe_args hides passwords in the job extra_vars"""
|
"""Verify that safe_args hides passwords in the job extra_vars"""
|
||||||
kwargs = {'ansible_version': '2.1'}
|
kwargs = {'ansible_version': '2.1'}
|
||||||
|
|||||||
Reference in New Issue
Block a user