Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'-U={0}'.format(getpass.getuser()), # GW username
'-p=22', # GW SSH port
'-P={0}'.format(SSH_PASSWORD), # GW password
'-R', '10.0.0.1:8080', '10.0.0.2:8080', # remote bind list
'-L', ':8081', ':8082', # local bind list
'-k={0}'.format(SSH_DSS), # hostkey
'-K={0}'.format(__file__), # pkey file
'-S={0}'.format(SSH_PASSWORD), # pkey password
'-t', # concurrent connections (threaded)
'-vvv', # triple verbosity
'-x=10.0.0.2:', # proxy address
'-c=ssh_config', # ssh configuration file
'-z', # request compression
'-n', # disable SSH agent key lookup
]
parser = sshtunnel._parse_arguments(args)
self._test_parser(parser)
with capture_stdout_stderr(): # silence stderr
# First argument is mandatory
with self.assertRaises(SystemExit):
parser = sshtunnel._parse_arguments(args[1:])
# -R argument is mandatory
with self.assertRaises(SystemExit):
parser = sshtunnel._parse_arguments(args[:4] + args[5:])
'-K={0}'.format(__file__), # pkey file
'-S={0}'.format(SSH_PASSWORD), # pkey password
'-t', # concurrent connections (threaded)
'-vvv', # triple verbosity
'-x=10.0.0.2:', # proxy address
'-c=ssh_config', # ssh configuration file
'-z', # request compression
'-n', # disable SSH agent key lookup
]
parser = sshtunnel._parse_arguments(args)
self._test_parser(parser)
with capture_stdout_stderr(): # silence stderr
# First argument is mandatory
with self.assertRaises(SystemExit):
parser = sshtunnel._parse_arguments(args[1:])
# -R argument is mandatory
with self.assertRaises(SystemExit):
parser = sshtunnel._parse_arguments(args[:4] + args[5:])
def test_parse_arguments_long(self):
""" Test CLI argument parsing with long parameter names """
parser = sshtunnel._parse_arguments(
['10.10.10.10', # ssh_address
'--username={0}'.format(getpass.getuser()), # GW username
'--server_port=22', # GW SSH port
'--password={0}'.format(SSH_PASSWORD), # GW password
'--remote_bind_address', '10.0.0.1:8080', '10.0.0.2:8080',
'--local_bind_address', ':8081', ':8082', # local bind list
'--ssh_host_key={0}'.format(SSH_DSS), # hostkey
'--private_key_file={0}'.format(__file__), # pkey file
'--private_key_password={0}'.format(SSH_PASSWORD),
'--threaded', # concurrent connections (threaded)
'--verbose', '--verbose', '--verbose', # triple verbosity
'--proxy', '10.0.0.2:22', # proxy address
'--config', 'ssh_config', # ssh configuration file
'--compress', # request compression
'--noagent', # disable SSH agent key lookup
]