summaryrefslogtreecommitdiffstats
path: root/test/units/playbook/test_play_context.py
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2015-09-04 15:30:31 +0200
committerBrian Coca <brian.coca+git@gmail.com>2015-09-04 16:36:16 +0200
commitc17fbf2f1261576359121193702ea926b492236d (patch)
treeab5ce19a585a5712158ac93604c6e65c21f42aa7 /test/units/playbook/test_play_context.py
parentremove closing connections after every task, this goes against conneciton cac... (diff)
downloadansible-c17fbf2f1261576359121193702ea926b492236d.tar.xz
ansible-c17fbf2f1261576359121193702ea926b492236d.zip
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
Diffstat (limited to 'test/units/playbook/test_play_context.py')
-rw-r--r--test/units/playbook/test_play_context.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/units/playbook/test_play_context.py b/test/units/playbook/test_play_context.py
index dcfc6df539..c1582a971a 100644
--- a/test/units/playbook/test_play_context.py
+++ b/test/units/playbook/test_play_context.py
@@ -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")