Update affected tests for env variables ordering and add new tests which
verify bash history is disabled when sudo password is provided.
@@ -47,15 +47,16 @@ class ParamikoRemoteCommandActionTestCase(unittest2.TestCase):
cmd_action.sudo = True
cmd_action.sudo_password = 'sudo pass'
- ex = 'echo -e \'sudo pass\n\' | sudo -S -E -- bash -c \'cd /tmp && echo boo bah baz\''
+ ex = ('set +o history ; echo -e \'sudo pass\n\' | sudo -S -E -- '
+ 'bash -c \'cd /tmp && echo boo bah baz\'')
self.assertEqual(cmd_action.get_full_command_string(), ex)
def test_get_command_string_with_env_vars(self):
cmd_action = ParamikoRemoteCommandActionTestCase._get_test_command_action(
'echo boo bah baz')
cmd_action.env_vars = {'FOO': 'BAR', 'BAR': 'BEET CAFE'}
- ex = 'export FOO=BAR ' + \
- 'BAR=\'BEET CAFE\'' + \
+ ex = 'export BAR=\'BEET CAFE\' ' + \
+ 'FOO=BAR' + \
' && cd /tmp && echo boo bah baz'
self.assertEqual(cmd_action.get_full_command_string(), ex)
@@ -66,14 +67,18 @@ class ParamikoRemoteCommandActionTestCase(unittest2.TestCase):
'\'export FOO=BAR ' + \
'BAR=\'"\'"\'BEET CAFE\'"\'"\'' + \
' && cd /tmp && echo boo bah baz\''
+ ex = 'sudo -E -- bash -c ' + \
+ '\'export BAR=\'"\'"\'BEET CAFE\'"\'"\' ' + \
+ 'FOO=BAR' + \
+ ' && cd /tmp && echo boo bah baz\''
self.assertEqual(cmd_action.get_full_command_string(), ex)
# with sudo_password
cmd_action.sudo = True
cmd_action.sudo_password = 'sudo pass'
- ex = 'echo -e \'sudo pass\n\' | sudo -S -E -- bash -c ' + \
- '\'export FOO=BAR ' + \
- 'BAR=\'"\'"\'BEET CAFE\'"\'"\'' + \
+ ex = 'set +o history ; echo -e \'sudo pass\n\' | sudo -S -E -- bash -c ' + \
+ '\'export BAR=\'"\'"\'BEET CAFE\'"\'"\' ' + \
+ 'FOO=BAR HISTFILE=/dev/null HISTSIZE=0' + \
' && cd /tmp && echo boo bah baz\''
self.assertEqual(cmd_action.get_full_command_string(), ex)
