diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2019-07-02 19:24:01 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2019-08-26 20:48:25 -0400 |
commit | 5a56eed757c598301f1cc1f5a31e9d06aa081ac1 (patch) | |
tree | ee5eb8ca70892fb5f934ee61111d1555e4d705b0 /tests | |
parent | c50f825aac15f878647ffb7533fdbe157399ca8b (diff) |
Start moving config snippets to files
Diffstat (limited to 'tests')
-rw-r--r-- | tests/robey.config | 18 | ||||
-rw-r--r-- | tests/test_config.py | 37 |
2 files changed, 27 insertions, 28 deletions
diff --git a/tests/robey.config b/tests/robey.config new file mode 100644 index 00000000..2175182f --- /dev/null +++ b/tests/robey.config @@ -0,0 +1,18 @@ +# A timeless classic? +# NOTE: some lines in here have 'extra' whitespace (incl trailing, and mixed +# tabs/spaces!) on purpose. + +Host * + User robey + IdentityFile =~/.ssh/id_rsa + +# comment +Host *.example.com + User bjork +Port=3333 +Host * + Crazy something dumb +Host spoo.example.com +Crazy something else + +# vim: set ft=sshconfig list : diff --git a/tests/test_config.py b/tests/test_config.py index 903690f7..cecb6204 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -11,34 +11,18 @@ from paramiko.py3compat import StringIO from paramiko import SSHConfig, SSHConfigDict from paramiko.util import lookup_ssh_host_config, parse_ssh_config +from .util import _support -# Note some lines in this configuration have trailing spaces on purpose -test_config_file = """\ -Host * - User robey - IdentityFile =~/.ssh/id_rsa - -# comment -Host *.example.com - \tUser bjork -Port=3333 -Host * -""" - -dont_strip_whitespace_please = "\t \t Crazy something dumb " -test_config_file += dont_strip_whitespace_please -test_config_file += """ -Host spoo.example.com -Crazy something else -""" +class TestSSHConfig(object): + def setup(self): + self.config_flo = open(_support("robey.config")) + def teardown(self): + self.config_flo.close() -class TestSSHConfig(object): def test_parse_config(self): - global test_config_file - f = StringIO(test_config_file) - config = parse_ssh_config(f) + config = parse_ssh_config(self.config_flo) expected = [ {"host": ["*"], "config": {}}, { @@ -58,9 +42,7 @@ class TestSSHConfig(object): assert config._config == expected def test_host_config(self): - global test_config_file - f = StringIO(test_config_file) - config = parse_ssh_config(f) + config = parse_ssh_config(self.config_flo) for host, values in { "irc.danger.com": { @@ -267,8 +249,7 @@ IdentityFile something_%l_using_fqdn assert config.lookup("abcqwerty")["hostname"] == "127.0.0.1" def test_get_hostnames(self): - f = StringIO(test_config_file) - config = parse_ssh_config(f) + config = parse_ssh_config(self.config_flo) expected = {"*", "*.example.com", "spoo.example.com"} assert config.get_hostnames() == expected |