diff options
author | Miklos Fazekas <mfazekas@szemafor.com> | 2018-03-23 10:28:53 +0100 |
---|---|---|
committer | Miklos Fazekas <mfazekas@szemafor.com> | 2018-03-23 11:04:33 +0100 |
commit | 51789e98c960aba4f6b6cadb4d03c435600ec10b (patch) | |
tree | f622a6b9b8533477b050d9e08878dcdf5964d773 /test/test_config.rb | |
parent | a90555cbe48e6020999bc4705a53deaf9480fa23 (diff) | |
download | net-ssh-51789e98c960aba4f6b6cadb4d03c435600ec10b.tar.gz |
Add support for Host in Match config blocks
Diffstat (limited to 'test/test_config.rb')
-rw-r--r-- | test/test_config.rb | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/test/test_config.rb b/test/test_config.rb index ca27cdc..3a10cd2 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -310,7 +310,55 @@ class TestConfig < NetSSHTest net_ssh = Net::SSH::Config.translate(config) assert_equal true, net_ssh[:forward_agent] assert_equal true, net_ssh[:compression] - assert_equal 22, net_ssh[:port] + assert_equal 2345, net_ssh[:port] + end + + def test_load_with_match_block_with_host + data = %q{ + Match Host foo + Port 1234 + Compression no + } + with_config_from_data data do |f| + config = Net::SSH::Config.load(f, "bar") + assert_nil config['port'] + config = Net::SSH::Config.load(f, "foo") + assert_equal 1234, config['port'] + end + end + + def test_load_with_match_block_with_hosts + data = %q{ + Match Host foo,bar + Port 1234 + Compression no + } + with_config_from_data data do |f| + config = Net::SSH::Config.load(f, "bar2") + assert_nil config['port'] + config = Net::SSH::Config.load(f, "bar") + assert_equal 1234, config['port'] + config = Net::SSH::Config.load(f, "foo") + assert_equal 1234, config['port'] + end + end + + def test_load_with_match_block_with_hosts_wildcard + data = %q{ + Match Host foo,*.baz.com + Port 1234 + Compression no + } + with_config_from_data data do |f| + config = Net::SSH::Config.load(f, "bar2") + assert_nil config['port'] + config = Net::SSH::Config.load(f, "bbaz.com") + assert_nil config['port'] + config = Net::SSH::Config.load(f, "bar.baz.com") + assert_equal 1234, config['port'] + config = Net::SSH::Config.load(f, "foo") + assert_equal 1234, config['port'] + end end private |