tugboat 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +520 -0
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +0 -6
  5. data/README.md +34 -2
  6. data/Rakefile +6 -1
  7. data/bin/tugboat +2 -2
  8. data/features/cassettes/config/Array_of_SSH_Keys_in_Config.yml +1 -1
  9. data/features/cassettes/config/Single_SSH_key_as_number_in_config.yml +1 -1
  10. data/features/step_definitions/steps.rb +1 -1
  11. data/features/support/env.rb +7 -3
  12. data/lib/tugboat.rb +2 -2
  13. data/lib/tugboat/cli.rb +394 -444
  14. data/lib/tugboat/config.rb +43 -61
  15. data/lib/tugboat/middleware.rb +33 -33
  16. data/lib/tugboat/middleware/add_key.rb +12 -13
  17. data/lib/tugboat/middleware/ask_for_credentials.rb +12 -13
  18. data/lib/tugboat/middleware/base.rb +25 -20
  19. data/lib/tugboat/middleware/check_configuration.rb +3 -6
  20. data/lib/tugboat/middleware/check_credentials.rb +0 -1
  21. data/lib/tugboat/middleware/check_droplet_active.rb +2 -4
  22. data/lib/tugboat/middleware/check_droplet_inactive.rb +2 -4
  23. data/lib/tugboat/middleware/config.rb +3 -5
  24. data/lib/tugboat/middleware/confirm_action.rb +4 -6
  25. data/lib/tugboat/middleware/create_droplet.rb +27 -44
  26. data/lib/tugboat/middleware/custom_logger.rb +52 -54
  27. data/lib/tugboat/middleware/destroy_droplet.rb +5 -6
  28. data/lib/tugboat/middleware/destroy_image.rb +5 -6
  29. data/lib/tugboat/middleware/find_droplet.rb +43 -47
  30. data/lib/tugboat/middleware/find_image.rb +23 -29
  31. data/lib/tugboat/middleware/halt_droplet.rb +9 -10
  32. data/lib/tugboat/middleware/info_droplet.rb +30 -33
  33. data/lib/tugboat/middleware/info_image.rb +1 -1
  34. data/lib/tugboat/middleware/inject_client.rb +8 -10
  35. data/lib/tugboat/middleware/inject_configuration.rb +1 -2
  36. data/lib/tugboat/middleware/list_droplets.rb +9 -10
  37. data/lib/tugboat/middleware/list_images.rb +9 -9
  38. data/lib/tugboat/middleware/list_regions.rb +1 -1
  39. data/lib/tugboat/middleware/list_sizes.rb +1 -1
  40. data/lib/tugboat/middleware/list_ssh_keys.rb +1 -3
  41. data/lib/tugboat/middleware/password_reset.rb +6 -7
  42. data/lib/tugboat/middleware/rebuild_droplet.rb +7 -7
  43. data/lib/tugboat/middleware/resize_droplet.rb +6 -7
  44. data/lib/tugboat/middleware/restart_droplet.rb +4 -11
  45. data/lib/tugboat/middleware/snapshot_droplet.rb +7 -8
  46. data/lib/tugboat/middleware/ssh_droplet.rb +30 -31
  47. data/lib/tugboat/middleware/start_droplet.rb +5 -5
  48. data/lib/tugboat/middleware/wait_for_state.rb +2 -3
  49. data/lib/tugboat/version.rb +1 -1
  50. data/spec/cli/add_key_spec.rb +25 -28
  51. data/spec/cli/authorize_cli_spec.rb +57 -60
  52. data/spec/cli/config_cli_spec.rb +8 -11
  53. data/spec/cli/create_cli_spec.rb +40 -46
  54. data/spec/cli/debug_cli_spec.rb +29 -29
  55. data/spec/cli/destroy_cli_spec.rb +58 -60
  56. data/spec/cli/destroy_image_cli_spec.rb +42 -45
  57. data/spec/cli/droplets_cli_spec.rb +62 -64
  58. data/spec/cli/env_variable_spec.rb +14 -15
  59. data/spec/cli/halt_cli_spec.rb +65 -69
  60. data/spec/cli/help_cli_spec.rb +8 -8
  61. data/spec/cli/images_cli_spec.rb +28 -30
  62. data/spec/cli/info_cli_spec.rb +144 -147
  63. data/spec/cli/info_image_cli_spec.rb +57 -60
  64. data/spec/cli/keys_cli_spec.rb +8 -10
  65. data/spec/cli/password_reset_cli_spec.rb +56 -56
  66. data/spec/cli/rebuild_cli_spec.rb +194 -198
  67. data/spec/cli/regions_cli_spec.rb +8 -8
  68. data/spec/cli/resize_cli_spec.rb +54 -56
  69. data/spec/cli/restart_cli_spec.rb +53 -57
  70. data/spec/cli/sizes_cli_spec.rb +7 -8
  71. data/spec/cli/snapshot_cli_spec.rb +50 -53
  72. data/spec/cli/ssh_cli_spec.rb +41 -42
  73. data/spec/cli/start_cli_spec.rb +48 -52
  74. data/spec/cli/verify_cli_spec.rb +22 -25
  75. data/spec/cli/version_cli_spec.rb +6 -8
  76. data/spec/cli/wait_cli_spec.rb +50 -52
  77. data/spec/config_spec.rb +56 -57
  78. data/spec/middleware/base_spec.rb +5 -6
  79. data/spec/middleware/check_configuration_spec.rb +5 -7
  80. data/spec/middleware/check_credentials_spec.rb +9 -10
  81. data/spec/middleware/check_droplet_active_spec.rb +5 -7
  82. data/spec/middleware/check_droplet_inactive_spec.rb +5 -7
  83. data/spec/middleware/find_droplet_spec.rb +4 -5
  84. data/spec/middleware/find_image_spec.rb +4 -5
  85. data/spec/middleware/inject_client_spec.rb +9 -12
  86. data/spec/middleware/inject_configuration_spec.rb +4 -7
  87. data/spec/middleware/ssh_droplet_spec.rb +70 -73
  88. data/spec/shared/environment.rb +18 -20
  89. data/spec/spec_helper.rb +4 -4
  90. data/tugboat.gemspec +10 -6
  91. 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 "spec"
4
+ include_context 'spec'
5
5
 
6
- let(:tmp_path) { project_path + "/tmp/tugboat" }
6
+ let(:tmp_path) { project_path + '/tmp/tugboat' }
7
7
 
8
- after :each do
8
+ after do
9
9
  # Clean up the temp file.
10
- File.delete(project_path + "/tmp/tugboat") if File.exist?(project_path + "/tmp/tugboat")
10
+ File.delete(project_path + '/tmp/tugboat') if File.exist?(project_path + '/tmp/tugboat')
11
11
  end
12
12
 
13
- it "is a singleton" do
14
- expect(Tugboat::Configuration).to be_a Class
13
+ it 'is a singleton' do
14
+ expect(described_class).to be_a Class
15
15
  expect do
16
- Tugboat::Configuration.new
17
- end.to raise_error(NoMethodError, /private method `new' called/)
16
+ described_class.new
17
+ end.to raise_error(NoMethodError, %r{private method `new' called})
18
18
  end
19
19
 
20
- it "has a data attribute" do
21
- config = Tugboat::Configuration.instance
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 "the file" do
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) { config = Tugboat::Configuration.instance }
38
+ let(:config) { described_class.instance }
39
39
 
40
- before :each do
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 "can be created" do
45
+ it 'can be created' do
46
46
  expect(File.exist?(tmp_path)).to be_true
47
47
  end
48
48
 
49
- it "can be loaded" do
49
+ it 'can be loaded' do
50
50
  data = config.load_config_file
51
- expect(data).to_not be_nil
51
+ expect(data).not_to be_nil
52
52
  end
53
53
 
54
- describe "the file format"
55
- let(:data) { YAML.load_file(tmp_path) }
54
+ describe 'the file format'
55
+ let(:data) { YAML.load_file(tmp_path) }
56
56
 
57
- it "should have authentication at the top level" do
58
- expect(data).to have_key("authentication")
57
+ it 'has authentication at the top level' do
58
+ expect(data).to have_key('authentication')
59
59
  end
60
60
 
61
- it "should have ssh at the top level" do
62
- expect(data).to have_key("ssh")
61
+ it 'has ssh at the top level' do
62
+ expect(data).to have_key('ssh')
63
63
  end
64
64
 
65
- it "should have an access token" do
66
- auth = data["authentication"]
67
- expect(auth).to have_key("access_token")
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 "should have an ssh key path" do
71
- ssh = data["ssh"]
72
- expect(ssh).to have_key("ssh_key_path")
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 "should have an ssh user" do
76
- ssh = data["ssh"]
77
- expect(ssh).to have_key("ssh_user")
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 "should have an ssh port" do
81
- ssh = data["ssh"]
82
- expect(ssh).to have_key("ssh_port")
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 "should have private_networking set" do
86
- private_networking = data["defaults"]
87
- expect(private_networking).to have_key("private_networking")
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 "should have backups_enabled set" do
91
- backups_enabled = data["defaults"]
92
- expect(backups_enabled).to have_key("backups_enabled")
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 "backwards compatible" do
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) { config = Tugboat::Configuration.instance }
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) { Tugboat::Configuration::DEFAULT_IP6 }
110
- let(:backwards_config) {
109
+ let(:config_default_ip6) { Tugboat::Configuration::DEFAULT_IP6 }
110
+ let(:backwards_config) do
111
111
  {
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},
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 :each do
117
+ before do
118
118
  config.instance_variable_set(:@data, backwards_config)
119
119
  end
120
120
 
121
- it "should load a backwards compatible config file" do
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 "should use default region if not in configuration" do
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 "should use default image if not in configuration" do
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 "should use default size if not in configuration" do
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 "should use default ssh key if not in configuration" do
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 "should use default private networking option if not in configuration" do
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 "should use default backups_enabled if not in the configuration" do
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 "should use default ip6 if not in the configuration" do
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 "spec"
4
+ include_context 'spec'
5
5
 
6
- let(:klass) { described_class }
6
+ let(:klass) { described_class }
7
7
 
8
- describe ".initialize" do
9
- it "prints a clear line" do
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 "spec"
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 + "/tmp/tugboat")
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 "spec"
4
+ include_context 'spec'
5
5
 
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.9.2'}).
10
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 401, :body => fixture('401'))
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["barge"] = ocean
13
+ env['barge'] = ocean
14
14
 
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")).
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 "spec"
4
+ include_context 'spec'
5
5
 
6
- describe ".call" do
7
- it "raises an error when droplet is not active" do
6
+ describe '.call' do
7
+ it 'raises an error when droplet is not active' do
8
+ env['droplet_status'] = 'off'
8
9
 
9
- env["droplet_status"] = "off"
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 "spec"
4
+ include_context 'spec'
5
5
 
6
- describe ".call" do
7
- it "raises an error when droplet is active" do
6
+ describe '.call' do
7
+ it 'raises an error when droplet is active' do
8
+ env['droplet_status'] = 'active'
8
9
 
9
- env["droplet_status"] = "active"
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 "spec"
4
+ include_context 'spec'
5
5
 
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)
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 "spec"
4
+ include_context 'spec'
5
5
 
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)
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 "spec"
4
+ include_context 'spec'
5
5
 
6
- let(:tmp_path) { project_path + "/tmp/tugboat" }
6
+ let(:tmp_path) { project_path + '/tmp/tugboat' }
7
7
 
8
- before :each do
8
+ before do
9
9
  config = Tugboat::Configuration.instance
10
- env["config"] = config
10
+ env['config'] = config
11
11
  end
12
12
 
13
- describe ".call" do
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["barge"].should be_a Barge::Client
17
+ env['barge'].should be_a Barge::Client
19
18
  end
20
19
 
21
- it "creates a client with values from config file" do
22
- Barge::Client.should_receive(:new).with(hash_including(:access_token=>"foo"))
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 "spec"
4
+ include_context 'spec'
5
5
 
6
- describe ".call" do
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["config"]).to eq(config)
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 "spec"
4
+ include_context 'spec'
5
5
 
6
6
  before do
7
7
  allow(Kernel).to receive(:exec)
8
8
  end
9
9
 
10
- describe ".call" do
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
- it "exec ssh with correct options" do
13
- expect(Kernel).to receive(:exec).with("ssh",
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 "exec ssh with IdentitiesOnly=no if no ssh_key_path in config" do
29
- expect(Kernel).to receive(:exec).with("ssh",
30
- "-o", "LogLevel=ERROR",
31
- "-o", "StrictHostKeyChecking=no",
32
- "-o", "UserKnownHostsFile=/dev/null",
33
- "-o", "IdentitiesOnly=no",
34
- "-p", ssh_port,
35
- "#{ssh_user}@#{droplet_ip}")
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["droplet_ip"] = droplet_ip
36
+ env['droplet_ip'] = droplet_ip
38
37
 
39
38
  config.data['ssh']['ssh_key_path'] = nil
40
39
 
41
- env["config"] = config
40
+ env['config'] = config
42
41
 
43
42
  described_class.new(app).call(env)
44
43
  end
45
44
 
46
- it "executes ssh with custom options" do
47
- expect(Kernel).to receive(:exec).with("ssh",
48
- "-o", "LogLevel=ERROR",
49
- "-o", "StrictHostKeyChecking=no",
50
- "-o", "UserKnownHostsFile=/dev/null",
51
- "-o", "IdentitiesOnly=yes",
52
- "-i", File.expand_path(ssh_key_path),
53
- "-p", ssh_port,
54
- "-e",
55
- "-q",
56
- "-X",
57
- "#{ssh_user}@#{droplet_ip}",
58
- "echo hello")
59
-
60
- env["droplet_ip"] = droplet_ip
61
- env["droplet_ip_private"] = droplet_ip_private
62
- env["config"] = config
63
- env["user_droplet_ssh_command"] = "echo hello"
64
- env["user_droplet_use_public_ip"] = true
65
- env["user_droplet_ssh_opts"] = "-e -q -X"
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 "executes ssh with private IP if option chosen" do
71
- expect(Kernel).to receive(:exec).with("ssh",
72
- "-o", "LogLevel=ERROR",
73
- "-o", "StrictHostKeyChecking=no",
74
- "-o", "UserKnownHostsFile=/dev/null",
75
- "-o", "IdentitiesOnly=yes",
76
- "-i", File.expand_path(ssh_key_path),
77
- "-p", ssh_port,
78
- "-e",
79
- "-q",
80
- "-X",
81
- "#{ssh_user}@#{droplet_ip_private}",
82
- "echo hello")
83
-
84
- env["droplet_ip"] = droplet_ip
85
- env["droplet_ip_private"] = droplet_ip_private
86
- env["config"] = config
87
- env["user_droplet_ssh_command"] = "echo hello"
88
- env["user_droplet_use_private_ip"] = true
89
- env["user_droplet_ssh_opts"] = "-e -q -X"
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 "errors if private IP option given but no Private IP on Droplet" do
95
- env["droplet_ip"] = droplet_ip
96
- env["config"] = config
97
- env["user_droplet_ssh_command"] = "echo hello"
98
- env["user_droplet_use_private_ip"] = true
99
- env["user_droplet_ssh_opts"] = "-e -q -X"
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