sshkit 1.21.5 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
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,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,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