|
|
|
@ -140,28 +140,28 @@ 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 -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))
|
|
|
|
|
self.assertEqual(cmd, """%s %s -u %s %s -c 'echo %s; %s'""" % (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" -u %s %s -c '"'"'echo %s; %s'"'"''""" % (default_exe, sudo_exe, sudo_flags.replace('-n',''), play_context.prompt, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
|
|
|
|
self.assertEqual(cmd, """%s %s -p "%s" -u %s %s -c 'echo %s; %s'""" % (sudo_exe, sudo_flags.replace('-n',''), 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")
|
|
|
|
|
self.assertEqual(cmd, """%s -c '%s %s -c %s -c '"'"'echo %s; %s'"'"''""" % (default_exe, su_exe, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
|
|
|
|
self.assertEqual(cmd, """%s %s -c '%s -c '"'"'echo %s; %s'"'"''""" % (su_exe, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
|
|
|
|
|
|
|
|
|
play_context.become_method = 'pbrun'
|
|
|
|
|
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
|
|
|
|
self.assertEqual(cmd, """%s -c '%s -b %s -u %s '"'"'echo %s; %s'"'"''""" % (default_exe, pbrun_exe, pbrun_flags, play_context.become_user, play_context.success_key, default_cmd))
|
|
|
|
|
self.assertEqual(cmd, """%s -b %s -u %s 'echo %s; %s'""" % (pbrun_exe, pbrun_flags, play_context.become_user, play_context.success_key, default_cmd))
|
|
|
|
|
|
|
|
|
|
play_context.become_method = 'pfexec'
|
|
|
|
|
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
|
|
|
|
self.assertEqual(cmd, """%s -c '%s %s "'"'"'echo %s; %s'"'"'"'""" % (default_exe, pfexec_exe, pfexec_flags, play_context.success_key, default_cmd))
|
|
|
|
|
self.assertEqual(cmd, '''%s %s "'echo %s; %s'"''' % (pfexec_exe, pfexec_flags, play_context.success_key, default_cmd))
|
|
|
|
|
|
|
|
|
|
play_context.become_method = 'doas'
|
|
|
|
|
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
|
|
|
|
self.assertEqual(cmd, """%s -c '%s %s echo %s && %s %s env ANSIBLE=true %s'""" % (default_exe, doas_exe, doas_flags, play_context.success_key, doas_exe, doas_flags, default_cmd))
|
|
|
|
|
self.assertEqual(cmd, """%s %s echo %s && %s %s env ANSIBLE=true %s""" % (doas_exe, doas_flags, play_context.success_key, doas_exe, doas_flags, default_cmd))
|
|
|
|
|
|
|
|
|
|
play_context.become_method = 'bad'
|
|
|
|
|
self.assertRaises(AnsibleError, play_context.make_become_cmd, cmd=default_cmd, executable="/bin/bash")
|
|
|
|
|