summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2012-11-05 17:44:25 -0800
committerJeff Forcier <jeff@bitprophet.org>2012-11-05 17:44:25 -0800
commit191a5fc08cb8ce08917ad4e8739d7d5efbec2be2 (patch)
treec17de59bacd8a41dda37d3c917d2c2ce0a536ac9
parent0981c25cd8ef651e6274feae8b3b6acd0869b680 (diff)
Implement (& test for) ProxyCommand interpolation.
Forgot this earlier.
-rw-r--r--paramiko/config.py7
-rw-r--r--tests/test_util.py28
2 files changed, 33 insertions, 2 deletions
diff --git a/paramiko/config.py b/paramiko/config.py
index 8daee18c..2828d903 100644
--- a/paramiko/config.py
+++ b/paramiko/config.py
@@ -174,7 +174,12 @@ class SSHConfig (object):
('%l', fqdn),
('%u', user),
('%r', remoteuser)
- ]
+ ],
+ 'proxycommand': [
+ ('%h', config['hostname']),
+ ('%p', port),
+ ('%r', remoteuser),
+ ],
}
for k in config:
if k in replacements:
diff --git a/tests/test_util.py b/tests/test_util.py
index 83de0044..093a2157 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -196,7 +196,7 @@ Host *
self.assertRaises(AssertionError,
lambda: paramiko.util.retry_on_signal(raises_other_exception))
- def test_9_proxycommand_config_parsing(self):
+ def test_9_proxycommand_config_equals_parsing(self):
"""
ProxyCommand should not split on equals signs within the value.
"""
@@ -214,3 +214,29 @@ Host equals-delimited
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 *
+ Port 25
+ ProxyCommand host %h port %p
+
+Host specific
+ Port 37
+ ProxyCommand host %h port %p lol
+
+Host portonly
+ Port 155
+"""))
+ 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
+ )