diff options
-rw-r--r-- | paramiko/config.py | 2 | ||||
-rw-r--r-- | tests/test_config.py | 31 |
2 files changed, 31 insertions, 2 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index 22e2e2b3..cd5aae90 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -122,7 +122,7 @@ class SSHConfig (object): if self._allowed(config['host'], hostname) ] - ret = {} + ret = SSHConfigDict() for match in matches: for key, value in match['config'].items(): if key not in ret: diff --git a/tests/test_config.py b/tests/test_config.py index 9edab3d9..20f051fc 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,8 +2,10 @@ # repository import pytest -from paramiko import config +from paramiko import config +from paramiko.util import parse_ssh_config +from paramiko.py3compat import StringIO def test_SSHConfigDict_construct_empty(): assert not config.SSHConfigDict() @@ -43,3 +45,30 @@ def test_SSHConfigDict_as_int_failures(non_int): with pytest.raises(exception_type): conf.as_int("key") + + +def test_SSHConfig_host_dicts_are_SSHConfigDict_instances(): + test_config_file = """ +Host *.example.com + Port 2222 + +Host * + Port 3333 + """ + f = StringIO(test_config_file) + config = parse_ssh_config(f) + assert config.lookup("foo.example.com").as_int("port") == 2222 + + +def test_SSHConfig_wildcard_host_dicts_are_SSHConfigDict_instances(): + test_config_file = """\ +Host *.example.com + Port 2222 + +Host * + Port 3333 + """ + f = StringIO(test_config_file) + config = parse_ssh_config(f) + assert config.lookup("anything-else").as_int("port") == 3333 + |