mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
simplify become testing and handling, we had drifted and were doulbe checking prompt, become and become_pass
fixed tests to conform to new signature and now tests both with and w/o password now we are more explicit about self.prompt
This commit is contained in:
parent
eb0e7e198b
commit
c17fbf2f12
5 changed files with 77 additions and 71 deletions
|
@ -116,7 +116,7 @@ class TestPlayContext(unittest.TestCase):
|
|||
default_cmd = "/bin/foo"
|
||||
default_exe = "/bin/bash"
|
||||
sudo_exe = C.DEFAULT_SUDO_EXE or 'sudo'
|
||||
sudo_flags = C.DEFAULT_SUDO_FLAGS + " -n "
|
||||
sudo_flags = C.DEFAULT_SUDO_FLAGS
|
||||
su_exe = C.DEFAULT_SU_EXE or 'su'
|
||||
su_flags = C.DEFAULT_SU_FLAGS or ''
|
||||
pbrun_exe = 'pbrun'
|
||||
|
@ -134,7 +134,12 @@ class TestPlayContext(unittest.TestCase):
|
|||
|
||||
play_context.become_method = 'sudo'
|
||||
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
||||
self.assertEqual(cmd, """%s -c '%s %s -S -p "%s" -u %s %s -c '"'"'echo %s; %s'"'"''""" % (default_exe, sudo_exe, sudo_flags, play_context.prompt, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
||||
self.assertEqual(cmd, """%s -c '%s %s -n -S -u %s %s -c '"'"'echo %s; %s'"'"''""" % (default_exe, sudo_exe, sudo_flags, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
||||
play_context.become_pass = 'testpass'
|
||||
cmd = play_context.make_become_cmd(cmd=default_cmd, executable=default_exe)
|
||||
self.assertEqual(cmd, """%s -c '%s %s -p "%s" -S -u %s %s -c '"'"'echo %s; %s'"'"''""" % (default_exe, sudo_exe, sudo_flags, play_context.prompt, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
||||
|
||||
play_context.become_pass = None
|
||||
|
||||
play_context.become_method = 'su'
|
||||
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue