Implement (& test for) ProxyCommand interpolation.
Forgot this earlier.
This commit is contained in:
parent
0981c25cd8
commit
191a5fc08c
|
@ -174,7 +174,12 @@ class SSHConfig (object):
|
||||||
('%l', fqdn),
|
('%l', fqdn),
|
||||||
('%u', user),
|
('%u', user),
|
||||||
('%r', remoteuser)
|
('%r', remoteuser)
|
||||||
]
|
],
|
||||||
|
'proxycommand': [
|
||||||
|
('%h', config['hostname']),
|
||||||
|
('%p', port),
|
||||||
|
('%r', remoteuser),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
for k in config:
|
for k in config:
|
||||||
if k in replacements:
|
if k in replacements:
|
||||||
|
|
|
@ -196,7 +196,7 @@ Host *
|
||||||
self.assertRaises(AssertionError,
|
self.assertRaises(AssertionError,
|
||||||
lambda: paramiko.util.retry_on_signal(raises_other_exception))
|
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.
|
ProxyCommand should not split on equals signs within the value.
|
||||||
"""
|
"""
|
||||||
|
@ -214,3 +214,29 @@ Host equals-delimited
|
||||||
host_config(host, config)['proxycommand'],
|
host_config(host, config)['proxycommand'],
|
||||||
'foo bar=biz baz'
|
'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
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue