def test_job_args_unredacted_passwords(job, tmpdir_factory): kwargs = {'ansible_version': '2.1', 'private_data_dir': tempfile.mkdtemp()} run_job = RunJob() args = run_job.build_args(job, **kwargs) ev_index = args.index('-e') + 1 extra_vars = json.loads(args[ev_index]) assert extra_vars['secret_key'] == 'my_password'
def test_job_args_unredacted_passwords(job): kwargs = {'ansible_version': '2.1'} run_job = RunJob() args = run_job.build_args(job, **kwargs) ev_index = args.index('-e') + 1 extra_vars = json.loads(args[ev_index]) assert extra_vars['secret_key'] == 'my_password'
def test_job_safe_args_redacted_passwords(job): """Verify that safe_args hides passwords in the job extra_vars""" kwargs = {'ansible_version': '2.1', 'private_data_dir': tempfile.mkdtemp()} run_job = RunJob() safe_args = run_job.build_safe_args(job, **kwargs) ev_index = safe_args.index('-e') + 1 extra_vars = json.loads(safe_args[ev_index]) assert extra_vars['secret_key'] == '$encrypted$'
def test_job_args_unredacted_passwords(job, tmpdir_factory): kwargs = {'ansible_version': '2.1', 'private_data_dir': tempfile.mkdtemp()} run_job = RunJob() args = run_job.build_args(job, **kwargs) ev_index = args.index('-e') + 1 extra_var_file = open(args[ev_index][1:], 'r') extra_vars = yaml.load(extra_var_file, SafeLoader) extra_var_file.close() assert extra_vars['secret_key'] == 'my_password'