tugboat 2.2.2 → 2.2.3
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/.rubocop.yml +520 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +0 -6
- data/README.md +34 -2
- data/Rakefile +6 -1
- data/bin/tugboat +2 -2
- data/features/cassettes/config/Array_of_SSH_Keys_in_Config.yml +1 -1
- data/features/cassettes/config/Single_SSH_key_as_number_in_config.yml +1 -1
- data/features/step_definitions/steps.rb +1 -1
- data/features/support/env.rb +7 -3
- data/lib/tugboat.rb +2 -2
- data/lib/tugboat/cli.rb +394 -444
- data/lib/tugboat/config.rb +43 -61
- data/lib/tugboat/middleware.rb +33 -33
- data/lib/tugboat/middleware/add_key.rb +12 -13
- data/lib/tugboat/middleware/ask_for_credentials.rb +12 -13
- data/lib/tugboat/middleware/base.rb +25 -20
- data/lib/tugboat/middleware/check_configuration.rb +3 -6
- data/lib/tugboat/middleware/check_credentials.rb +0 -1
- data/lib/tugboat/middleware/check_droplet_active.rb +2 -4
- data/lib/tugboat/middleware/check_droplet_inactive.rb +2 -4
- data/lib/tugboat/middleware/config.rb +3 -5
- data/lib/tugboat/middleware/confirm_action.rb +4 -6
- data/lib/tugboat/middleware/create_droplet.rb +27 -44
- data/lib/tugboat/middleware/custom_logger.rb +52 -54
- data/lib/tugboat/middleware/destroy_droplet.rb +5 -6
- data/lib/tugboat/middleware/destroy_image.rb +5 -6
- data/lib/tugboat/middleware/find_droplet.rb +43 -47
- data/lib/tugboat/middleware/find_image.rb +23 -29
- data/lib/tugboat/middleware/halt_droplet.rb +9 -10
- data/lib/tugboat/middleware/info_droplet.rb +30 -33
- data/lib/tugboat/middleware/info_image.rb +1 -1
- data/lib/tugboat/middleware/inject_client.rb +8 -10
- data/lib/tugboat/middleware/inject_configuration.rb +1 -2
- data/lib/tugboat/middleware/list_droplets.rb +9 -10
- data/lib/tugboat/middleware/list_images.rb +9 -9
- data/lib/tugboat/middleware/list_regions.rb +1 -1
- data/lib/tugboat/middleware/list_sizes.rb +1 -1
- data/lib/tugboat/middleware/list_ssh_keys.rb +1 -3
- data/lib/tugboat/middleware/password_reset.rb +6 -7
- data/lib/tugboat/middleware/rebuild_droplet.rb +7 -7
- data/lib/tugboat/middleware/resize_droplet.rb +6 -7
- data/lib/tugboat/middleware/restart_droplet.rb +4 -11
- data/lib/tugboat/middleware/snapshot_droplet.rb +7 -8
- data/lib/tugboat/middleware/ssh_droplet.rb +30 -31
- data/lib/tugboat/middleware/start_droplet.rb +5 -5
- data/lib/tugboat/middleware/wait_for_state.rb +2 -3
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +25 -28
- data/spec/cli/authorize_cli_spec.rb +57 -60
- data/spec/cli/config_cli_spec.rb +8 -11
- data/spec/cli/create_cli_spec.rb +40 -46
- data/spec/cli/debug_cli_spec.rb +29 -29
- data/spec/cli/destroy_cli_spec.rb +58 -60
- data/spec/cli/destroy_image_cli_spec.rb +42 -45
- data/spec/cli/droplets_cli_spec.rb +62 -64
- data/spec/cli/env_variable_spec.rb +14 -15
- data/spec/cli/halt_cli_spec.rb +65 -69
- data/spec/cli/help_cli_spec.rb +8 -8
- data/spec/cli/images_cli_spec.rb +28 -30
- data/spec/cli/info_cli_spec.rb +144 -147
- data/spec/cli/info_image_cli_spec.rb +57 -60
- data/spec/cli/keys_cli_spec.rb +8 -10
- data/spec/cli/password_reset_cli_spec.rb +56 -56
- data/spec/cli/rebuild_cli_spec.rb +194 -198
- data/spec/cli/regions_cli_spec.rb +8 -8
- data/spec/cli/resize_cli_spec.rb +54 -56
- data/spec/cli/restart_cli_spec.rb +53 -57
- data/spec/cli/sizes_cli_spec.rb +7 -8
- data/spec/cli/snapshot_cli_spec.rb +50 -53
- data/spec/cli/ssh_cli_spec.rb +41 -42
- data/spec/cli/start_cli_spec.rb +48 -52
- data/spec/cli/verify_cli_spec.rb +22 -25
- data/spec/cli/version_cli_spec.rb +6 -8
- data/spec/cli/wait_cli_spec.rb +50 -52
- data/spec/config_spec.rb +56 -57
- data/spec/middleware/base_spec.rb +5 -6
- data/spec/middleware/check_configuration_spec.rb +5 -7
- data/spec/middleware/check_credentials_spec.rb +9 -10
- data/spec/middleware/check_droplet_active_spec.rb +5 -7
- data/spec/middleware/check_droplet_inactive_spec.rb +5 -7
- data/spec/middleware/find_droplet_spec.rb +4 -5
- data/spec/middleware/find_image_spec.rb +4 -5
- data/spec/middleware/inject_client_spec.rb +9 -12
- data/spec/middleware/inject_configuration_spec.rb +4 -7
- data/spec/middleware/ssh_droplet_spec.rb +70 -73
- data/spec/shared/environment.rb +18 -20
- data/spec/spec_helper.rb +4 -4
- data/tugboat.gemspec +10 -6
- metadata +88 -17
data/spec/config_spec.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Configuration do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
let(:tmp_path)
|
6
|
+
let(:tmp_path) { project_path + '/tmp/tugboat' }
|
7
7
|
|
8
|
-
after
|
8
|
+
after do
|
9
9
|
# Clean up the temp file.
|
10
|
-
File.delete(project_path +
|
10
|
+
File.delete(project_path + '/tmp/tugboat') if File.exist?(project_path + '/tmp/tugboat')
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
expect(
|
13
|
+
it 'is a singleton' do
|
14
|
+
expect(described_class).to be_a Class
|
15
15
|
expect do
|
16
|
-
|
17
|
-
end.to raise_error(NoMethodError,
|
16
|
+
described_class.new
|
17
|
+
end.to raise_error(NoMethodError, %r{private method `new' called})
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
config =
|
20
|
+
it 'has a data attribute' do
|
21
|
+
config = described_class.instance
|
22
22
|
expect(config.data).to be
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe 'the file' do
|
26
26
|
let(:access_token) { 'foo' }
|
27
27
|
let(:ssh_user) { 'root' }
|
28
28
|
let(:ssh_key_path) { '~/.ssh/id_rsa2' }
|
@@ -35,128 +35,127 @@ describe Tugboat::Configuration do
|
|
35
35
|
let(:backups_enabled) { 'false' }
|
36
36
|
let(:ip6) { 'false' }
|
37
37
|
|
38
|
-
let(:config)
|
38
|
+
let(:config) { described_class.instance }
|
39
39
|
|
40
|
-
before
|
40
|
+
before do
|
41
41
|
# Create a temporary file
|
42
42
|
config.create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key_id, private_networking, backups_enabled, ip6)
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'can be created' do
|
46
46
|
expect(File.exist?(tmp_path)).to be_true
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it 'can be loaded' do
|
50
50
|
data = config.load_config_file
|
51
|
-
expect(data).
|
51
|
+
expect(data).not_to be_nil
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
55
|
-
let(:data)
|
54
|
+
describe 'the file format'
|
55
|
+
let(:data) { YAML.load_file(tmp_path) }
|
56
56
|
|
57
|
-
it
|
58
|
-
expect(data).to have_key(
|
57
|
+
it 'has authentication at the top level' do
|
58
|
+
expect(data).to have_key('authentication')
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
62
|
-
expect(data).to have_key(
|
61
|
+
it 'has ssh at the top level' do
|
62
|
+
expect(data).to have_key('ssh')
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
auth = data[
|
67
|
-
expect(auth).to have_key(
|
65
|
+
it 'has an access token' do
|
66
|
+
auth = data['authentication']
|
67
|
+
expect(auth).to have_key('access_token')
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
71
|
-
ssh = data[
|
72
|
-
expect(ssh).to have_key(
|
70
|
+
it 'has an ssh key path' do
|
71
|
+
ssh = data['ssh']
|
72
|
+
expect(ssh).to have_key('ssh_key_path')
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
76
|
-
ssh = data[
|
77
|
-
expect(ssh).to have_key(
|
75
|
+
it 'has an ssh user' do
|
76
|
+
ssh = data['ssh']
|
77
|
+
expect(ssh).to have_key('ssh_user')
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
ssh = data[
|
82
|
-
expect(ssh).to have_key(
|
80
|
+
it 'has an ssh port' do
|
81
|
+
ssh = data['ssh']
|
82
|
+
expect(ssh).to have_key('ssh_port')
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
86
|
-
private_networking = data[
|
87
|
-
expect(private_networking).to have_key(
|
85
|
+
it 'has private_networking set' do
|
86
|
+
private_networking = data['defaults']
|
87
|
+
expect(private_networking).to have_key('private_networking')
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
91
|
-
backups_enabled = data[
|
92
|
-
expect(backups_enabled).to have_key(
|
90
|
+
it 'has backups_enabled set' do
|
91
|
+
backups_enabled = data['defaults']
|
92
|
+
expect(backups_enabled).to have_key('backups_enabled')
|
93
93
|
end
|
94
94
|
end
|
95
|
-
describe
|
95
|
+
describe 'backwards compatible' do
|
96
96
|
let(:client_key) { 'foo' }
|
97
97
|
let(:api_key) { 'bar' }
|
98
98
|
let(:ssh_user) { 'baz' }
|
99
99
|
let(:ssh_key_path) { '~/.ssh/id_rsa2' }
|
100
100
|
let(:ssh_port) { '22' }
|
101
101
|
|
102
|
-
let(:config) {
|
102
|
+
let(:config) { described_class.instance }
|
103
103
|
let(:config_default_region) { Tugboat::Configuration::DEFAULT_REGION }
|
104
104
|
let(:config_default_image) { Tugboat::Configuration::DEFAULT_IMAGE }
|
105
105
|
let(:config_default_size) { Tugboat::Configuration::DEFAULT_SIZE }
|
106
106
|
let(:config_default_ssh_key) { Tugboat::Configuration::DEFAULT_SSH_KEY }
|
107
107
|
let(:config_default_networking) { Tugboat::Configuration::DEFAULT_PRIVATE_NETWORKING }
|
108
108
|
let(:config_default_backups) { Tugboat::Configuration::DEFAULT_BACKUPS_ENABLED }
|
109
|
-
let(:config_default_ip6)
|
110
|
-
let(:backwards_config)
|
109
|
+
let(:config_default_ip6) { Tugboat::Configuration::DEFAULT_IP6 }
|
110
|
+
let(:backwards_config) do
|
111
111
|
{
|
112
|
-
|
113
|
-
|
112
|
+
'authentication' => { 'client_key' => client_key, 'api_key' => api_key },
|
113
|
+
'ssh' => { 'ssh_user' => ssh_user, 'ssh_key_path' => ssh_key_path, 'ssh_port' => ssh_port }
|
114
114
|
}
|
115
|
-
|
115
|
+
end
|
116
116
|
|
117
|
-
before
|
117
|
+
before do
|
118
118
|
config.instance_variable_set(:@data, backwards_config)
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
121
|
+
it 'loads a backwards compatible config file' do
|
122
122
|
data_file = config.instance_variable_get(:@data)
|
123
123
|
expect(data_file).to eql backwards_config
|
124
124
|
end
|
125
125
|
|
126
|
-
it
|
126
|
+
it 'uses default region if not in configuration' do
|
127
127
|
region = config.default_region
|
128
128
|
expect(region).to eql config_default_region
|
129
129
|
end
|
130
130
|
|
131
|
-
it
|
131
|
+
it 'uses default image if not in configuration' do
|
132
132
|
image = config.default_image
|
133
133
|
expect(image).to eql config_default_image
|
134
134
|
end
|
135
135
|
|
136
|
-
it
|
136
|
+
it 'uses default size if not in configuration' do
|
137
137
|
size = config.default_size
|
138
138
|
expect(size).to eql config_default_size
|
139
139
|
end
|
140
140
|
|
141
|
-
it
|
141
|
+
it 'uses default ssh key if not in configuration' do
|
142
142
|
ssh_key = config.default_ssh_key
|
143
143
|
expect(ssh_key).to eql config_default_ssh_key
|
144
144
|
end
|
145
145
|
|
146
|
-
it
|
146
|
+
it 'uses default private networking option if not in configuration' do
|
147
147
|
private_networking = config.default_private_networking
|
148
148
|
expect(private_networking).to eql config_default_networking
|
149
149
|
end
|
150
150
|
|
151
|
-
it
|
151
|
+
it 'uses default backups_enabled if not in the configuration' do
|
152
152
|
backups_enabled = config.default_backups_enabled
|
153
153
|
expect(backups_enabled).to eql config_default_backups
|
154
154
|
end
|
155
155
|
|
156
|
-
it
|
156
|
+
it 'uses default ip6 if not in the configuration' do
|
157
157
|
ip6 = config.default_ip6
|
158
158
|
expect(ip6).to eql config_default_ip6
|
159
159
|
end
|
160
|
-
|
161
160
|
end
|
162
161
|
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::Base do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
let(:klass)
|
6
|
+
let(:klass) { described_class }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
expect($stdout).to receive(:print).with(
|
8
|
+
describe '.initialize' do
|
9
|
+
it 'prints a clear line' do
|
10
|
+
expect($stdout).to receive(:print).with('')
|
11
11
|
klass.new({})
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
14
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::CheckConfiguration do
|
4
|
-
include_context
|
5
|
-
|
6
|
-
describe ".call" do
|
7
|
-
it "raises SystemExit with no configuration" do
|
4
|
+
include_context 'spec'
|
8
5
|
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises SystemExit with no configuration' do
|
9
8
|
# Delete the temp configuration file.
|
10
|
-
File.delete(project_path +
|
9
|
+
File.delete(project_path + '/tmp/tugboat')
|
11
10
|
|
12
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
11
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
@@ -1,21 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::CheckCredentials do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises SystemExit with no configuration' do
|
8
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
9
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
10
|
+
to_return(headers: { 'Content-Type' => 'application/json' }, status: 401, body: fixture('401'))
|
11
11
|
|
12
12
|
# Inject the client.
|
13
|
-
env[
|
13
|
+
env['barge'] = ocean
|
14
14
|
|
15
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
16
|
-
expect(a_request(:get,
|
15
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
16
|
+
expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1')).
|
17
17
|
to have_been_made
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
20
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::CheckDropletActive do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises an error when droplet is not active' do
|
8
|
+
env['droplet_status'] = 'off'
|
8
9
|
|
9
|
-
env
|
10
|
-
|
11
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
10
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::CheckDropletInactive do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises an error when droplet is active' do
|
8
|
+
env['droplet_status'] = 'active'
|
8
9
|
|
9
|
-
env
|
10
|
-
|
11
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
10
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::FindDroplet do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises SystemExit with no droplet data' do
|
8
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
9
9
|
|
10
10
|
expect($stdout.string).to include 'Tugboat attempted to find a droplet with no arguments'
|
11
11
|
expect($stdout.string).to include 'For more help run: '
|
12
12
|
expect($stdout.string).to include 'Try running `tugboat '
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::FindImage do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
|
6
|
+
describe '.call' do
|
7
|
+
it 'raises SystemExit with no image data' do
|
8
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
9
9
|
|
10
10
|
expect($stdout.string).to include 'Tugboat attempted to find an image with no arguments'
|
11
11
|
expect($stdout.string).to include 'For more help run: '
|
12
12
|
expect($stdout.string).to include 'Try running `tugboat '
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
@@ -1,29 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::InjectClient do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
let(:tmp_path)
|
6
|
+
let(:tmp_path) { project_path + '/tmp/tugboat' }
|
7
7
|
|
8
|
-
before
|
8
|
+
before do
|
9
9
|
config = Tugboat::Configuration.instance
|
10
|
-
env[
|
10
|
+
env['config'] = config
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
|
15
|
-
it "loads the client into the environment" do
|
13
|
+
describe '.call' do
|
14
|
+
it 'loads the client into the environment' do
|
16
15
|
described_class.new(app).call(env)
|
17
16
|
|
18
|
-
env[
|
17
|
+
env['barge'].should be_a Barge::Client
|
19
18
|
end
|
20
19
|
|
21
|
-
it
|
22
|
-
Barge::Client.should_receive(:new).with(hash_including(:
|
20
|
+
it 'creates a client with values from config file' do
|
21
|
+
Barge::Client.should_receive(:new).with(hash_including(access_token: 'foo'))
|
23
22
|
|
24
23
|
described_class.new(app).call(env)
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
|
-
|
29
26
|
end
|
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::InjectConfiguration do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
|
8
|
-
it "loads the configuration into the environment" do
|
6
|
+
describe '.call' do
|
7
|
+
it 'loads the configuration into the environment' do
|
9
8
|
described_class.new(app).call(env)
|
10
9
|
|
11
|
-
expect(env[
|
10
|
+
expect(env['config']).to eq(config)
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
|
-
|
16
13
|
end
|
@@ -1,111 +1,108 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::Middleware::SSHDroplet do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
6
|
before do
|
7
7
|
allow(Kernel).to receive(:exec)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe '.call' do
|
11
|
+
it 'exec ssh with correct options' do
|
12
|
+
expect(Kernel).to receive(:exec).with('ssh',
|
13
|
+
'-o', 'LogLevel=ERROR',
|
14
|
+
'-o', 'StrictHostKeyChecking=no',
|
15
|
+
'-o', 'UserKnownHostsFile=/dev/null',
|
16
|
+
'-o', 'IdentitiesOnly=yes',
|
17
|
+
'-i', File.expand_path(ssh_key_path),
|
18
|
+
'-p', ssh_port,
|
19
|
+
"#{ssh_user}@#{droplet_ip}")
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
"-o", "LogLevel=ERROR",
|
15
|
-
"-o", "StrictHostKeyChecking=no",
|
16
|
-
"-o", "UserKnownHostsFile=/dev/null",
|
17
|
-
"-o", "IdentitiesOnly=yes",
|
18
|
-
"-i", File.expand_path(ssh_key_path),
|
19
|
-
"-p", ssh_port,
|
20
|
-
"#{ssh_user}@#{droplet_ip}")
|
21
|
-
|
22
|
-
env["droplet_ip"] = droplet_ip
|
23
|
-
env["config"] = config
|
21
|
+
env['droplet_ip'] = droplet_ip
|
22
|
+
env['config'] = config
|
24
23
|
|
25
24
|
described_class.new(app).call(env)
|
26
25
|
end
|
27
26
|
|
28
|
-
it
|
29
|
-
expect(Kernel).to receive(:exec).with(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
it 'exec ssh with IdentitiesOnly=no if no ssh_key_path in config' do
|
28
|
+
expect(Kernel).to receive(:exec).with('ssh',
|
29
|
+
'-o', 'LogLevel=ERROR',
|
30
|
+
'-o', 'StrictHostKeyChecking=no',
|
31
|
+
'-o', 'UserKnownHostsFile=/dev/null',
|
32
|
+
'-o', 'IdentitiesOnly=no',
|
33
|
+
'-p', ssh_port,
|
34
|
+
"#{ssh_user}@#{droplet_ip}")
|
36
35
|
|
37
|
-
env[
|
36
|
+
env['droplet_ip'] = droplet_ip
|
38
37
|
|
39
38
|
config.data['ssh']['ssh_key_path'] = nil
|
40
39
|
|
41
|
-
env[
|
40
|
+
env['config'] = config
|
42
41
|
|
43
42
|
described_class.new(app).call(env)
|
44
43
|
end
|
45
44
|
|
46
|
-
it
|
47
|
-
expect(Kernel).to receive(:exec).with(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
env[
|
61
|
-
env[
|
62
|
-
env[
|
63
|
-
env[
|
64
|
-
env[
|
65
|
-
env[
|
45
|
+
it 'executes ssh with custom options' do
|
46
|
+
expect(Kernel).to receive(:exec).with('ssh',
|
47
|
+
'-o', 'LogLevel=ERROR',
|
48
|
+
'-o', 'StrictHostKeyChecking=no',
|
49
|
+
'-o', 'UserKnownHostsFile=/dev/null',
|
50
|
+
'-o', 'IdentitiesOnly=yes',
|
51
|
+
'-i', File.expand_path(ssh_key_path),
|
52
|
+
'-p', ssh_port,
|
53
|
+
'-e',
|
54
|
+
'-q',
|
55
|
+
'-X',
|
56
|
+
"#{ssh_user}@#{droplet_ip}",
|
57
|
+
'echo hello')
|
58
|
+
|
59
|
+
env['droplet_ip'] = droplet_ip
|
60
|
+
env['droplet_ip_private'] = droplet_ip_private
|
61
|
+
env['config'] = config
|
62
|
+
env['user_droplet_ssh_command'] = 'echo hello'
|
63
|
+
env['user_droplet_use_public_ip'] = true
|
64
|
+
env['user_droplet_ssh_opts'] = '-e -q -X'
|
66
65
|
|
67
66
|
described_class.new(app).call(env)
|
68
67
|
end
|
69
68
|
|
70
|
-
it
|
71
|
-
expect(Kernel).to receive(:exec).with(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
env[
|
85
|
-
env[
|
86
|
-
env[
|
87
|
-
env[
|
88
|
-
env[
|
89
|
-
env[
|
69
|
+
it 'executes ssh with private IP if option chosen' do
|
70
|
+
expect(Kernel).to receive(:exec).with('ssh',
|
71
|
+
'-o', 'LogLevel=ERROR',
|
72
|
+
'-o', 'StrictHostKeyChecking=no',
|
73
|
+
'-o', 'UserKnownHostsFile=/dev/null',
|
74
|
+
'-o', 'IdentitiesOnly=yes',
|
75
|
+
'-i', File.expand_path(ssh_key_path),
|
76
|
+
'-p', ssh_port,
|
77
|
+
'-e',
|
78
|
+
'-q',
|
79
|
+
'-X',
|
80
|
+
"#{ssh_user}@#{droplet_ip_private}",
|
81
|
+
'echo hello')
|
82
|
+
|
83
|
+
env['droplet_ip'] = droplet_ip
|
84
|
+
env['droplet_ip_private'] = droplet_ip_private
|
85
|
+
env['config'] = config
|
86
|
+
env['user_droplet_ssh_command'] = 'echo hello'
|
87
|
+
env['user_droplet_use_private_ip'] = true
|
88
|
+
env['user_droplet_ssh_opts'] = '-e -q -X'
|
90
89
|
|
91
90
|
described_class.new(app).call(env)
|
92
91
|
end
|
93
92
|
|
94
|
-
it
|
95
|
-
env[
|
96
|
-
env[
|
97
|
-
env[
|
98
|
-
env[
|
99
|
-
env[
|
93
|
+
it 'errors if private IP option given but no Private IP on Droplet' do
|
94
|
+
env['droplet_ip'] = droplet_ip
|
95
|
+
env['config'] = config
|
96
|
+
env['user_droplet_ssh_command'] = 'echo hello'
|
97
|
+
env['user_droplet_use_private_ip'] = true
|
98
|
+
env['user_droplet_ssh_opts'] = '-e -q -X'
|
100
99
|
|
101
|
-
expect {described_class.new(app).call(env)}.to raise_error(SystemExit)
|
100
|
+
expect { described_class.new(app).call(env) }.to raise_error(SystemExit)
|
102
101
|
|
103
102
|
expect($stdout.string).to eq <<-eos
|
104
103
|
Executing SSH on Droplet ...
|
105
104
|
You asked to ssh to the private IP, but no Private IP found!
|
106
105
|
eos
|
107
106
|
end
|
108
|
-
|
109
107
|
end
|
110
|
-
|
111
108
|
end
|