Skip to content

Commit 758dffb

Browse files
authored
Merge pull request #463 from capistrano/fix-functional-tests
Fix functional tests
2 parents d01f803 + cb6b6ef commit 758dffb

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ rvm:
66
- 2.2
77
- 2.1
88
- 2.0
9+
branches:
10+
only:
11+
- master
912
matrix:
1013
include:
1114
# Run Danger only once, on 2.5

test/functional/backends/test_netssh.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_simple_netssh
3838
"Command: /usr/bin/env ls -l\n",
3939
"Command: if test ! -d /tmp; then echo \"Directory does not exist '/tmp'\" 1>&2; false; fi\n",
4040
"Command: if ! sudo -u root whoami > /dev/null; then echo \"You cannot switch to user 'root' using sudo, please check the sudoers file\" 1>&2; false; fi\n",
41-
"Command: cd /tmp && ( export RAILS_ENV=\"production\" ; sudo -u root RAILS_ENV=\"production\" -- sh -c '/usr/bin/env touch restart.txt' )\n"
41+
"Command: cd /tmp && ( export RAILS_ENV=\"production\" ; sudo -u root RAILS_ENV=\"production\" -- sh -c /usr/bin/env\\ touch\\ restart.txt )\n"
4242
], command_lines
4343
end
4444

@@ -82,7 +82,7 @@ def test_group_netssh
8282
command_lines = @output.lines.select { |line| line.start_with?('Command:') }
8383
assert_equal [
8484
"Command: if ! sudo -u root whoami > /dev/null; then echo \"You cannot switch to user 'root' using sudo, please check the sudoers file\" 1>&2; false; fi\n",
85-
"Command: sudo -u root -- sh -c 'sg admin -c \"/usr/bin/env touch restart.txt\"'\n"
85+
"Command: sudo -u root -- sh -c sg\\ admin\\ -c\\ /usr/bin/env\\\\\\ touch\\\\\\ restart.txt\n"
8686
], command_lines
8787
end
8888

@@ -96,21 +96,18 @@ def test_capture
9696
end
9797

9898
def test_ssh_option_merge
99-
verify_host_opt = if Net::SSH::Version::MAJOR >= 5
100-
{ verify_host_key: :always }
101-
else
102-
{ paranoid: true }
103-
end
104-
a_host.ssh_options = verify_host_opt
99+
keepalive_opt = { keepalive: true }
100+
test_host = a_host.dup
101+
test_host.ssh_options = keepalive_opt
105102
host_ssh_options = {}
106103
SSHKit::Backend::Netssh.config.ssh_options = { forward_agent: false }
107-
Netssh.new(a_host) do |host|
104+
Netssh.new(test_host) do |host|
108105
capture(:uname)
109106
host_ssh_options = host.ssh_options
110107
end.run
111-
assert_equal [:forward_agent, *verify_host_opt.keys, :known_hosts, :logger, :password_prompt].sort, host_ssh_options.keys.sort
108+
assert_equal [:forward_agent, *keepalive_opt.keys, :known_hosts, :logger, :password_prompt].sort, host_ssh_options.keys.sort
112109
assert_equal false, host_ssh_options[:forward_agent]
113-
assert_equal verify_host_opt.values.first, host_ssh_options[verify_host_opt.keys.first]
110+
assert_equal keepalive_opt.values.first, host_ssh_options[keepalive_opt.keys.first]
114111
assert_instance_of SSHKit::Backend::Netssh::KnownHosts, host_ssh_options[:known_hosts]
115112
end
116113

test/support/vagrant_wrapper.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,19 @@ def vm_host(vm)
4646
user: vm['user'] || 'vagrant',
4747
hostname: vm['hostname'] || 'localhost',
4848
port: vm['port'] || '22',
49-
password: vm['password'] || 'vagrant'
49+
password: vm['password'] || 'vagrant',
50+
ssh_options: host_verify_options
5051
}
5152

5253
SSHKit::Host.new(host_options)
5354
end
55+
56+
def host_verify_options
57+
if Net::SSH::Version::MAJOR >= 5
58+
{ verify_host_key: :never }
59+
else
60+
{ paranoid: false }
61+
end
62+
end
5463
end
5564
end

0 commit comments

Comments
 (0)