diff options
author | Jeremy T. Bouse <jbouse@debian.org> | 2015-03-12 21:35:59 -0400 |
---|---|---|
committer | Jeremy T. Bouse <jbouse@debian.org> | 2015-03-12 21:35:59 -0400 |
commit | 01653e8710c38f3066078b2773ad47ccb3670c58 (patch) | |
tree | 8284e75857a06945167186d09dd9021fd24c2ee1 /tests/test_util.py | |
parent | 74794f84c2d9906aea5024dfccd90482fff9bab3 (diff) | |
parent | f784a533d6e1d09e89dc254f3493b491e19c94f0 (diff) | |
download | python-paramiko-01653e8710c38f3066078b2773ad47ccb3670c58.tar python-paramiko-01653e8710c38f3066078b2773ad47ccb3670c58.tar.gz |
Merge tag 'upstream/1.15.2'
Upstream version 1.15.2
Diffstat (limited to 'tests/test_util.py')
-rw-r--r-- | tests/test_util.py | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/tests/test_util.py b/tests/test_util.py index 35e1576..bfdc525 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -27,8 +27,8 @@ from hashlib import sha1 import unittest import paramiko.util -from paramiko.util import lookup_ssh_host_config as host_config -from paramiko.py3compat import StringIO, byte_ord +from paramiko.util import lookup_ssh_host_config as host_config, safe_string +from paramiko.py3compat import StringIO, byte_ord, b test_config_file = """\ Host * @@ -349,6 +349,11 @@ IdentityFile something_%l_using_fqdn config.parse(config_file) self.assertEqual(config.lookup("abcqwerty")["hostname"], "127.0.0.1") + def test_14_get_hostnames(self): + f = StringIO(test_config_file) + config = paramiko.util.parse_ssh_config(f) + self.assertEqual(config.get_hostnames(), set(['*', '*.example.com', 'spoo.example.com'])) + def test_quoted_host_names(self): test_config_file = """\ Host "param pam" param "pam" @@ -448,3 +453,34 @@ Host param3 parara ) for host in incorrect_data: self.assertRaises(Exception, conf._get_hosts, host) + + def test_safe_string(self): + vanilla = b("vanilla") + has_bytes = b("has \7\3 bytes") + safe_vanilla = safe_string(vanilla) + safe_has_bytes = safe_string(has_bytes) + expected_bytes = b("has %07%03 bytes") + err = "{0!r} != {1!r}" + assert safe_vanilla == vanilla, err.format(safe_vanilla, vanilla) + assert safe_has_bytes == expected_bytes, \ + err.format(safe_has_bytes, expected_bytes) + + def test_proxycommand_none_issue_418(self): + test_config_file = """ +Host proxycommand-standard-none + ProxyCommand None + +Host proxycommand-with-equals-none + ProxyCommand=None + """ + for host, values in { + 'proxycommand-standard-none': {'hostname': 'proxycommand-standard-none'}, + 'proxycommand-with-equals-none': {'hostname': 'proxycommand-with-equals-none'} + }.items(): + + f = StringIO(test_config_file) + config = paramiko.util.parse_ssh_config(f) + self.assertEqual( + paramiko.util.lookup_ssh_host_config(host, config), + values + ) |