1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

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:
Aaron Tan 2016-08-24 11:17:10 -04:00 committed by GitHub
commit 37e19115a8
2 changed files with 18 additions and 1 deletions

View File

@ -747,7 +747,9 @@ class Job(UnifiedJob, JobOptions):
'''
if self.survey_passwords:
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)
else:
return self.extra_vars

View File

@ -32,6 +32,21 @@ def test_job_survey_password_redaction():
'secret_key': '$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):
"""Verify that safe_args hides passwords in the job extra_vars"""
kwargs = {'ansible_version': '2.1'}