How to use the sshtunnel.SSHTunnelForwarder._read_ssh_config function in sshtunnel

To help you get started, we’ve selected a few sshtunnel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pahaz / sshtunnel / tests / test_forwarder.py View on Github external
def test_read_ssh_config(self):
        """ Test that we can gather host information from a config file """
        (ssh_hostname,
         ssh_username,
         ssh_private_key,
         ssh_port,
         ssh_proxy,
         compression) = sshtunnel.SSHTunnelForwarder._read_ssh_config(
             'test',
             get_test_data_path(TEST_CONFIG_FILE),
        )
        self.assertEqual(ssh_hostname, 'test')
        self.assertEqual(ssh_username, 'test')
        self.assertEqual(PKEY_FILE, ssh_private_key)
        self.assertEqual(ssh_port, 22)  # fallback value
        self.assertListEqual(ssh_proxy.cmd[-2:], ['test:22', 'sshproxy'])
        self.assertTrue(compression)

        # passed parameters are not overriden by config
        (ssh_hostname,
         ssh_username,
         ssh_private_key,
         ssh_port,
         ssh_proxy,
github pahaz / sshtunnel / tests / test_forwarder.py View on Github external
get_test_data_path(TEST_CONFIG_FILE),
        )
        self.assertEqual(ssh_hostname, 'test')
        self.assertEqual(ssh_username, 'test')
        self.assertEqual(PKEY_FILE, ssh_private_key)
        self.assertEqual(ssh_port, 22)  # fallback value
        self.assertListEqual(ssh_proxy.cmd[-2:], ['test:22', 'sshproxy'])
        self.assertTrue(compression)

        # passed parameters are not overriden by config
        (ssh_hostname,
         ssh_username,
         ssh_private_key,
         ssh_port,
         ssh_proxy,
         compression) = sshtunnel.SSHTunnelForwarder._read_ssh_config(
             'other',
             get_test_data_path(TEST_CONFIG_FILE),
             compression=False
        )
        self.assertEqual(ssh_hostname, '10.0.0.1')
        self.assertEqual(ssh_port, 222)
        self.assertFalse(compression)