tugboat 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -3
  3. data/features/{vagrant-adam → tugboat}/config_current_directory.feature +0 -0
  4. data/lib/tugboat/cli.rb +6 -1
  5. data/lib/tugboat/middleware/base.rb +59 -0
  6. data/lib/tugboat/middleware/check_credentials.rb +1 -10
  7. data/lib/tugboat/middleware/find_droplet.rb +23 -18
  8. data/lib/tugboat/middleware/list_droplets.rb +23 -19
  9. data/lib/tugboat/middleware/rebuild_droplet.rb +1 -1
  10. data/lib/tugboat/middleware/snapshot_droplet.rb +1 -1
  11. data/lib/tugboat/middleware/ssh_droplet.rb +15 -2
  12. data/lib/tugboat/middleware/wait_for_state.rb +1 -20
  13. data/lib/tugboat/version.rb +1 -1
  14. data/spec/cli/authorize_cli_spec.rb +2 -2
  15. data/spec/cli/create_cli_spec.rb +10 -10
  16. data/spec/cli/debug_cli_spec.rb +2 -2
  17. data/spec/cli/destroy_cli_spec.rb +22 -6
  18. data/spec/cli/droplets_cli_spec.rb +72 -8
  19. data/spec/cli/env_variable_spec.rb +4 -4
  20. data/spec/cli/halt_cli_spec.rb +24 -4
  21. data/spec/cli/info_cli_spec.rb +55 -10
  22. data/spec/cli/password_reset_cli_spec.rb +20 -4
  23. data/spec/cli/rebuild_cli_spec.rb +59 -19
  24. data/spec/cli/resize_cli_spec.rb +19 -3
  25. data/spec/cli/restart_cli_spec.rb +19 -3
  26. data/spec/cli/snapshot_cli_spec.rb +19 -3
  27. data/spec/cli/ssh_cli_spec.rb +37 -2
  28. data/spec/cli/start_cli_spec.rb +19 -3
  29. data/spec/cli/verify_cli_spec.rb +9 -9
  30. data/spec/cli/wait_cli_spec.rb +19 -3
  31. data/spec/fixtures/401.json +4 -0
  32. data/spec/fixtures/show_droplets.json +0 -4
  33. data/spec/fixtures/show_droplets_paginated_first.json +256 -0
  34. data/spec/fixtures/show_droplets_paginated_last.json +253 -0
  35. data/spec/fixtures/show_droplets_private_ip.json +258 -0
  36. data/spec/middleware/check_credentials_spec.rb +3 -3
  37. data/spec/middleware/ssh_droplet_spec.rb +21 -3
  38. data/tugboat.gemspec +1 -0
  39. metadata +26 -4
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "rebuild" do
7
7
  it "rebuilds a droplet with a fuzzy name based on an image with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
13
  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
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -14,7 +18,7 @@ describe Tugboat::CLI do
14
18
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
15
19
 
16
20
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
17
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
21
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
18
22
  :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'}).
19
23
  to_return(:status => 200, :body => "", :headers => {})
20
24
 
@@ -31,6 +35,10 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
31
35
  end
32
36
 
33
37
  it "rebuilds a droplet with an id based on an image with a fuzzy name" do
38
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
39
+ 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'}).
40
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
41
+
34
42
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
35
43
  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'}).
36
44
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -40,7 +48,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
40
48
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
41
49
 
42
50
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
43
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
51
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
44
52
  :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'}).
45
53
  to_return(:status => 200, :body => "", :headers => {})
46
54
 
@@ -57,7 +65,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
57
65
  end
58
66
 
59
67
  it "rebuilds a droplet with a name based on an image with a fuzzy name" do
60
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
68
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
69
+ 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'}).
70
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
71
+
72
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
61
73
  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'}).
62
74
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
63
75
 
@@ -70,7 +82,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
70
82
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
71
83
 
72
84
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
73
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
85
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
74
86
  :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'}).
75
87
  to_return(:status => 200, :body => "", :headers => {})
76
88
 
@@ -88,7 +100,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
88
100
  end
89
101
 
90
102
  it "rebuilds a droplet with a fuzzy name based on an image with an id" do
91
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
103
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
104
+ 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'}).
105
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
106
+
107
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
92
108
  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'}).
93
109
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
94
110
 
@@ -105,7 +121,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
105
121
  to_return(:status => 200, :body => fixture('show_image'), :headers => {})
106
122
 
107
123
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
108
- with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
124
+ with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
109
125
  :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'}).
110
126
  to_return(:status => 200, :body => "", :headers => {})
111
127
 
@@ -122,7 +138,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
122
138
  end
123
139
 
124
140
  it "rebuilds a droplet with an id based on an image with an id" do
125
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
141
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
142
+ 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'}).
143
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
144
+
145
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
126
146
  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'}).
127
147
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
128
148
 
@@ -139,7 +159,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
139
159
  to_return(:status => 200, :body => fixture('show_image'), :headers => {})
140
160
 
141
161
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
142
- with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
162
+ with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
143
163
  :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'}).
144
164
  to_return(:status => 200, :body => "", :headers => {})
145
165
 
@@ -156,7 +176,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
156
176
  end
157
177
 
158
178
  it "rebuilds a droplet with a name based on an image with an id" do
159
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
179
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
180
+ 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'}).
181
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
182
+
183
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
160
184
  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'}).
161
185
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
162
186
 
@@ -173,7 +197,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
173
197
  to_return(:status => 200, :body => fixture('show_image'), :headers => {})
174
198
 
175
199
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
176
- with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
200
+ with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
177
201
  :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'}).
178
202
  to_return(:status => 200, :body => "", :headers => {})
179
203
 
@@ -190,7 +214,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
190
214
  end
191
215
 
192
216
  it "rebuilds a droplet with a fuzzy name based on an image with a name" do
193
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
217
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
218
+ 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'}).
219
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
220
+
221
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
194
222
  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'}).
195
223
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
196
224
 
@@ -199,7 +227,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
199
227
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
200
228
 
201
229
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
202
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
230
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
203
231
  :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'}).
204
232
  to_return(:status => 200, :body => "", :headers => {})
205
233
 
@@ -217,7 +245,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
217
245
  end
218
246
 
219
247
  it "rebuilds a droplet with an id based on an image with a name" do
220
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
248
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
249
+ 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'}).
250
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
251
+
252
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
221
253
  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'}).
222
254
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
223
255
 
@@ -230,7 +262,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
230
262
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
231
263
 
232
264
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
233
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
265
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
234
266
  :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'}).
235
267
  to_return(:status => 200, :body => "", :headers => {})
236
268
 
@@ -247,7 +279,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
247
279
  end
248
280
 
249
281
  it "rebuilds a droplet with a name based on an image with a name" do
250
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
282
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
283
+ 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'}).
284
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
285
+
286
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
251
287
  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'}).
252
288
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
253
289
 
@@ -256,7 +292,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
256
292
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
257
293
 
258
294
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
259
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
295
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
260
296
  :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'}).
261
297
  to_return(:status => 200, :body => "", :headers => {})
262
298
 
@@ -273,7 +309,11 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
273
309
  end
274
310
 
275
311
  it "rebuilds a droplet with confirm flag set" do
276
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
312
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
313
+ 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'}).
314
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
315
+
316
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
277
317
  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'}).
278
318
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
279
319
 
@@ -282,7 +322,7 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
282
322
  to_return(:status => 200, :body => fixture('show_images'), :headers => {})
283
323
 
284
324
  stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
285
- with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
325
+ with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
286
326
  :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'}).
287
327
  to_return(:status => 200, :body => "", :headers => {})
288
328
 
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "resize" do
7
7
  it "resizes a droplet with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
13
  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
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -24,6 +28,10 @@ Queuing resize for 6918990 (example.com)...Resize complete!
24
28
  end
25
29
 
26
30
  it "resizes a droplet with an id" do
31
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
32
+ 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'}).
33
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
34
+
27
35
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
28
36
  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'}).
29
37
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -43,7 +51,11 @@ Queuing resize for 6918990 (example.com)...Resize complete!
43
51
  end
44
52
 
45
53
  it "resizes a droplet with a name" do
46
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
54
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
55
+ 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'}).
56
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
57
+
58
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
47
59
  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'}).
48
60
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
49
61
 
@@ -63,7 +75,11 @@ Queuing resize for 6918990 (example.com)...Resize complete!
63
75
  end
64
76
 
65
77
  it "raises SystemExit when a request fails" do
66
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
78
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
79
+ 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'}).
80
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
81
+
82
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
67
83
  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'}).
68
84
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
69
85
 
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "restarts a droplet" do
7
7
  it "with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
13
  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
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -24,7 +28,11 @@ Queuing restart for 6918990 (example.com)...Restart complete!
24
28
  end
25
29
 
26
30
  it "restarts a droplet hard when the hard option is used" do
27
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
31
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
32
+ 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'}).
33
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
34
+
35
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
28
36
  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'}).
29
37
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
30
38
 
@@ -43,6 +51,10 @@ Queuing hard restart for 6918990 (example.com)...Restart complete!
43
51
  end
44
52
 
45
53
  it "with an id" do
54
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
55
+ 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'}).
56
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
57
+
46
58
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
47
59
  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'}).
48
60
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -63,7 +75,11 @@ Queuing restart for 6918990 (example.com)...Restart complete!
63
75
 
64
76
 
65
77
  it "with a name" do
66
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
78
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
79
+ 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'}).
80
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
81
+
82
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
67
83
  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'}).
68
84
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
69
85
 
@@ -7,7 +7,11 @@ describe Tugboat::CLI do
7
7
 
8
8
  describe "snapshots a droplet" do
9
9
  it "with a fuzzy name" do
10
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
10
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
11
+ 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'}).
12
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
13
+
14
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
11
15
  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'}).
12
16
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
13
17
 
@@ -26,6 +30,10 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
26
30
  end
27
31
 
28
32
  it "with an id" do
33
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
34
+ 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'}).
35
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
36
+
29
37
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/3164444?per_page=200").
30
38
  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'}).
31
39
  to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet_inactive"))
@@ -47,7 +55,11 @@ Queuing snapshot 'foo-snapshot' for 3164494 (example.com)...Snapshot successful!
47
55
 
48
56
 
49
57
  it "with a name" do
50
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
58
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
59
+ 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'}).
60
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
61
+
62
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
51
63
  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'}).
52
64
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
53
65
 
@@ -67,7 +79,11 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
67
79
  end
68
80
 
69
81
  it "does not snapshot a droplet that is active" do
70
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
82
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
83
+ 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'}).
84
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
85
+
86
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
71
87
  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'}).
72
88
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
73
89
 
@@ -5,15 +5,50 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "ssh" do
7
7
  it "tries to fetch the droplet's IP from the API" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
13
+ to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
14
+ allow(Kernel).to receive(:exec).with('ssh', anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything())
15
+
16
+ @cli.ssh("example.com")
17
+ end
18
+
19
+ it "wait's until droplet active if -w command is given" do
20
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
21
+ 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'}).
22
+ to_return(:status => 200, :body => "", :headers => {})
23
+
24
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
25
+ 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'}).
26
+ to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
27
+
28
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
29
  to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
10
30
  allow(Kernel).to receive(:exec).with('ssh', anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything(), anything(),anything())
11
31
 
32
+ @cli.options = @cli.options.merge(:wait => true)
33
+
12
34
  @cli.ssh("example.com")
35
+
36
+ expect($stdout.string).to eq <<-eos
37
+ Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
38
+ Executing SSH on Droplet (example.com)...
39
+ Wait flag given, waiting for droplet to become active
40
+ .done\e[0m (0s)
41
+ Attempting SSH: baz@104.236.32.182
42
+ SShing with options: -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i #{Dir.home}/.ssh/id_rsa2 -p 33 baz@104.236.32.182
43
+ eos
13
44
  end
14
45
 
15
46
  it "does not allow ssh into a droplet that is inactive" do
16
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
47
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
48
+ 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'}).
49
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
50
+
51
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
17
52
  to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
18
53
  allow(Kernel).to receive(:exec)
19
54
 
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "start" do
7
7
  it "starts the droplet with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
13
  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
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -23,6 +27,10 @@ Queuing start for 3164444 (example3.com)...Start complete!
23
27
  end
24
28
 
25
29
  it "starts the droplet with an id" do
30
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
31
+ 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'}).
32
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
33
+
26
34
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/3164494?per_page=200").
27
35
  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'}).
28
36
  to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet_inactive"))
@@ -43,7 +51,11 @@ Queuing start for 3164494 (example.com)...Start complete!
43
51
 
44
52
 
45
53
  it "starts the droplet with a name" do
46
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
54
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
55
+ 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'}).
56
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
57
+
58
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
47
59
  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'}).
48
60
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
49
61
 
@@ -62,7 +74,11 @@ Queuing start for 3164444 (example3.com)...Start complete!
62
74
  end
63
75
 
64
76
  it "does not start a droplet that is inactive" do
65
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
77
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
78
+ 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'}).
79
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
80
+
81
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
66
82
  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'}).
67
83
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
68
84