Created
April 24, 2019 20:03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_______________________________________________________________ test_callback_plugin_task_args_leak[playbook0] _______________________________________________________________ | |
executor = <ansible_runner.runner.Runner object at 0x106d37cc0> | |
playbook = {'no_log_on_ok.yml': '\n- name: args should not be logged when no_log is set at the task or module level\n connection... url=https://example.org username="PUBLIC" password="PRIVATE"\n - copy: content="PRIVATE" dest="/tmp/tmp_no_log"\n'} | |
@pytest.mark.parametrize('playbook', [ | |
{'no_log_on_ok.yml': ''' | |
- name: args should not be logged when no_log is set at the task or module level | |
connection: local | |
hosts: all | |
gather_facts: no | |
tasks: | |
- shell: echo "PUBLIC" | |
- shell: echo "PRIVATE" | |
no_log: true | |
- uri: url=https://example.org username="PUBLIC" password="PRIVATE" | |
- copy: content="PRIVATE" dest="/tmp/tmp_no_log" | |
'''}, # noqa | |
]) | |
def test_callback_plugin_task_args_leak(executor, playbook): | |
executor.run() | |
events = list(executor.events) | |
assert events[0]['event'] == 'playbook_on_start' | |
assert events[1]['event'] == 'playbook_on_play_start' | |
# task 1 | |
assert events[2]['event'] == 'playbook_on_task_start' | |
> assert events[3]['event'] == 'runner_on_ok' | |
E AssertionError: assert 'runner_on_start' == 'runner_on_ok' | |
E - runner_on_start | |
E + runner_on_ok | |
test/integration/test_display_callback.py:173: AssertionError | |
---------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------- | |
PLAY [args should not be logged when no_log is set at the task or module level] *** | |
TASK [shell] ******************************************************************* | |
[WARNING]: Platform darwin on host localhost is using the discovered Python | |
interpreter at /usr/bin/python, but future installation of another Python | |
interpreter could change this. See https://docs.ansible.com/ansible/devel/refer | |
ence_appendices/interpreter_discovery.html for more information. | |
changed: [localhost] | |
TASK [shell] ******************************************************************* | |
changed: [localhost] | |
TASK [uri] ********************************************************************* | |
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (uri) module: username Supported parameters include: attributes, backup, body, body_format, client_cert, client_key, content, creates, delimiter, dest, directory_mode, follow, follow_redirects, force, force_basic_auth, group, headers, http_agent, method, mode, owner, regexp, remote_src, removes, return_content, selevel, serole, setype, seuser, src, status_code, timeout, unix_socket, unsafe_writes, url, url_password, url_username, use_proxy, validate_certs"} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=2 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 | |
________________________________________________________ test_callback_plugin_censoring_does_not_overwrite[playbook0] ________________________________________________________ | |
executor = <ansible_runner.runner.Runner object at 0x106c5cd30> | |
playbook = {'loop_with_no_log.yml': '\n- name: playbook variable should not be overwritten when using no log\n connection: local...ms:\n - "echo helloworld!"\n - debug: msg="{{ command_register.results|map(attribute=\'stdout\')|list }}"\n'} | |
@pytest.mark.parametrize('playbook', [ | |
{'loop_with_no_log.yml': ''' | |
- name: playbook variable should not be overwritten when using no log | |
connection: local | |
hosts: all | |
gather_facts: no | |
tasks: | |
- command: "{{ item }}" | |
register: command_register | |
no_log: True | |
with_items: | |
- "echo helloworld!" | |
- debug: msg="{{ command_register.results|map(attribute='stdout')|list }}" | |
'''}, # noqa | |
]) | |
def test_callback_plugin_censoring_does_not_overwrite(executor, playbook): | |
executor.run() | |
events = list(executor.events) | |
assert events[0]['event'] == 'playbook_on_start' | |
assert events[1]['event'] == 'playbook_on_play_start' | |
# task 1 | |
assert events[2]['event'] == 'playbook_on_task_start' | |
# Ordering of task and item events may differ randomly | |
> assert set(['runner_on_ok', 'runner_item_on_ok']) == set([data['event'] for data in events[3:5]]) | |
E AssertionError: assert {'runner_item...runner_on_ok'} == {'runner_item_...ner_on_start'} | |
E Extra items in the left set: | |
E 'runner_on_ok' | |
E Extra items in the right set: | |
E 'runner_on_start' | |
E Use -v to get the full diff | |
test/integration/test_display_callback.py:208: AssertionError | |
---------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------- | |
PLAY [playbook variable should not be overwritten when using no log] *********** | |
TASK [command] ***************************************************************** | |
changed: [localhost] => (item=None) | |
changed: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"msg": [ | |
"helloworld!" | |
] | |
} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment