Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_make_ssh_forward_server_sets_daemon(self, case):
self.start_echo_and_ssh_server()
tunnel = sshtunnel.open_tunnel(
(self.saddr, self.sport),
ssh_username=SSH_USERNAME,
ssh_password=SSH_PASSWORD,
remote_bind_address=(self.eaddr, self.eport),
logger=self.log,
ssh_config_file=None,
allow_agent=False
)
try:
tunnel.daemon_forward_servers = case
tunnel.start()
for server in tunnel._server_list:
self.assertEqual(server.daemon_threads, case)
finally:
tunnel.stop()
def test_open_tunnel(self):
""" Test wrapper method mainly used from CLI """
server = sshtunnel.open_tunnel(
(self.saddr, self.sport),
ssh_username=SSH_USERNAME,
ssh_password=SSH_PASSWORD,
remote_bind_address=(self.eaddr, self.eport),
logger=self.log,
ssh_config_file=None,
allow_agent=False
)
self.assertEqual(server.ssh_host, self.saddr)
self.assertEqual(server.ssh_port, self.sport)
self.assertEqual(server.ssh_username, SSH_USERNAME)
self.assertEqual(server.ssh_password, SSH_PASSWORD)
self.assertEqual(server.logger, self.log)
self.start_echo_and_ssh_server()
server.start()
self._check_server_auth()
def capture_stdout_stderr():
(old_out, old_err) = (sys.stdout, sys.stderr)
try:
out = [StringIO(), StringIO()]
(sys.stdout, sys.stderr) = out
yield out
finally:
(sys.stdout, sys.stderr) = (old_out, old_err)
out[0] = out[0].getvalue()
out[1] = out[1].getvalue()
# Ensure that ``ssh_config_file is None`` during tests, exceptions are not
# raised and pkey loading from an SSH agent is disabled
open_tunnel = partial(
sshtunnel.open_tunnel,
mute_exceptions=False,
ssh_config_file=None,
allow_agent=False,
skip_tunnel_checkup=True,
)
# CONSTANTS
SSH_USERNAME = get_random_string()
SSH_PASSWORD = get_random_string()
SSH_DSS = b'\x44\x78\xf0\xb9\xa2\x3c\xc5\x18\x20\x09\xff\x75\x5b\xc1\xd2\x6c'
SSH_RSA = b'\x60\x73\x38\x44\xcb\x51\x86\x65\x7f\xde\xda\xa2\x2b\x5a\x57\xd5'
ECDSA = b'\x25\x19\xeb\x55\xe6\xa1\x47\xff\x4f\x38\xd2\x75\x6f\xa5\xd5\x60'
FINGERPRINTS = {
'ssh-dss': SSH_DSS,
'ssh-rsa': SSH_RSA,