diff --git a/awx/lib/tests/test_display_callback.py b/awx/lib/tests/test_display_callback.py index 25d12774d3..13822eb7b8 100644 --- a/awx/lib/tests/test_display_callback.py +++ b/awx/lib/tests/test_display_callback.py @@ -137,3 +137,21 @@ def test_callback_plugin_no_log_filters(executor, local_cache, playbook): with mock.patch.object(event_context, 'cache', local_cache): executor.run() assert 'SENSITIVE' not in json.dumps(local_cache.items()) + + +@pytest.mark.parametrize('playbook', [ +{'strip_env_vars.yml': ''' +- name: sensitive environment variables should be stripped from events + connection: local + hosts: all + tasks: + - shell: echo "Hello, World!" +'''}, # noqa +]) +def test_callback_plugin_strips_task_environ_variables(executor, local_cache, + playbook): + with mock.patch.object(event_context, 'cache', local_cache): + executor.run() + for event in local_cache.values(): + if event['event_data'].get('task') == 'setup': + assert os.environ['VIRTUAL_ENV'] not in json.dumps(event)