Fix more become plugins (#708)

* Fix more become plugins.

* Don't re-use var.

* Other way around.
This commit is contained in:
Felix Fontein 2020-07-29 20:27:16 +02:00 committed by GitHub
commit 08f10d5758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 113 additions and 8 deletions

View file

@ -14,6 +14,27 @@ from ansible import context
from .helper import call_become_plugin
def test_doas_basic(mocker, parser, reset_cli_args):
options = parser.parse_args([])
context._init_global_context(options)
default_cmd = "/bin/foo"
default_exe = "/bin/bash"
doas_exe = 'doas'
doas_flags = '-n'
success = 'BECOME-SUCCESS-.+?'
task = {
'become_method': 'community.general.doas',
}
var_options = {}
cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe)
print(cmd)
assert (re.match("""%s %s %s -c 'echo %s; %s'""" % (doas_exe, doas_flags, default_exe, success,
default_cmd), cmd) is not None)
def test_doas(mocker, parser, reset_cli_args):
options = parser.parse_args([])
context._init_global_context(options)