update stdout cleaner to use current job passwords

This commit is contained in:
AlanCoding
2017-01-31 14:32:20 -05:00
parent 8ea36adb19
commit f377da0ecb
2 changed files with 39 additions and 13 deletions
@@ -20,11 +20,9 @@ def job(mocker):
return ret
@pytest.mark.survey
def test_job_survey_password_redaction():
"""Tests the Job model's funciton to redact passwords from
extra_vars - used when displaying job information"""
job = Job(
@pytest.fixture
def job_with_survey():
return Job(
name="test-job-with-passwords",
extra_vars=json.dumps({
'submitter_email': 'foobar@redhat.com',
@@ -33,7 +31,13 @@ def test_job_survey_password_redaction():
survey_passwords={
'secret_key': '$encrypted$',
'SSN': '$encrypted$'})
assert json.loads(job.display_extra_vars()) == {
@pytest.mark.survey
def test_job_survey_password_redaction(job_with_survey):
"""Tests the Job model's funciton to redact passwords from
extra_vars - used when displaying job information"""
assert json.loads(job_with_survey.display_extra_vars()) == {
'submitter_email': 'foobar@redhat.com',
'secret_key': '$encrypted$',
'SSN': '$encrypted$'}
@@ -55,6 +59,27 @@ def test_survey_passwords_not_in_extra_vars():
}
@pytest.mark.survey
def test_survey_passwords_not_in_stdout(job_with_survey):
example_stdout = '''
PLAY [all] *********************************************************************
TASK [debug] *******************************************************************
ok: [webserver45] => {
"msg": "Helpful echo of your secret_key: secret_key=6kQngg3h8lgiSTvIEb21 "
}
TASK [debug] *******************************************************************
ok: [webserver46] => {
"msg": "Helpful echo of your secret_key: secret_key=123-45-6789 "
}
'''
display_stdout = job_with_survey._survey_search_and_replace(example_stdout)
assert display_stdout == example_stdout.replace(
'6kQngg3h8lgiSTvIEb21', '$encrypted$').replace('123-45-6789', '$encrypted$')
def test_job_safe_args_redacted_passwords(job):
"""Verify that safe_args hides passwords in the job extra_vars"""
kwargs = {'ansible_version': '2.1'}