From a6dd8bb2d0b3698d967e576c31a611f285ff3a5f Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 31 Oct 2018 16:16:28 +0000 Subject: [PATCH] issue #409: stub test for mitogen_sudo method. --- .../integration/stub_connections/all.yml | 1 + .../integration/stub_connections/sudo.yml | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/ansible/integration/stub_connections/sudo.yml diff --git a/tests/ansible/integration/stub_connections/all.yml b/tests/ansible/integration/stub_connections/all.yml index c845d872..5a3f37cf 100644 --- a/tests/ansible/integration/stub_connections/all.yml +++ b/tests/ansible/integration/stub_connections/all.yml @@ -3,3 +3,4 @@ - import_playbook: lxd.yml - import_playbook: setns_lxc.yml - import_playbook: setns_lxd.yml +- import_playbook: sudo.yml diff --git a/tests/ansible/integration/stub_connections/sudo.yml b/tests/ansible/integration/stub_connections/sudo.yml new file mode 100644 index 00000000..b5e6f263 --- /dev/null +++ b/tests/ansible/integration/stub_connections/sudo.yml @@ -0,0 +1,20 @@ + +- name: integration/stub_connections/sudo.yml + hosts: test-targets + gather_facts: false + any_errors_fatal: true + tasks: + - meta: end_play + when: not is_mitogen + + - custom_python_detect_environment: + vars: + ansible_connection: mitogen_sudo + ansible_become_exe: stub-sudo.py + ansible_become_flags: --type=sometype --role=somerole + register: out + + - assert: + that: + - out.env.THIS_IS_STUB_SUDO == '1' + - (out.env.ORIGINAL_ARGV|from_json)[1:9] == ['-u', 'root', '-H', '-r', 'somerole', '-t', 'sometype', '--']