summaryrefslogtreecommitdiffhomepage
path: root/tests/test_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_util.py')
-rw-r--r--tests/test_util.py63
1 files changed, 50 insertions, 13 deletions
diff --git a/tests/test_util.py b/tests/test_util.py
index 9a155bfa..efda9b2f 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -27,7 +27,9 @@ import os
import unittest
from Crypto.Hash import SHA
import paramiko.util
+from paramiko.util import lookup_ssh_host_config as host_config
+from util import ParamikoTest
test_config_file = """\
Host *
@@ -58,17 +60,7 @@ BGQ3GQ/Fc7SX6gkpXkwcZryoi4kNFhHu5LvHcZPdxXV1D+uTMfGS1eyd2Yz/DoNWXNAl8TI0cAsW\
from paramiko import *
-class UtilTest (unittest.TestCase):
-
- assertTrue = unittest.TestCase.failUnless # for Python 2.3 and below
- assertFalse = unittest.TestCase.failIf # for Python 2.3 and below
-
- def setUp(self):
- pass
-
- def tearDown(self):
- pass
-
+class UtilTest(ParamikoTest):
def test_1_import(self):
"""
verify that all the classes can be imported from paramiko.
@@ -213,7 +205,52 @@ Host *
self.assertRaises(AssertionError,
lambda: paramiko.util.retry_on_signal(raises_other_exception))
- def test_9_host_config_test_negation(self):
+ def test_9_proxycommand_config_equals_parsing(self):
+ """
+ ProxyCommand should not split on equals signs within the value.
+ """
+ conf = """
+Host space-delimited
+ ProxyCommand foo bar=biz baz
+
+Host equals-delimited
+ ProxyCommand=foo bar=biz baz
+"""
+ f = cStringIO.StringIO(conf)
+ config = paramiko.util.parse_ssh_config(f)
+ for host in ('space-delimited', 'equals-delimited'):
+ self.assertEquals(
+ host_config(host, config)['proxycommand'],
+ 'foo bar=biz baz'
+ )
+
+ def test_10_proxycommand_interpolation(self):
+ """
+ ProxyCommand should perform interpolation on the value
+ """
+ config = paramiko.util.parse_ssh_config(cStringIO.StringIO("""
+Host specific
+ Port 37
+ ProxyCommand host %h port %p lol
+
+Host portonly
+ Port 155
+
+Host *
+ Port 25
+ ProxyCommand host %h port %p
+"""))
+ for host, val in (
+ ('foo.com', "host foo.com port 25"),
+ ('specific', "host specific port 37 lol"),
+ ('portonly', "host portonly port 155"),
+ ):
+ self.assertEquals(
+ host_config(host, config)['proxycommand'],
+ val
+ )
+
+ def test_11_host_config_test_negation(self):
test_config_file = """
Host www13.* !*.example.com
Port 22
@@ -235,7 +272,7 @@ Host *
{'hostname': host, 'port': '8080'}
)
- def test_10_host_config_test_proxycommand(self):
+ def test_12_host_config_test_proxycommand(self):
test_config_file = """
Host proxy-with-equal-divisor-and-space
ProxyCommand = foo=bar