sshkit 1.18.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/Dockerfile +6 -0
  3. data/.docker/ubuntu_setup.sh +22 -0
  4. data/.github/dependabot.yml +16 -0
  5. data/.github/release-drafter.yml +25 -0
  6. data/.github/workflows/ci.yml +98 -0
  7. data/.github/workflows/push.yml +12 -0
  8. data/.gitignore +0 -1
  9. data/.rubocop.yml +63 -0
  10. data/.rubocop_todo.yml +630 -0
  11. data/CHANGELOG.md +1 -769
  12. data/CONTRIBUTING.md +2 -2
  13. data/Dangerfile +1 -1
  14. data/EXAMPLES.md +35 -13
  15. data/Gemfile +0 -12
  16. data/README.md +35 -17
  17. data/RELEASING.md +4 -5
  18. data/Rakefile +3 -10
  19. data/docker-compose.yml +8 -0
  20. data/examples/simple_connection.rb +9 -0
  21. data/lib/sshkit/backends/abstract.rb +9 -6
  22. data/lib/sshkit/backends/connection_pool/cache.rb +12 -5
  23. data/lib/sshkit/backends/connection_pool.rb +8 -4
  24. data/lib/sshkit/backends/netssh/known_hosts.rb +8 -8
  25. data/lib/sshkit/backends/netssh/scp_transfer.rb +26 -0
  26. data/lib/sshkit/backends/netssh/sftp_transfer.rb +46 -0
  27. data/lib/sshkit/backends/netssh.rb +38 -8
  28. data/lib/sshkit/command.rb +18 -13
  29. data/lib/sshkit/deprecation_logger.rb +2 -0
  30. data/lib/sshkit/host.rb +31 -4
  31. data/lib/sshkit/version.rb +1 -1
  32. data/sshkit.gemspec +6 -1
  33. data/test/functional/backends/netssh_transfer_tests.rb +83 -0
  34. data/test/functional/backends/test_local.rb +18 -0
  35. data/test/functional/backends/test_netssh.rb +24 -79
  36. data/test/functional/backends/test_netssh_scp.rb +23 -0
  37. data/test/functional/backends/test_netssh_sftp.rb +23 -0
  38. data/test/helper.rb +5 -43
  39. data/test/support/docker_wrapper.rb +71 -0
  40. data/test/unit/backends/test_abstract.rb +13 -1
  41. data/test/unit/backends/test_netssh.rb +55 -0
  42. data/test/unit/formatters/test_pretty.rb +1 -1
  43. data/test/unit/test_command.rb +32 -7
  44. data/test/unit/test_command_map.rb +8 -8
  45. data/test/unit/test_deprecation_logger.rb +1 -1
  46. data/test/unit/test_host.rb +44 -0
  47. metadata +58 -18
  48. data/.travis.yml +0 -14
  49. data/Vagrantfile +0 -15
  50. data/test/boxes.json +0 -17
  51. data/test/functional/test_ssh_server_comes_up_for_functional_tests.rb +0 -24
  52. data/test/support/vagrant_wrapper.rb +0 -55
@@ -99,6 +99,18 @@ module SSHKit
99
99
  assert_equal '/usr/bin/env cat file', backend.executed_command.to_command
100
100
  end
101
101
 
102
+ def test_within_home
103
+ backend = ExampleBackend.new do
104
+ within '~/foo' do
105
+ execute :cat, 'file', :strip => false
106
+ end
107
+ end
108
+
109
+ backend.run
110
+
111
+ assert_equal 'cd ~/foo && /usr/bin/env cat file', backend.executed_command.to_command
112
+ end
113
+
102
114
  def test_background_logs_deprecation_warnings
103
115
  deprecation_out = ''
104
116
  SSHKit.config.deprecation_output = deprecation_out
@@ -112,7 +124,7 @@ module SSHKit
112
124
  assert_equal 2, lines.length
113
125
 
114
126
  assert_equal("[Deprecated] The background method is deprecated. Blame badly behaved pseudo-daemons!\n", lines[0])
115
- assert_match(/ \(Called from.*test_abstract.rb:\d+:in `block in test_background_logs_deprecation_warnings'\)\n/, lines[1])
127
+ assert_match(/ \(Called from.*test_abstract.rb:\d+:in .block in .*test_background_logs_deprecation_warnings.\)\n/, lines[1])
116
128
  end
117
129
 
118
130
  def test_calling_abstract_with_undefined_execute_command_raises_exception
@@ -5,6 +5,12 @@ module SSHKit
5
5
  module Backend
6
6
  class TestNetssh < UnitTest
7
7
 
8
+ def teardown
9
+ super
10
+ # Reset config to defaults after each test
11
+ backend.instance_variable_set :@config, nil
12
+ end
13
+
8
14
  def backend
9
15
  @backend ||= Netssh
10
16
  end
@@ -13,6 +19,7 @@ module SSHKit
13
19
  backend.configure do |ssh|
14
20
  ssh.pty = true
15
21
  ssh.connection_timeout = 30
22
+ ssh.transfer_method = :sftp
16
23
  ssh.ssh_options = {
17
24
  keys: %w(/home/user/.ssh/id_rsa),
18
25
  forward_agent: false,
@@ -21,6 +28,7 @@ module SSHKit
21
28
  end
22
29
 
23
30
  assert_equal 30, backend.config.connection_timeout
31
+ assert_equal :sftp, backend.config.transfer_method
24
32
  assert_equal true, backend.config.pty
25
33
 
26
34
  assert_equal %w(/home/user/.ssh/id_rsa), backend.config.ssh_options[:keys]
@@ -29,6 +37,46 @@ module SSHKit
29
37
  assert_instance_of backend::KnownHosts, backend.config.ssh_options[:known_hosts]
30
38
  end
31
39
 
40
+ def test_transfer_method_prohibits_invalid_values
41
+ error = assert_raises ArgumentError do
42
+ backend.configure do |ssh|
43
+ ssh.transfer_method = :nope
44
+ end
45
+ end
46
+
47
+ assert_match ":nope is not a valid transfer method", error.message
48
+ end
49
+
50
+ def test_transfer_method_does_not_allow_nil
51
+ error = assert_raises ArgumentError do
52
+ backend.configure do |ssh|
53
+ ssh.transfer_method = nil
54
+ end
55
+ end
56
+
57
+ assert_match "nil is not a valid transfer method", error.message
58
+ end
59
+
60
+ def test_transfer_method_defaults_to_scp
61
+ assert_equal :scp, backend.config.transfer_method
62
+ end
63
+
64
+ def test_host_can_override_transfer_method
65
+ backend.configure do |ssh|
66
+ ssh.transfer_method = :scp
67
+ end
68
+
69
+ host = Host.new("fake")
70
+ host.transfer_method = :sftp
71
+
72
+ netssh = backend.new(host)
73
+ netssh.stubs(:with_ssh).yields(nil)
74
+
75
+ netssh.send(:with_transfer, nil) do |transfer|
76
+ assert_instance_of Netssh::SftpTransfer, transfer
77
+ end
78
+ end
79
+
32
80
  def test_netssh_ext
33
81
  assert_includes Net::SSH::Config.default_files, "#{Dir.pwd}/.ssh/config"
34
82
  end
@@ -54,6 +102,13 @@ module SSHKit
54
102
  end
55
103
  end
56
104
 
105
+ def test_transfer_summarizer_uses_verbosity
106
+ netssh = Netssh.new(Host.new('fake'))
107
+ summarizer = netssh.send(:transfer_summarizer, 'Transferring', verbosity: :ERROR)
108
+ netssh.expects(:error).with { |msg| msg.include?('Transferring afile 15.0%') }
109
+ summarizer.call(nil,'afile',15,100)
110
+ end
111
+
57
112
  if Net::SSH::Version::CURRENT >= Net::SSH::Version[3, 1, 0]
58
113
  def test_known_hosts_for_when_all_hosts_are_recognized
59
114
  perform_known_hosts_test('github', 'github.com')
@@ -115,7 +115,7 @@ module SSHKit
115
115
 
116
116
  def test_can_write_to_output_which_just_supports_append
117
117
  # Note output doesn't have to be an IO, it only needs to support <<
118
- output = stub(:<<)
118
+ output = stub(:<< => nil)
119
119
  pretty = SSHKit::Formatter::Pretty.new(output)
120
120
  simulate_command_lifecycle(pretty)
121
121
  end
@@ -51,13 +51,13 @@ module SSHKit
51
51
  def test_double_quotes_are_escaped_in_env
52
52
  SSHKit.config = nil
53
53
  c = Command.new(:rails, 'server', env: {foo: 'asdf"hjkl'})
54
- assert_equal %{( export FOO="asdf\\\"hjkl" ; /usr/bin/env rails server )}, c.to_command
54
+ assert_equal %{( export FOO="asdf\\"hjkl" ; /usr/bin/env rails server )}, c.to_command
55
55
  end
56
56
 
57
57
  def test_percentage_symbol_handled_in_env
58
58
  SSHKit.config = nil
59
59
  c = Command.new(:rails, 'server', env: {foo: 'asdf%hjkl'}, user: "anotheruser")
60
- assert_equal %{( export FOO="asdf%hjkl" ; sudo -u anotheruser FOO=\"asdf%hjkl\" -- sh -c '/usr/bin/env rails server' )}, c.to_command
60
+ assert_equal %{( export FOO="asdf%hjkl" ; sudo -u anotheruser FOO=\"asdf%hjkl\" -- sh -c /usr/bin/env\\ rails\\ server )}, c.to_command
61
61
  end
62
62
 
63
63
  def test_including_the_env_doesnt_addressively_escape
@@ -84,6 +84,16 @@ module SSHKit
84
84
  assert_equal "cd /opt/sites && /usr/bin/env ls -l", c.to_command
85
85
  end
86
86
 
87
+ def test_working_in_home_directory
88
+ c = Command.new(:ls, '-l', in: "~/sites")
89
+ assert_equal "cd ~/sites && /usr/bin/env ls -l", c.to_command
90
+ end
91
+
92
+ def test_working_in_a_given_weird_directory
93
+ c = Command.new(:ls, '-l', in: "/opt/sites and stuff")
94
+ assert_equal "cd /opt/sites\\ and\\ stuff && /usr/bin/env ls -l", c.to_command
95
+ end
96
+
87
97
  def test_working_in_a_given_directory_with_env
88
98
  c = Command.new(:ls, '-l', in: "/opt/sites", env: {a: :b})
89
99
  assert_equal %{cd /opt/sites && ( export A="b" ; /usr/bin/env ls -l )}, c.to_command
@@ -97,17 +107,27 @@ module SSHKit
97
107
 
98
108
  def test_working_as_a_given_user
99
109
  c = Command.new(:whoami, user: :anotheruser)
100
- assert_equal "sudo -u anotheruser -- sh -c '/usr/bin/env whoami'", c.to_command
110
+ assert_equal "sudo -u anotheruser -- sh -c /usr/bin/env\\ whoami", c.to_command
111
+ end
112
+
113
+ def test_working_as_a_given_weird_user
114
+ c = Command.new(:whoami, user: "mr space |")
115
+ assert_equal "sudo -u mr\\ space\\ \\| -- sh -c /usr/bin/env\\ whoami", c.to_command
101
116
  end
102
117
 
103
118
  def test_working_as_a_given_group
104
119
  c = Command.new(:whoami, group: :devvers)
105
- assert_equal 'sg devvers -c "/usr/bin/env whoami"', c.to_command
120
+ assert_equal 'sg devvers -c /usr/bin/env\\ whoami', c.to_command
121
+ end
122
+
123
+ def test_working_as_a_given_weird_group
124
+ c = Command.new(:whoami, group: "space | group")
125
+ assert_equal "sg space\\ \\|\\ group -c /usr/bin/env\\ whoami", c.to_command
106
126
  end
107
127
 
108
128
  def test_working_as_a_given_user_and_group
109
129
  c = Command.new(:whoami, user: :anotheruser, group: :devvers)
110
- assert_equal %Q(sudo -u anotheruser -- sh -c 'sg devvers -c "/usr/bin/env whoami"'), c.to_command
130
+ assert_equal %Q(sudo -u anotheruser -- sh -c sg\\ devvers\\ -c\\ /usr/bin/env\\\\\\ whoami), c.to_command
111
131
  end
112
132
 
113
133
  def test_umask
@@ -125,13 +145,13 @@ module SSHKit
125
145
  def test_umask_with_working_directory_and_user
126
146
  SSHKit.config.umask = '007'
127
147
  c = Command.new(:touch, 'somefile', in: '/var', user: 'alice')
128
- assert_equal "cd /var && umask 007 && sudo -u alice -- sh -c '/usr/bin/env touch somefile'", c.to_command
148
+ assert_equal "cd /var && umask 007 && sudo -u alice -- sh -c /usr/bin/env\\ touch\\ somefile", c.to_command
129
149
  end
130
150
 
131
151
  def test_umask_with_env_and_working_directory_and_user
132
152
  SSHKit.config.umask = '007'
133
153
  c = Command.new(:touch, 'somefile', user: 'bob', env: {a: 'b'}, in: '/var')
134
- assert_equal %{cd /var && umask 007 && ( export A="b" ; sudo -u bob A="b" -- sh -c '/usr/bin/env touch somefile' )}, c.to_command
154
+ assert_equal %{cd /var && umask 007 && ( export A="b" ; sudo -u bob A="b" -- sh -c /usr/bin/env\\ touch\\ somefile )}, c.to_command
135
155
  end
136
156
 
137
157
  def test_verbosity_defaults_to_logger_info
@@ -245,5 +265,10 @@ module SSHKit
245
265
  assert_equal "whoami exit status: 1\nwhoami stdout: Nothing written\nwhoami stderr: Nothing written\n", error.message
246
266
  end
247
267
 
268
+ def test_shares_same_uuid_before_and_after_redaction
269
+ command = Command.new(:whoami)
270
+ command_with_redaction = command.with_redaction
271
+ assert_equal command.uuid, command_with_redaction.uuid, "UUID should be stable before and after redaction"
272
+ end
248
273
  end
249
274
  end
@@ -27,26 +27,26 @@ module SSHKit
27
27
 
28
28
  def test_prefix
29
29
  map = CommandMap.new
30
- map.prefix[:rake].push("/home/vagrant/.rbenv/bin/rbenv exec")
30
+ map.prefix[:rake].push("/home/deployer/.rbenv/bin/rbenv exec")
31
31
  map.prefix[:rake].push("bundle exec")
32
32
 
33
- assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
33
+ assert_equal map[:rake], "/home/deployer/.rbenv/bin/rbenv exec bundle exec rake"
34
34
  end
35
35
 
36
36
  def test_prefix_procs
37
37
  map = CommandMap.new
38
- map.prefix[:rake].push("/home/vagrant/.rbenv/bin/rbenv exec")
38
+ map.prefix[:rake].push("/home/deployer/.rbenv/bin/rbenv exec")
39
39
  map.prefix[:rake].push(proc{ "bundle exec" })
40
40
 
41
- assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
41
+ assert_equal map[:rake], "/home/deployer/.rbenv/bin/rbenv exec bundle exec rake"
42
42
  end
43
43
 
44
44
  def test_prefix_unshift
45
45
  map = CommandMap.new
46
46
  map.prefix[:rake].push("bundle exec")
47
- map.prefix[:rake].unshift("/home/vagrant/.rbenv/bin/rbenv exec")
47
+ map.prefix[:rake].unshift("/home/deployer/.rbenv/bin/rbenv exec")
48
48
 
49
- assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
49
+ assert_equal map[:rake], "/home/deployer/.rbenv/bin/rbenv exec bundle exec rake"
50
50
  end
51
51
 
52
52
  def test_indifferent_setter
@@ -59,10 +59,10 @@ module SSHKit
59
59
 
60
60
  def test_indifferent_prefix
61
61
  map = CommandMap.new
62
- map.prefix[:rake].push("/home/vagrant/.rbenv/bin/rbenv exec")
62
+ map.prefix[:rake].push("/home/deployer/.rbenv/bin/rbenv exec")
63
63
  map.prefix["rake"].push("bundle exec")
64
64
 
65
- assert_equal map[:rake], "/home/vagrant/.rbenv/bin/rbenv exec bundle exec rake"
65
+ assert_equal map[:rake], "/home/deployer/.rbenv/bin/rbenv exec bundle exec rake"
66
66
  end
67
67
 
68
68
  def test_prefix_initialization_is_thread_safe
@@ -20,7 +20,7 @@ module SSHKit
20
20
 
21
21
  assert_equal(2, actual_lines.size)
22
22
  assert_equal "[Deprecated] Some message\n", actual_lines[0]
23
- assert_match %r{ \(Called from .*sshkit/test/unit/test_deprecation_logger.rb:#{line_number}:in `generate_warning'\)\n}, actual_lines[1]
23
+ assert_match %r{ \(Called from .*sshkit/test/unit/test_deprecation_logger.rb:#{line_number}:in .*generate_warning.\)\n}, actual_lines[1]
24
24
  end
25
25
 
26
26
  def test_handles_nil_output
@@ -28,6 +28,12 @@ module SSHKit
28
28
  assert_equal 'example.com', h.hostname
29
29
  end
30
30
 
31
+ def test_custom_host_with_port
32
+ h = Host.new 'db:22'
33
+ assert_equal 22, h.port
34
+ assert_equal 'db', h.hostname
35
+ end
36
+
31
37
  def test_host_with_username
32
38
  h = Host.new 'root@example.com'
33
39
  assert_equal 'root', h.username
@@ -50,12 +56,23 @@ module SSHKit
50
56
  assert_equal 'localhost', h.hostname
51
57
  end
52
58
 
59
+ def test_ipv6_without_brackets
60
+ h = Host.new '1fff:0:a88:85a3::ac1f'
61
+ assert_nil h.port
62
+ assert_equal '1fff:0:a88:85a3::ac1f', h.hostname
63
+ end
64
+
53
65
  def test_does_not_confuse_ipv6_hosts_with_port_specification
54
66
  h = Host.new '[1fff:0:a88:85a3::ac1f]:8001'
55
67
  assert_equal 8001, h.port
56
68
  assert_equal '1fff:0:a88:85a3::ac1f', h.hostname
57
69
  end
58
70
 
71
+ def test_does_not_confuse_ipv6_hosts_without_port_specification
72
+ h = Host.new '[2001:db8:85a3:8d3:1319:8a2e:370:7348]'
73
+ assert_equal '2001:db8:85a3:8d3:1319:8a2e:370:7348', h.hostname
74
+ end
75
+
59
76
  def testing_host_casting_to_a_string
60
77
  assert_equal "example.com", Host.new('user@example.com:1234').to_s
61
78
  end
@@ -137,6 +154,33 @@ module SSHKit
137
154
  end
138
155
  end
139
156
 
157
+ def test_transfer_method_defaults_to_nil
158
+ host = Host.new 'example.com'
159
+ assert_nil host.transfer_method
160
+ end
161
+
162
+ def test_transfer_method_can_be_configured
163
+ host = Host.new 'example.com'
164
+
165
+ host.transfer_method = :scp
166
+ assert_equal :scp, host.transfer_method
167
+
168
+ host.transfer_method = :sftp
169
+ assert_equal :sftp, host.transfer_method
170
+
171
+ host.transfer_method = nil
172
+ assert_nil host.transfer_method
173
+ end
174
+
175
+ def test_transfer_method_prohibits_invalid_values
176
+ host = Host.new 'example.com'
177
+
178
+ error = assert_raises ArgumentError do
179
+ host.transfer_method = :nope
180
+ end
181
+
182
+ assert_match ":nope is not a valid transfer method", error.message
183
+ end
140
184
  end
141
185
 
142
186
  end
metadata CHANGED
@@ -1,16 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
8
8
  - Tom Clements
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-21 00:00:00.000000000 Z
12
+ date: 2024-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: base64
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: net-ssh
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,6 +53,20 @@ dependencies:
39
53
  - - ">="
40
54
  - !ruby/object:Gem::Version
41
55
  version: 1.1.2
56
+ - !ruby/object:Gem::Dependency
57
+ name: net-sftp
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.1.2
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.1.2
42
70
  - !ruby/object:Gem::Dependency
43
71
  name: danger
44
72
  requirement: !ruby/object:Gem::Requirement
@@ -87,14 +115,14 @@ dependencies:
87
115
  requirements:
88
116
  - - "~>"
89
117
  - !ruby/object:Gem::Version
90
- version: 2.1.0
118
+ version: 2.2.2
91
119
  type: :development
92
120
  prerelease: false
93
121
  version_requirements: !ruby/object:Gem::Requirement
94
122
  requirements:
95
123
  - - "~>"
96
124
  - !ruby/object:Gem::Version
97
- version: 2.1.0
125
+ version: 2.2.2
98
126
  - !ruby/object:Gem::Dependency
99
127
  name: rake
100
128
  requirement: !ruby/object:Gem::Requirement
@@ -180,8 +208,15 @@ executables: []
180
208
  extensions: []
181
209
  extra_rdoc_files: []
182
210
  files:
211
+ - ".docker/Dockerfile"
212
+ - ".docker/ubuntu_setup.sh"
213
+ - ".github/dependabot.yml"
214
+ - ".github/release-drafter.yml"
215
+ - ".github/workflows/ci.yml"
216
+ - ".github/workflows/push.yml"
183
217
  - ".gitignore"
184
- - ".travis.yml"
218
+ - ".rubocop.yml"
219
+ - ".rubocop_todo.yml"
185
220
  - ".yardopts"
186
221
  - BREAKING_API_WISHLIST.md
187
222
  - CHANGELOG.md
@@ -194,9 +229,10 @@ files:
194
229
  - README.md
195
230
  - RELEASING.md
196
231
  - Rakefile
197
- - Vagrantfile
232
+ - docker-compose.yml
198
233
  - examples/images/example_output.png
199
234
  - examples/images/logo.png
235
+ - examples/simple_connection.rb
200
236
  - lib/core_ext/array.rb
201
237
  - lib/core_ext/hash.rb
202
238
  - lib/sshkit.rb
@@ -208,6 +244,8 @@ files:
208
244
  - lib/sshkit/backends/local.rb
209
245
  - lib/sshkit/backends/netssh.rb
210
246
  - lib/sshkit/backends/netssh/known_hosts.rb
247
+ - lib/sshkit/backends/netssh/scp_transfer.rb
248
+ - lib/sshkit/backends/netssh/sftp_transfer.rb
211
249
  - lib/sshkit/backends/printer.rb
212
250
  - lib/sshkit/backends/skipper.rb
213
251
  - lib/sshkit/color.rb
@@ -234,15 +272,16 @@ files:
234
272
  - lib/sshkit/runners/sequential.rb
235
273
  - lib/sshkit/version.rb
236
274
  - sshkit.gemspec
237
- - test/boxes.json
275
+ - test/functional/backends/netssh_transfer_tests.rb
238
276
  - test/functional/backends/test_local.rb
239
277
  - test/functional/backends/test_netssh.rb
240
- - test/functional/test_ssh_server_comes_up_for_functional_tests.rb
278
+ - test/functional/backends/test_netssh_scp.rb
279
+ - test/functional/backends/test_netssh_sftp.rb
241
280
  - test/helper.rb
242
281
  - test/known_hosts/github
243
282
  - test/known_hosts/github_hash
244
283
  - test/known_hosts/github_ip
245
- - test/support/vagrant_wrapper.rb
284
+ - test/support/docker_wrapper.rb
246
285
  - test/unit/backends/test_abstract.rb
247
286
  - test/unit/backends/test_connection_pool.rb
248
287
  - test/unit/backends/test_local.rb
@@ -268,8 +307,9 @@ files:
268
307
  homepage: http://github.com/capistrano/sshkit
269
308
  licenses:
270
309
  - MIT
271
- metadata: {}
272
- post_install_message:
310
+ metadata:
311
+ changelog_uri: https://github.com/capistrano/sshkit/releases
312
+ post_install_message:
273
313
  rdoc_options: []
274
314
  require_paths:
275
315
  - lib
@@ -284,21 +324,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
324
  - !ruby/object:Gem::Version
285
325
  version: '0'
286
326
  requirements: []
287
- rubyforge_project:
288
- rubygems_version: 2.7.7
289
- signing_key:
327
+ rubygems_version: 3.5.13
328
+ signing_key:
290
329
  specification_version: 4
291
330
  summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
292
331
  test_files:
293
- - test/boxes.json
332
+ - test/functional/backends/netssh_transfer_tests.rb
294
333
  - test/functional/backends/test_local.rb
295
334
  - test/functional/backends/test_netssh.rb
296
- - test/functional/test_ssh_server_comes_up_for_functional_tests.rb
335
+ - test/functional/backends/test_netssh_scp.rb
336
+ - test/functional/backends/test_netssh_sftp.rb
297
337
  - test/helper.rb
298
338
  - test/known_hosts/github
299
339
  - test/known_hosts/github_hash
300
340
  - test/known_hosts/github_ip
301
- - test/support/vagrant_wrapper.rb
341
+ - test/support/docker_wrapper.rb
302
342
  - test/unit/backends/test_abstract.rb
303
343
  - test/unit/backends/test_connection_pool.rb
304
344
  - test/unit/backends/test_local.rb
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.4
5
- - 2.3
6
- - 2.2
7
- - 2.1
8
- - 2.0
9
- matrix:
10
- include:
11
- # Run Danger only once, on 2.5
12
- - rvm: 2.5
13
- script: bundle exec danger
14
- script: bundle exec rake test:units lint
data/Vagrantfile DELETED
@@ -1,15 +0,0 @@
1
- VAGRANTFILE_API_VERSION = "2"
2
-
3
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
4
- config.vm.box = 'hashicorp/precise64'
5
-
6
- json_config_path = File.join("test", "boxes.json")
7
- list = File.open(json_config_path).read
8
- list = JSON.parse(list)
9
-
10
- list.each do |vm|
11
- config.vm.define vm["name"] do |web|
12
- web.vm.network "forwarded_port", guest: 22, host: vm["port"]
13
- end
14
- end
15
- end
data/test/boxes.json DELETED
@@ -1,17 +0,0 @@
1
- [
2
- {
3
- "name": "one",
4
- "port": 3001,
5
- "user": "vagrant",
6
- "password": "vagrant",
7
- "hostname": "localhost"
8
- },
9
- {
10
- "name": "two",
11
- "port": 3002
12
- },
13
- {
14
- "name": "three",
15
- "port": 3003
16
- }
17
- ]
@@ -1,24 +0,0 @@
1
- require 'helper'
2
-
3
- module SSHKit
4
-
5
- class TestHost < FunctionalTest
6
-
7
- def host
8
- @_host ||= Host.new('')
9
- end
10
-
11
- def test_that_it_works
12
- assert true
13
- end
14
-
15
- def test_creating_a_user_gives_us_back_his_private_key_as_a_string
16
- skip 'It is not safe to create an user for non vagrant envs' unless VagrantWrapper.running?
17
- keys = create_user_with_key(:peter)
18
- assert_equal [:one, :two, :three], keys.keys
19
- assert keys.values.all?
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,55 +0,0 @@
1
- class VagrantWrapper
2
- class << self
3
- def hosts
4
- @vm_hosts ||= begin
5
- result = {}
6
-
7
- boxes = boxes_list
8
-
9
- unless running?
10
- boxes.map! do |box|
11
- box['user'] = ENV['USER']
12
- box['port'] = '22'
13
- box
14
- end
15
- end
16
-
17
- boxes.each do |vm|
18
- result[vm['name']] = vm_host(vm)
19
- end
20
-
21
- result
22
- end
23
- end
24
-
25
- def running?
26
- @running ||= begin
27
- status = `#{vagrant_binary} status`
28
- status.include?('running')
29
- end
30
- end
31
-
32
- def boxes_list
33
- json_config_path = File.join('test', 'boxes.json')
34
- boxes = File.open(json_config_path).read
35
- JSON.parse(boxes)
36
- end
37
-
38
- def vagrant_binary
39
- 'vagrant'
40
- end
41
-
42
- private
43
-
44
- def vm_host(vm)
45
- host_options = {
46
- user: vm['user'] || 'vagrant',
47
- hostname: vm['hostname'] || 'localhost',
48
- port: vm['port'] || '22',
49
- password: vm['password'] || 'vagrant'
50
- }
51
-
52
- SSHKit::Host.new(host_options)
53
- end
54
- end
55
- end