<s> import unittest2 <EOL> from st2common . models . system . paramiko_script_action import ParamikoRemoteScriptAction <EOL> class ParamikoRemoteScriptActionTests ( unittest2 . TestCase ) : <EOL> def test_get_command_string_no_env_vars ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> ex = '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> def test_get_command_string_with_env_vars ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> script_action . env_vars = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> def test_get_command_string_no_script_args_no_env_args ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> script_action . named_args = { } <EOL> script_action . positional_args = [ ] <EOL> ex = '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> def test_get_command_string_no_script_args_with_env_args ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> script_action . named_args = { } <EOL> script_action . positional_args = [ ] <EOL> script_action . env_vars = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> def test_script_path_shell_injection_safe ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> test_path = '<STR_LIT>' <EOL> script_action . remote_script = test_path <EOL> script_action . named_args = { } <EOL> script_action . positional_args = [ ] <EOL> ex = '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> def test_script_path_shell_injection_safe_with_env_vars ( self ) : <EOL> script_action = ParamikoRemoteScriptActionTests . _get_test_script_action ( ) <EOL> test_path = '<STR_LIT>' <EOL> script_action . remote_script = test_path <EOL> script_action . named_args = { } <EOL> script_action . positional_args = [ ] <EOL> script_action . env_vars = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ex = '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> script_action . sudo = True <EOL> ex = '<STR_LIT>' + '<STR_LIT>' + '<STR_LIT>' <EOL> self . assertEqual ( script_action . get_full_command_string ( ) , ex ) <EOL> @ staticmethod <EOL> def _get_test_script_action ( ) : <EOL> local_script_path = '<STR_LIT>' <EOL> script_action = ParamikoRemoteScriptAction ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> local_script_path , <EOL> '<STR_LIT>' , <EOL> named_args = { '<STR_LIT>' : '<STR_LIT>' } , <EOL> positional_args = [ '<STR_LIT>' ] , <EOL> env_vars = { } , <EOL> on_behalf_user = '<STR_LIT>' , <EOL> user = '<STR_LIT>' , <EOL> private_key = '<STR_LIT>' , <EOL> remote_dir = '<STR_LIT>' , <EOL> hosts = [ '<STR_LIT:127.0.0.1>' ] , <EOL> parallel = True , <EOL> sudo = False , <EOL> timeout = <NUM_LIT> , cwd = '<STR_LIT>' ) <EOL> return script_action </s>
