Restore ability of parsing extra_vars string for provisioning callback.

This commit is contained in:
Aaron Tan 2017-04-24 17:43:20 -04:00
parent 7d7d1daae7
commit 3a81ca0dce
2 changed files with 12 additions and 1 deletions

View File

@ -2,6 +2,7 @@
# Copyright (c) 2017 Ansible, Inc.
# All Rights Reserved.
import pytest
from awx.conf.models import Setting
from awx.main.utils import common
@ -52,3 +53,13 @@ def test_encrypt_field_with_ask():
def test_encrypt_field_with_empty_value():
encrypted = common.encrypt_field(Setting(value=None), 'value')
assert encrypted is None
@pytest.mark.parametrize('input_, output', [
({"foo": "bar"}, {"foo": "bar"}),
('{"foo": "bar"}', {"foo": "bar"}),
('---\nfoo: bar', {"foo": "bar"}),
(4399, {}),
])
def test_parse_yaml_or_json(input_, output):
assert common.parse_yaml_or_json(input_) == output

View File

@ -863,8 +863,8 @@ class OutputEventFilter(object):
def callback_filter_out_ansible_extra_vars(extra_vars):
extra_vars_redacted = {}
extra_vars = parse_yaml_or_json(extra_vars)
for key, value in extra_vars.iteritems():
if not key.startswith('ansible_'):
extra_vars_redacted[key] = value
return extra_vars_redacted