tugboat 1.3.1 → 2.0.0.RC1
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/.travis.yml +1 -1
- data/CHANGELOG.md +12 -8
- data/lib/tugboat/cli.rb +8 -7
- data/lib/tugboat/config.rb +8 -12
- data/lib/tugboat/middleware/add_key.rb +9 -6
- data/lib/tugboat/middleware/ask_for_credentials.rb +7 -8
- data/lib/tugboat/middleware/check_configuration.rb +1 -1
- data/lib/tugboat/middleware/check_credentials.rb +4 -2
- data/lib/tugboat/middleware/config.rb +3 -4
- data/lib/tugboat/middleware/create_droplet.rb +32 -26
- data/lib/tugboat/middleware/destroy_droplet.rb +6 -6
- data/lib/tugboat/middleware/destroy_image.rb +6 -6
- data/lib/tugboat/middleware/find_droplet.rb +20 -16
- data/lib/tugboat/middleware/find_image.rb +17 -10
- data/lib/tugboat/middleware/halt_droplet.rb +8 -8
- data/lib/tugboat/middleware/info_droplet.rb +38 -25
- data/lib/tugboat/middleware/info_image.rb +5 -5
- data/lib/tugboat/middleware/inject_client.rb +3 -9
- data/lib/tugboat/middleware/list_droplets.rb +6 -4
- data/lib/tugboat/middleware/list_images.rb +28 -23
- data/lib/tugboat/middleware/list_regions.rb +3 -3
- data/lib/tugboat/middleware/list_sizes.rb +3 -3
- data/lib/tugboat/middleware/list_ssh_keys.rb +5 -4
- data/lib/tugboat/middleware/password_reset.rb +7 -7
- data/lib/tugboat/middleware/rebuild_droplet.rb +8 -8
- data/lib/tugboat/middleware/resize_droplet.rb +7 -7
- data/lib/tugboat/middleware/restart_droplet.rb +8 -8
- data/lib/tugboat/middleware/snapshot_droplet.rb +6 -6
- data/lib/tugboat/middleware/ssh_droplet.rb +3 -1
- data/lib/tugboat/middleware/start_droplet.rb +6 -6
- data/lib/tugboat/middleware/wait_for_state.rb +6 -6
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +16 -9
- data/spec/cli/authorize_cli_spec.rb +24 -29
- data/spec/cli/config_cli_spec.rb +57 -0
- data/spec/cli/create_cli_spec.rb +18 -28
- data/spec/cli/debug_cli_spec.rb +8 -14
- data/spec/cli/destroy_cli_spec.rb +39 -50
- data/spec/cli/destroy_image_cli_spec.rb +33 -39
- data/spec/cli/droplets_cli_spec.rb +15 -12
- data/spec/cli/halt_cli_spec.rb +50 -46
- data/spec/cli/images_cli_spec.rb +134 -58
- data/spec/cli/info_cli_spec.rb +139 -139
- data/spec/cli/info_image_cli_spec.rb +113 -26
- data/spec/cli/keys_cli_spec.rb +7 -5
- data/spec/cli/password_reset_cli_spec.rb +46 -44
- data/spec/cli/rebuild_cli_spec.rb +187 -101
- data/spec/cli/regions_cli_spec.rb +13 -6
- data/spec/cli/resize_cli_spec.rb +51 -48
- data/spec/cli/restart_cli_spec.rb +41 -39
- data/spec/cli/sizes_cli_spec.rb +13 -8
- data/spec/cli/snapshot_cli_spec.rb +36 -37
- data/spec/cli/ssh_cli_spec.rb +7 -15
- data/spec/cli/start_cli_spec.rb +39 -35
- data/spec/cli/verify_cli_spec.rb +20 -12
- data/spec/cli/wait_cli_spec.rb +43 -27
- data/spec/config_spec.rb +19 -25
- data/spec/fixtures/create_droplet.json +44 -0
- data/spec/fixtures/create_ssh_key.json +4 -4
- data/spec/fixtures/create_ssh_key_from_file.json +8 -0
- data/spec/fixtures/droplet_start_response.json +13 -0
- data/spec/fixtures/not_found.json +4 -0
- data/spec/fixtures/password_reset_response.json +13 -0
- data/spec/fixtures/power_cycle_response.json +13 -0
- data/spec/fixtures/resize_droplet.json +13 -0
- data/spec/fixtures/restart_response.json +13 -0
- data/spec/fixtures/show_coreos_image.json +23 -0
- data/spec/fixtures/show_droplet.json +90 -11
- data/spec/fixtures/show_droplet_inactive.json +90 -11
- data/spec/fixtures/show_droplets.json +249 -30
- data/spec/fixtures/show_droplets_empty.json +5 -2
- data/spec/fixtures/show_image.json +14 -7
- data/spec/fixtures/show_images.json +1075 -13
- data/spec/fixtures/show_images_global.json +25 -16
- data/spec/fixtures/show_keys.json +15 -7
- data/spec/fixtures/show_redmine_image.json +24 -0
- data/spec/fixtures/show_regions.json +181 -12
- data/spec/fixtures/show_sizes.json +178 -9
- data/spec/fixtures/shutdown_response.json +13 -0
- data/spec/fixtures/snapshot_response.json +13 -0
- data/spec/fixtures/ubuntu_image_9801951.json +24 -0
- data/spec/middleware/check_credentials_spec.rb +4 -3
- data/spec/middleware/inject_client_spec.rb +2 -2
- data/spec/shared/environment.rb +6 -7
- data/spec/spec_helper.rb +1 -1
- data/tugboat.gemspec +39 -19
- metadata +50 -14
- data/spec/fixtures/show_droplet_fuzzy.json +0 -13
- data/spec/fixtures/show_droplets_fuzzy.json +0 -35
- data/spec/fixtures/show_droplets_inactive.json +0 -37
@@ -7,28 +7,28 @@ describe Tugboat::CLI do
|
|
7
7
|
|
8
8
|
describe "authorize" do
|
9
9
|
before do
|
10
|
-
|
11
|
-
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200)
|
10
|
+
|
12
11
|
end
|
13
12
|
|
14
13
|
it "asks the right questions and checks credentials" do
|
14
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
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'}).
|
16
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
15
17
|
|
16
18
|
expect($stdout).to receive(:print).exactly(6).times
|
17
|
-
expect($stdout).to receive(:print).with("Enter your
|
18
|
-
expect($stdin).to receive(:gets).and_return(
|
19
|
-
expect($stdout).to receive(:print).with("Enter your API key: ")
|
20
|
-
expect($stdin).to receive(:gets).and_return(api_key)
|
19
|
+
expect($stdout).to receive(:print).with("Enter your access token: ")
|
20
|
+
expect($stdin).to receive(:gets).and_return(access_token)
|
21
21
|
expect($stdout).to receive(:print).with("Enter your SSH key path (optional, defaults to ~/.ssh/id_rsa): ")
|
22
22
|
expect($stdin).to receive(:gets).and_return(ssh_key_path)
|
23
23
|
expect($stdout).to receive(:print).with("Enter your SSH user (optional, defaults to root): ")
|
24
24
|
expect($stdin).to receive(:gets).and_return(ssh_user)
|
25
25
|
expect($stdout).to receive(:print).with("Enter your SSH port number (optional, defaults to 22): ")
|
26
26
|
expect($stdin).to receive(:gets).and_return(ssh_port)
|
27
|
-
expect($stdout).to receive(:print).with("Enter your default region
|
27
|
+
expect($stdout).to receive(:print).with("Enter your default region (optional, defaults to nyc1): ")
|
28
28
|
expect($stdin).to receive(:gets).and_return(region)
|
29
|
-
expect($stdout).to receive(:print).with("Enter your default image ID (optional, defaults to
|
29
|
+
expect($stdout).to receive(:print).with("Enter your default image ID or image slug (optional, defaults to ubuntu-14-04-x64): ")
|
30
30
|
expect($stdin).to receive(:gets).and_return(image)
|
31
|
-
expect($stdout).to receive(:print).with("Enter your default size
|
31
|
+
expect($stdout).to receive(:print).with("Enter your default size (optional, defaults to 512mb)): ")
|
32
32
|
expect($stdin).to receive(:gets).and_return(size)
|
33
33
|
expect($stdout).to receive(:print).with("Enter your default ssh key ID (optional, defaults to none): ")
|
34
34
|
expect($stdin).to receive(:gets).and_return(ssh_key_id)
|
@@ -39,13 +39,10 @@ describe Tugboat::CLI do
|
|
39
39
|
|
40
40
|
@cli.authorize
|
41
41
|
|
42
|
-
expect($stdout.string).to include("Note: You can get
|
43
|
-
expect($stdout.string).to include("Also Note: Tugboat is setup to work with v1 of the Digital Ocean API (https://developers.digitalocean.com/v1/)")
|
42
|
+
expect($stdout.string).to include("Note: You can get your Access Token from https://cloud.digitalocean.com/settings/tokens/new")
|
44
43
|
expect($stdout.string).to include("To retrieve region, image, size and key ID's, you can use the corresponding tugboat command, such as `tugboat images`.")
|
45
44
|
expect($stdout.string).to include("Defaults can be changed at any time in your ~/.tugboat configuration file.")
|
46
45
|
|
47
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
48
|
-
|
49
46
|
config = YAML.load_file(tmp_path)
|
50
47
|
|
51
48
|
expect(config["defaults"]["image"]).to eq image
|
@@ -60,23 +57,24 @@ describe Tugboat::CLI do
|
|
60
57
|
end
|
61
58
|
|
62
59
|
it "sets defaults if no input given" do
|
60
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
61
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>/Bearer/, 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
62
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
63
63
|
|
64
64
|
expect($stdout).to receive(:print).exactly(6).times
|
65
|
-
expect($stdout).to receive(:print).with("Enter your
|
66
|
-
expect($stdin).to receive(:gets).and_return(
|
67
|
-
expect($stdout).to receive(:print).with("Enter your API key: ")
|
68
|
-
expect($stdin).to receive(:gets).and_return(api_key)
|
65
|
+
expect($stdout).to receive(:print).with("Enter your access token: ")
|
66
|
+
expect($stdin).to receive(:gets).and_return('')
|
69
67
|
expect($stdout).to receive(:print).with("Enter your SSH key path (optional, defaults to ~/.ssh/id_rsa): ")
|
70
|
-
expect($stdin).to receive(:gets).and_return(
|
68
|
+
expect($stdin).to receive(:gets).and_return('')
|
71
69
|
expect($stdout).to receive(:print).with("Enter your SSH user (optional, defaults to root): ")
|
72
70
|
expect($stdin).to receive(:gets).and_return('')
|
73
71
|
expect($stdout).to receive(:print).with("Enter your SSH port number (optional, defaults to 22): ")
|
74
72
|
expect($stdin).to receive(:gets).and_return('')
|
75
|
-
expect($stdout).to receive(:print).with("Enter your default region
|
73
|
+
expect($stdout).to receive(:print).with("Enter your default region (optional, defaults to nyc1): ")
|
76
74
|
expect($stdin).to receive(:gets).and_return('')
|
77
|
-
expect($stdout).to receive(:print).with("Enter your default image ID (optional, defaults to
|
75
|
+
expect($stdout).to receive(:print).with("Enter your default image ID or image slug (optional, defaults to ubuntu-14-04-x64): ")
|
78
76
|
expect($stdin).to receive(:gets).and_return('')
|
79
|
-
expect($stdout).to receive(:print).with("Enter your default size
|
77
|
+
expect($stdout).to receive(:print).with("Enter your default size (optional, defaults to 512mb)): ")
|
80
78
|
expect($stdin).to receive(:gets).and_return('')
|
81
79
|
expect($stdout).to receive(:print).with("Enter your default ssh key ID (optional, defaults to none): ")
|
82
80
|
expect($stdin).to receive(:gets).and_return('')
|
@@ -87,20 +85,17 @@ describe Tugboat::CLI do
|
|
87
85
|
|
88
86
|
@cli.authorize
|
89
87
|
|
90
|
-
expect($stdout.string).to include("Note: You can get
|
91
|
-
expect($stdout.string).to include("Also Note: Tugboat is setup to work with v1 of the Digital Ocean API (https://developers.digitalocean.com/v1/)")
|
88
|
+
expect($stdout.string).to include("Note: You can get your Access Token from https://cloud.digitalocean.com/settings/tokens/new")
|
92
89
|
expect($stdout.string).to include("To retrieve region, image, size and key ID's, you can use the corresponding tugboat command, such as `tugboat images`.")
|
93
90
|
expect($stdout.string).to include("Defaults can be changed at any time in your ~/.tugboat configuration file.")
|
94
91
|
|
95
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
96
|
-
|
97
92
|
config = YAML.load_file(tmp_path)
|
98
93
|
|
99
|
-
expect(config["defaults"]["image"]).to eq "
|
100
|
-
expect(config["defaults"]["region"]).to eq "
|
101
|
-
expect(config["defaults"]["size"]).to eq "
|
94
|
+
expect(config["defaults"]["image"]).to eq "ubuntu-14-04-x64"
|
95
|
+
expect(config["defaults"]["region"]).to eq "nyc2"
|
96
|
+
expect(config["defaults"]["size"]).to eq "512mb"
|
102
97
|
expect(config["ssh"]["ssh_user"]).to eq 'root'
|
103
|
-
expect(config["ssh"]["ssh_key_path"]).to eq "~/.ssh/
|
98
|
+
expect(config["ssh"]["ssh_key_path"]).to eq "~/.ssh/id_rsa"
|
104
99
|
expect(config["ssh"]["ssh_port"]).to eq "22"
|
105
100
|
expect(config["defaults"]["ssh_key"]).to eq ""
|
106
101
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tugboat::CLI do
|
4
|
+
include_context "spec"
|
5
|
+
|
6
|
+
describe "config" do
|
7
|
+
it "shows the full config" do
|
8
|
+
|
9
|
+
@cli.config
|
10
|
+
|
11
|
+
expect($stdout.string).to eq <<-eos
|
12
|
+
Current Config\x20
|
13
|
+
Path: #{Dir.pwd}/tmp/tugboat
|
14
|
+
---
|
15
|
+
authentication:
|
16
|
+
access_token: foo
|
17
|
+
ssh:
|
18
|
+
ssh_user: baz
|
19
|
+
ssh_key_path: ~/.ssh/id_rsa2
|
20
|
+
ssh_port: '33'
|
21
|
+
defaults:
|
22
|
+
region: nyc2
|
23
|
+
image: ubuntu-14-04-x64
|
24
|
+
size: 512mb
|
25
|
+
ssh_key: '1234'
|
26
|
+
private_networking: 'false'
|
27
|
+
backups_enabled: 'false'
|
28
|
+
eos
|
29
|
+
end
|
30
|
+
|
31
|
+
it "hides sensitive data if option given" do
|
32
|
+
|
33
|
+
@cli.options = @cli.options.merge(:hide => true)
|
34
|
+
@cli.config
|
35
|
+
|
36
|
+
expect($stdout.string).to eq <<-eos
|
37
|
+
Current Config (Keys Redacted)
|
38
|
+
Path: #{Dir.pwd}/tmp/tugboat
|
39
|
+
---
|
40
|
+
authentication:
|
41
|
+
access_token:\x20\x20[REDACTED]
|
42
|
+
ssh:
|
43
|
+
ssh_user: baz
|
44
|
+
ssh_key_path: ~/.ssh/id_rsa2
|
45
|
+
ssh_port: '33'
|
46
|
+
defaults:
|
47
|
+
region: nyc2
|
48
|
+
image: ubuntu-14-04-x64
|
49
|
+
size: 512mb
|
50
|
+
ssh_key: '1234'
|
51
|
+
private_networking: 'false'
|
52
|
+
backups_enabled: 'false'
|
53
|
+
eos
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/spec/cli/create_cli_spec.rb
CHANGED
@@ -5,47 +5,35 @@ describe Tugboat::CLI do
|
|
5
5
|
|
6
6
|
describe "create a droplet" do
|
7
7
|
it "with a name, uses defaults from configuration" do
|
8
|
-
stub_request(:
|
9
|
-
|
8
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
9
|
+
with(:body => "{\"name\":\"foo\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":null}",
|
10
|
+
: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'}).
|
11
|
+
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
10
12
|
|
11
13
|
@cli.create(droplet_name)
|
12
14
|
|
13
15
|
expect($stdout.string).to eq <<-eos
|
14
|
-
Queueing creation of droplet '#{droplet_name}'...
|
16
|
+
Queueing creation of droplet '#{droplet_name}'...Droplet created!
|
15
17
|
eos
|
16
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets/new?api_key=#{api_key}&client_id=#{client_key}&image_id=#{image}&name=#{droplet_name}&backups_enabled=#{backups_enabled}&private_networking=#{private_networking}®ion_id=#{region}&size_id=#{size}&ssh_key_ids=#{ssh_key_id}")).to have_been_made
|
17
18
|
end
|
18
19
|
|
19
20
|
it "with args does not use defaults from configuration" do
|
20
|
-
stub_request(:
|
21
|
-
|
21
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
22
|
+
with(:body => "{\"name\":\"example.com\",\"size\":\"1gb\",\"image\":\"ubuntu-12-04-x64\",\"region\":\"nyc3\",\"ssh_keys\":[\"foo_bar_key\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":null}",
|
23
|
+
: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'}).
|
24
|
+
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
22
25
|
|
23
|
-
@cli.options = @cli.options.merge(:image => '
|
24
|
-
@cli.create(
|
26
|
+
@cli.options = @cli.options.merge(:image => 'ubuntu-12-04-x64', :size => '1gb', :region => 'nyc3', :keys => 'foo_bar_key')
|
27
|
+
@cli.create('example.com')
|
25
28
|
|
26
29
|
expect($stdout.string).to eq <<-eos
|
27
|
-
Queueing creation of droplet '
|
30
|
+
Queueing creation of droplet 'example.com'...Droplet created!
|
28
31
|
eos
|
29
32
|
|
30
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets/new?api_key=#{api_key}&client_id=#{client_key}&image_id=555&name=foo&backups_enabled=#{backups_enabled}&private_networking=#{private_networking}®ion_id=3&size_id=666&ssh_key_ids=4321")).to have_been_made
|
31
33
|
end
|
32
34
|
|
33
35
|
it "doesn't create a droplet when mistyping help command" do
|
34
|
-
help_text =
|
35
|
-
Usage:
|
36
|
-
rspec create NAME
|
37
|
-
|
38
|
-
Options:
|
39
|
-
-s, [--size=N] # The size_id of the droplet
|
40
|
-
-i, [--image=N] # The image_id of the droplet
|
41
|
-
-r, [--region=N] # The region_id of the droplet
|
42
|
-
-k, [--keys=KEYS] # A comma separated list of SSH key ids to add to the droplet
|
43
|
-
-p, [--private-networking] # Enable private networking on the droplet
|
44
|
-
-b, [--backups-enabled] # Enable backups on the droplet
|
45
|
-
-q, [--quiet]
|
46
|
-
|
47
|
-
Create a droplet.
|
48
|
-
eos
|
36
|
+
help_text = "Usage:\n rspec create NAME\n\nOptions:\n -s, [--size=N] # The size_id of the droplet\n -i, [--image=N] # The image_id of the droplet\n -r, [--region=N] # The region_id of the droplet\n -k, [--keys=KEYS] # A comma separated list of SSH key ids to add to the droplet\n -p, [--private-networking] # Enable private networking on the droplet\n -b, [--backups-enabled] # Enable backups on the droplet\n -q, [--quiet] \n\nCreate a droplet.\n"
|
49
37
|
|
50
38
|
@cli.create('help')
|
51
39
|
expect($stdout.string).to eq help_text
|
@@ -58,13 +46,15 @@ eos
|
|
58
46
|
end
|
59
47
|
|
60
48
|
it "does not clobber named droplets that contain the word help" do
|
61
|
-
stub_request(:
|
62
|
-
|
49
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
50
|
+
with(:body => "{\"name\":\"somethingblahblah--help\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":null}",
|
51
|
+
: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
|
+
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
63
53
|
|
64
54
|
@cli.create('somethingblahblah--help')
|
65
55
|
|
66
56
|
expect($stdout.string).to eq <<-eos
|
67
|
-
Queueing creation of droplet 'somethingblahblah--help'...
|
57
|
+
Queueing creation of droplet 'somethingblahblah--help'...Droplet created!
|
68
58
|
eos
|
69
59
|
end
|
70
60
|
end
|
data/spec/cli/debug_cli_spec.rb
CHANGED
@@ -11,14 +11,11 @@ describe Tugboat::CLI do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "gives full faraday logs" do
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
pending 'Debug flag not avaliable yet'
|
15
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
16
|
+
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'}).
|
17
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
17
18
|
@cli.droplets
|
18
|
-
|
19
|
-
expect($stdout.string).to include('Response from https://api.digitalocean.com/droplets?client_id=foo&api_key=bar; Status: 200;')
|
20
|
-
|
21
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
22
19
|
end
|
23
20
|
end
|
24
21
|
|
@@ -30,14 +27,11 @@ describe Tugboat::CLI do
|
|
30
27
|
end
|
31
28
|
|
32
29
|
it "gives full faraday logs with redacted API keys" do
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
pending 'Debug flag not avaliable yet'
|
31
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
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 => {})
|
36
34
|
@cli.droplets
|
37
|
-
|
38
|
-
expect($stdout.string).to include('Response from https://api.digitalocean.com/droplets?client_id=[CLIENT-ID]&api_key=[API-KEY]; Status: 200;')
|
39
|
-
|
40
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -5,103 +5,92 @@ describe Tugboat::CLI do
|
|
5
5
|
|
6
6
|
describe "destroy" do
|
7
7
|
it "destroys a droplet with a fuzzy name" do
|
8
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
9
|
-
|
8
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
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 => {})
|
10
11
|
|
11
|
-
stub_request(:delete, "https://api.digitalocean.com/droplets/
|
12
|
-
|
12
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
|
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'}).
|
14
|
+
to_return(:status => 204, :body => "", :headers => {})
|
13
15
|
|
14
16
|
expect($stdin).to receive(:gets).and_return("y")
|
15
17
|
|
16
|
-
@cli.destroy("
|
18
|
+
@cli.destroy("example.com")
|
17
19
|
|
18
20
|
expect($stdout.string).to eq <<-eos
|
19
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
20
|
-
|
21
|
-
|
22
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
23
|
-
expect(a_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
21
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
|
22
|
+
eos
|
24
23
|
end
|
25
24
|
|
26
25
|
it "destroys a droplet with an id" do
|
27
|
-
stub_request(:get, "https://api.digitalocean.com/droplets
|
28
|
-
|
26
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
|
27
|
+
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
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
29
29
|
|
30
|
-
stub_request(:delete, "https://api.digitalocean.com/droplets/
|
31
|
-
|
30
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
|
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 => 204, :body => "", :headers => {})
|
32
33
|
|
33
34
|
expect($stdin).to receive(:gets).and_return("y")
|
34
35
|
|
35
|
-
@cli.options = @cli.options.merge(:id =>
|
36
|
+
@cli.options = @cli.options.merge(:id => '6918990')
|
36
37
|
@cli.destroy
|
37
38
|
|
38
39
|
expect($stdout.string).to eq <<-eos
|
39
|
-
Droplet id provided. Finding Droplet...done\e[0m,
|
40
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
|
40
41
|
eos
|
41
|
-
|
42
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
43
|
-
expect(a_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
44
42
|
end
|
45
43
|
|
46
44
|
|
47
45
|
it "destroys a droplet with a name" do
|
48
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
49
|
-
|
46
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
47
|
+
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
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
50
49
|
|
51
|
-
stub_request(:delete, "https://api.digitalocean.com/droplets/
|
52
|
-
|
50
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
|
51
|
+
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
|
+
to_return(:status => 204, :body => "", :headers => {})
|
53
53
|
|
54
54
|
expect($stdin).to receive(:gets).and_return("y")
|
55
55
|
|
56
|
-
@cli.options = @cli.options.merge(:name =>
|
56
|
+
@cli.options = @cli.options.merge(:name => 'example.com')
|
57
57
|
@cli.destroy
|
58
58
|
|
59
59
|
expect($stdout.string).to eq <<-eos
|
60
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
60
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
|
61
61
|
eos
|
62
|
-
|
63
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
64
|
-
expect(a_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
65
62
|
end
|
66
63
|
|
67
|
-
|
68
64
|
it "destroys a droplet with confirm flag set" do
|
69
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
70
|
-
|
65
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
66
|
+
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
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
71
68
|
|
72
|
-
stub_request(:delete, "https://api.digitalocean.com/droplets/
|
73
|
-
|
69
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
|
70
|
+
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'}).
|
71
|
+
to_return(:status => 204, :body => "", :headers => {})
|
74
72
|
|
75
|
-
@cli.options = @cli.options.merge(:name =>
|
76
|
-
@cli.options = @cli.options.merge(:confirm => true)
|
73
|
+
@cli.options = @cli.options.merge(:name => 'example.com', :confirm => true)
|
77
74
|
@cli.destroy
|
78
75
|
|
79
76
|
expect($stdout.string).to eq <<-eos
|
80
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
81
|
-
Queuing destroy for
|
77
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
78
|
+
Queuing destroy for 6918990 (example.com)...Deletion Successful!
|
82
79
|
eos
|
83
|
-
|
84
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
85
|
-
expect(a_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
86
80
|
end
|
87
81
|
|
88
82
|
it "does not destroy a droplet if no is chosen" do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
stub_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}").
|
93
|
-
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
83
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
84
|
+
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'}).
|
85
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
94
86
|
|
95
87
|
$stdin.should_receive(:gets).and_return("n")
|
96
88
|
|
97
|
-
expect {@cli.destroy("
|
89
|
+
expect {@cli.destroy("example.com")}.to raise_error(SystemExit)
|
98
90
|
|
99
91
|
expect($stdout.string).to eq <<-eos
|
100
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
92
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Aborted due to user request.
|
101
93
|
eos
|
102
|
-
|
103
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
104
|
-
expect(a_request(:delete, "https://api.digitalocean.com/droplets/100823/destroy?api_key=#{api_key}&client_id=#{client_key}")).to_not have_been_made
|
105
94
|
end
|
106
95
|
end
|
107
96
|
|
@@ -5,83 +5,77 @@ describe Tugboat::CLI do
|
|
5
5
|
|
6
6
|
describe "destroy image" do
|
7
7
|
it "destroys an image with a fuzzy name" do
|
8
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
9
|
-
|
8
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
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_images_global'), :headers => {})
|
10
11
|
|
11
|
-
stub_request(:
|
12
|
-
|
12
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
|
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'}).
|
14
|
+
to_return(:status => 204, :body => "", :headers => {})
|
13
15
|
|
14
16
|
expect($stdin).to receive(:gets).and_return("y")
|
15
17
|
|
16
|
-
@cli.destroy_image("
|
18
|
+
@cli.destroy_image("My application image")
|
17
19
|
|
18
20
|
expect($stdout.string).to eq <<-eos
|
19
|
-
Image fuzzy name provided. Finding image ID...done\e[0m,
|
21
|
+
Image fuzzy name provided. Finding image ID...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!
|
20
22
|
eos
|
21
|
-
|
22
|
-
expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
23
|
-
expect(a_request(:get, "https://api.digitalocean.com/images/478/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
24
23
|
end
|
25
24
|
|
26
25
|
it "destroys an image with an id" do
|
27
|
-
stub_request(:get, "https://api.digitalocean.com/images/
|
28
|
-
|
26
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images/6376601?per_page=200").
|
27
|
+
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
|
+
to_return(:status => 200, :body => fixture('show_image'), :headers => {})
|
29
29
|
|
30
|
-
stub_request(:
|
31
|
-
|
30
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
|
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 => 204, :body => "", :headers => {})
|
32
33
|
|
33
34
|
expect($stdin).to receive(:gets).and_return("y")
|
34
35
|
|
35
|
-
@cli.options = @cli.options.merge(:id =>
|
36
|
+
@cli.options = @cli.options.merge(:id => 6376601)
|
36
37
|
@cli.destroy_image
|
37
38
|
|
38
39
|
expect($stdout.string).to eq <<-eos
|
39
|
-
Image id provided. Finding Image...done\e[0m,
|
40
|
+
Image id provided. Finding Image...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!
|
40
41
|
eos
|
41
|
-
|
42
|
-
expect(a_request(:get, "https://api.digitalocean.com/images/478?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
43
|
-
expect(a_request(:get, "https://api.digitalocean.com/images/478/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
44
|
-
end
|
42
|
+
end
|
45
43
|
|
46
44
|
|
47
45
|
it "destroys an image with a name" do
|
48
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
49
|
-
|
46
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
47
|
+
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
|
+
to_return(:status => 200, :body => fixture('show_images_global'), :headers => {})
|
50
49
|
|
51
|
-
stub_request(:
|
52
|
-
|
50
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
|
51
|
+
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
|
+
to_return(:status => 204, :body => "", :headers => {})
|
53
53
|
|
54
54
|
expect($stdin).to receive(:gets).and_return("y")
|
55
55
|
|
56
|
-
@cli.options = @cli.options.merge(:name => "
|
56
|
+
@cli.options = @cli.options.merge(:name => "My application image")
|
57
57
|
@cli.destroy_image
|
58
58
|
|
59
|
-
expect($stdout.string).to eq
|
60
|
-
Image name provided. Finding image ID...done\e[0m, 478 (NLP Final)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 478 (NLP Final)...done
|
61
|
-
eos
|
62
|
-
|
63
|
-
expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
64
|
-
expect(a_request(:get, "https://api.digitalocean.com/images/478/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
59
|
+
expect($stdout.string).to eq "Image name provided. Finding Image...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!\n"
|
65
60
|
end
|
66
61
|
|
67
62
|
|
68
63
|
it "destroys an image with confirm flag set" do
|
69
|
-
|
70
|
-
|
64
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
65
|
+
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'}).
|
66
|
+
to_return(:status => 200, :body => fixture('show_images_global'), :headers => {})
|
71
67
|
|
72
|
-
stub_request(:
|
73
|
-
|
68
|
+
stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
|
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 => 204, :body => "", :headers => {})
|
74
71
|
|
75
|
-
@cli.options = @cli.options.merge(:name => "
|
72
|
+
@cli.options = @cli.options.merge(:name => "My application image")
|
76
73
|
@cli.options = @cli.options.merge(:confirm => true)
|
77
74
|
@cli.destroy_image("NLP Final")
|
78
75
|
|
79
76
|
expect($stdout.string).to eq <<-eos
|
80
|
-
Image name provided. Finding
|
77
|
+
Image name provided. Finding Image...done\e[0m, 6376601 (My application image)\nQueuing destroy image for 6376601 (My application image)...Image deletion successful!
|
81
78
|
eos
|
82
|
-
|
83
|
-
expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
84
|
-
expect(a_request(:get, "https://api.digitalocean.com/images/478/destroy?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
85
79
|
end
|
86
80
|
end
|
87
81
|
|