sshkit 1.18.1 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/release-drafter.yml +17 -0
- data/.github/workflows/push.yml +12 -0
- data/.rubocop.yml +63 -0
- data/.rubocop_todo.yml +637 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +1 -774
- data/Dangerfile +1 -1
- data/Gemfile +0 -7
- data/README.md +31 -14
- data/RELEASING.md +3 -4
- data/Rakefile +3 -6
- data/examples/simple_connection.rb +9 -0
- data/lib/sshkit/backends/abstract.rb +9 -6
- data/lib/sshkit/backends/connection_pool.rb +7 -3
- data/lib/sshkit/backends/netssh.rb +2 -1
- data/lib/sshkit/command.rb +18 -13
- data/lib/sshkit/host.rb +6 -4
- data/lib/sshkit/version.rb +1 -1
- data/sshkit.gemspec +3 -0
- data/test/functional/backends/test_local.rb +18 -0
- data/test/functional/backends/test_netssh.rb +8 -11
- data/test/helper.rb +1 -1
- data/test/support/vagrant_wrapper.rb +10 -1
- data/test/unit/backends/test_abstract.rb +12 -0
- data/test/unit/backends/test_netssh.rb +7 -0
- data/test/unit/formatters/test_pretty.rb +1 -1
- data/test/unit/test_command.rb +32 -7
- data/test/unit/test_host.rb +5 -0
- metadata +10 -4
data/test/helper.rb
CHANGED
@@ -46,10 +46,19 @@ class VagrantWrapper
|
|
46
46
|
user: vm['user'] || 'vagrant',
|
47
47
|
hostname: vm['hostname'] || 'localhost',
|
48
48
|
port: vm['port'] || '22',
|
49
|
-
password: vm['password'] || 'vagrant'
|
49
|
+
password: vm['password'] || 'vagrant',
|
50
|
+
ssh_options: host_verify_options
|
50
51
|
}
|
51
52
|
|
52
53
|
SSHKit::Host.new(host_options)
|
53
54
|
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
|
54
63
|
end
|
55
64
|
end
|
@@ -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
|
@@ -54,6 +54,13 @@ module SSHKit
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_transfer_summarizer_uses_verbosity
|
58
|
+
netssh = Netssh.new(Host.new('fake'))
|
59
|
+
summarizer = netssh.send(:transfer_summarizer, 'Transferring', verbosity: :ERROR)
|
60
|
+
netssh.expects(:error).with { |msg| msg.include?('Transferring afile 15.0%') }
|
61
|
+
summarizer.call(nil,'afile',15,100)
|
62
|
+
end
|
63
|
+
|
57
64
|
if Net::SSH::Version::CURRENT >= Net::SSH::Version[3, 1, 0]
|
58
65
|
def test_known_hosts_for_when_all_hosts_are_recognized
|
59
66
|
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
|
data/test/unit/test_command.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
data/test/unit/test_host.rb
CHANGED
@@ -56,6 +56,11 @@ module SSHKit
|
|
56
56
|
assert_equal '1fff:0:a88:85a3::ac1f', h.hostname
|
57
57
|
end
|
58
58
|
|
59
|
+
def test_does_not_confuse_ipv6_hosts_without_port_specification
|
60
|
+
h = Host.new '[2001:db8:85a3:8d3:1319:8a2e:370:7348]'
|
61
|
+
assert_equal '2001:db8:85a3:8d3:1319:8a2e:370:7348', h.hostname
|
62
|
+
end
|
63
|
+
|
59
64
|
def testing_host_casting_to_a_string
|
60
65
|
assert_equal "example.com", Host.new('user@example.com:1234').to_s
|
61
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Hambley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -180,7 +180,11 @@ executables: []
|
|
180
180
|
extensions: []
|
181
181
|
extra_rdoc_files: []
|
182
182
|
files:
|
183
|
+
- ".github/release-drafter.yml"
|
184
|
+
- ".github/workflows/push.yml"
|
183
185
|
- ".gitignore"
|
186
|
+
- ".rubocop.yml"
|
187
|
+
- ".rubocop_todo.yml"
|
184
188
|
- ".travis.yml"
|
185
189
|
- ".yardopts"
|
186
190
|
- BREAKING_API_WISHLIST.md
|
@@ -197,6 +201,7 @@ files:
|
|
197
201
|
- Vagrantfile
|
198
202
|
- examples/images/example_output.png
|
199
203
|
- examples/images/logo.png
|
204
|
+
- examples/simple_connection.rb
|
200
205
|
- lib/core_ext/array.rb
|
201
206
|
- lib/core_ext/hash.rb
|
202
207
|
- lib/sshkit.rb
|
@@ -268,7 +273,8 @@ files:
|
|
268
273
|
homepage: http://github.com/capistrano/sshkit
|
269
274
|
licenses:
|
270
275
|
- MIT
|
271
|
-
metadata:
|
276
|
+
metadata:
|
277
|
+
changelog_uri: https://github.com/capistrano/sshkit/releases
|
272
278
|
post_install_message:
|
273
279
|
rdoc_options: []
|
274
280
|
require_paths:
|
@@ -284,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
290
|
- !ruby/object:Gem::Version
|
285
291
|
version: '0'
|
286
292
|
requirements: []
|
287
|
-
rubygems_version: 3.
|
293
|
+
rubygems_version: 3.1.2
|
288
294
|
signing_key:
|
289
295
|
specification_version: 4
|
290
296
|
summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
|