sshkit 1.21.5 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docker/Dockerfile +6 -0
- data/.docker/ubuntu_setup.sh +22 -0
- data/.github/release-drafter.yml +10 -2
- data/.github/workflows/ci.yml +19 -34
- data/.github/workflows/push.yml +1 -1
- data/.gitignore +0 -1
- data/.rubocop_todo.yml +0 -7
- data/CONTRIBUTING.md +2 -2
- data/EXAMPLES.md +25 -13
- data/README.md +2 -1
- data/RELEASING.md +1 -1
- data/Rakefile +0 -4
- data/docker-compose.yml +8 -0
- data/lib/sshkit/backends/connection_pool/cache.rb +2 -2
- data/lib/sshkit/backends/netssh/known_hosts.rb +8 -8
- data/lib/sshkit/backends/netssh/scp_transfer.rb +26 -0
- data/lib/sshkit/backends/netssh/sftp_transfer.rb +46 -0
- data/lib/sshkit/backends/netssh.rb +36 -7
- data/lib/sshkit/host.rb +25 -0
- data/lib/sshkit/version.rb +1 -1
- data/sshkit.gemspec +2 -0
- data/test/functional/backends/netssh_transfer_tests.rb +83 -0
- data/test/functional/backends/test_netssh.rb +1 -67
- data/test/functional/backends/test_netssh_scp.rb +23 -0
- data/test/functional/backends/test_netssh_sftp.rb +23 -0
- data/test/helper.rb +4 -42
- data/test/support/docker_wrapper.rb +71 -0
- data/test/unit/backends/test_abstract.rb +1 -1
- data/test/unit/backends/test_netssh.rb +48 -0
- data/test/unit/test_command_map.rb +8 -8
- data/test/unit/test_deprecation_logger.rb +1 -1
- data/test/unit/test_host.rb +39 -0
- metadata +44 -10
- data/Vagrantfile +0 -24
- data/test/boxes.json +0 -17
- data/test/functional/test_ssh_server_comes_up_for_functional_tests.rb +0 -24
- data/test/support/vagrant_wrapper.rb +0 -64
data/Vagrantfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
VAGRANTFILE_API_VERSION = "2"
|
2
|
-
|
3
|
-
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
4
|
-
config.vm.box = 'bento/ubuntu-22.10'
|
5
|
-
|
6
|
-
config.vm.boot_timeout = 600 # seconds
|
7
|
-
config.ssh.insert_key = false
|
8
|
-
config.vm.provision "shell", inline: <<-SHELL
|
9
|
-
echo 'ClientAliveInterval 3' >> /etc/ssh/sshd_config
|
10
|
-
echo 'ClientAliveCountMax 3' >> /etc/ssh/sshd_config
|
11
|
-
echo 'MaxAuthTries 6' >> /etc/ssh/sshd_config
|
12
|
-
service ssh restart
|
13
|
-
SHELL
|
14
|
-
|
15
|
-
json_config_path = File.join("test", "boxes.json")
|
16
|
-
list = File.open(json_config_path).read
|
17
|
-
list = JSON.parse(list)
|
18
|
-
|
19
|
-
list.each do |vm|
|
20
|
-
config.vm.define vm["name"] do |web|
|
21
|
-
web.vm.network "forwarded_port", guest: 22, host: vm["port"]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/test/boxes.json
DELETED
@@ -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,64 +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
|
-
ssh_options: host_verify_options
|
51
|
-
}
|
52
|
-
|
53
|
-
SSHKit::Host.new(host_options)
|
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
|
63
|
-
end
|
64
|
-
end
|