brightbox-cli 4.3.1 → 4.4.0

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.
@@ -36,7 +36,7 @@ describe "brightbox lbs" do
36
36
  .to_return(:status => 200, :body => '{"id":"lba-12345"}')
37
37
 
38
38
  stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-12345?account_id=acc-12345")
39
- .with(:body => hash_including("ssl_minimum_version" => "TLSv1.0"))
39
+ .with(:body => { ssl_minimum_version: "TLSv1.0" })
40
40
  .to_return(:status => 202, :body => json_response)
41
41
  end
42
42
 
@@ -45,5 +45,59 @@ describe "brightbox lbs" do
45
45
  expect(stdout).to include("lba-12345")
46
46
  end
47
47
  end
48
+
49
+ context "--sslv3" do
50
+ let(:argv) { ["lbs", "update", "--sslv3", "lba-grt24"] }
51
+
52
+ let(:json_response) do
53
+ <<-EOS
54
+ {
55
+ "id":"lba-grt24",
56
+ "ssl_minimum_version":"TLSv1.0"
57
+ }
58
+ EOS
59
+ end
60
+
61
+ before do
62
+ stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-grt24?account_id=acc-12345")
63
+ .to_return(:status => 200, :body => '{"id":"lba-grt24"}')
64
+
65
+ stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-grt24?account_id=acc-12345")
66
+ .with(:body => { sslv3: true })
67
+ .to_return(:status => 202, :body => json_response)
68
+ end
69
+
70
+ it "includes ssl_minimum_version in response" do
71
+ expect(stderr).to eq("Updating load balancer lba-grt24\n")
72
+ expect(stdout).to include("lba-grt24")
73
+ end
74
+ end
75
+
76
+ context "--no-sslv3" do
77
+ let(:argv) { ["lbs", "update", "--no-sslv3", "lba-kl432"] }
78
+
79
+ let(:json_response) do
80
+ <<-EOS
81
+ {
82
+ "id":"lba-kl432",
83
+ "ssl_minimum_version":"TLSv1.0"
84
+ }
85
+ EOS
86
+ end
87
+
88
+ before do
89
+ stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-kl432?account_id=acc-12345")
90
+ .to_return(:status => 200, :body => '{"id":"lba-kl432"}')
91
+
92
+ stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-kl432?account_id=acc-12345")
93
+ .with(:body => { sslv3: false })
94
+ .to_return(:status => 202, :body => json_response)
95
+ end
96
+
97
+ it "includes ssl_minimum_version in response" do
98
+ expect(stderr).to eq("Updating load balancer lba-kl432\n")
99
+ expect(stdout).to include("lba-kl432")
100
+ end
101
+ end
48
102
  end
49
103
  end
@@ -38,7 +38,10 @@ describe "brightbox servers" do
38
38
 
39
39
  it "does not error" do
40
40
  stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
41
- .with(:body => hash_including(image: "img-12345"))
41
+ .with(:body => {
42
+ image: "img-12345",
43
+ server_type: "typ-12345"
44
+ })
42
45
  .and_return(:status => 202, :body => sample_response)
43
46
 
44
47
  expect(stderr).not_to match("ERROR")
@@ -94,8 +97,12 @@ describe "brightbox servers" do
94
97
 
95
98
  it "requests new server with encryption at rest enabled" do
96
99
  stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
97
- .with(:headers => { "Content-Type" => "application/json" },
98
- :body => hash_including(:disk_encrypted => true))
100
+ .with(headers: { "Content-Type" => "application/json" },
101
+ body: {
102
+ disk_encrypted: true,
103
+ image: "img-12345",
104
+ server_type: "typ-12345"
105
+ })
99
106
  .and_return(:status => 202, :body => sample_response)
100
107
 
101
108
  expect(stderr).to match("Creating a nano")
@@ -1,17 +1,272 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "brightbox servers" do
4
- describe "update" do
5
- let(:output) { FauxIO.new { Brightbox.run(argv) } }
6
- let(:stdout) { output.stdout }
7
- let(:stderr) { output.stderr }
8
-
9
- context "" do
10
- let(:argv) { %w[servers update] }
11
-
12
- it "does not error" do
13
- expect { output }.to_not raise_error
14
- end
3
+ describe "brightbox servers update" do
4
+ let(:output) { FauxIO.new { Brightbox.run(argv) } }
5
+ let(:stdout) { output.stdout }
6
+ let(:stderr) { output.stderr }
7
+
8
+ before do
9
+ config_from_contents(API_CLIENT_CONFIG_CONTENTS)
10
+
11
+ stub_request(:post, "http://api.brightbox.localhost/token")
12
+ .to_return(
13
+ status: 200,
14
+ body: JSON.dump(
15
+ access_token: "ACCESS-TOKEN",
16
+ refresh_token: "REFRESH_TOKEN"
17
+ )
18
+ )
19
+
20
+ Brightbox.config.reauthenticate
21
+ end
22
+
23
+ context "without arguments" do
24
+ let(:argv) { %w[servers update] }
25
+
26
+ it "does not error" do
27
+ expect { output }.to_not raise_error
28
+
29
+ expect(stderr).to eq("ERROR: You must specify a valid server id as the first argument\n")
30
+
31
+ expect(stdout).to match("")
32
+ end
33
+ end
34
+
35
+ context "without options" do
36
+ let(:argv) { %w[servers update srv-klfkd] }
37
+
38
+ before do
39
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-klfkd?account_id=acc-12345")
40
+ .to_return(:status => 200, :body => {
41
+ id: "srv-klfkd",
42
+ server_type: {
43
+ id: "typ-12345"
44
+ },
45
+ cloud_ips: [],
46
+ interfaces: []
47
+ }.to_json)
48
+
49
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
50
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
51
+
52
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-klfkd?account_id=acc-12345")
53
+ .with(:body => {
54
+ compatibility_mode: false
55
+ })
56
+ .to_return(:status => 200, :body => {
57
+ id: "srv-klfkd",
58
+ server_type: {
59
+ id: "typ-12345"
60
+ },
61
+ cloud_ips: [],
62
+ interfaces: []
63
+ }.to_json)
64
+ end
65
+
66
+ it "does not error" do
67
+ expect { output }.to_not raise_error
68
+
69
+ expect(stderr).to eq("Updating server srv-klfkd\n")
70
+
71
+ expect(stdout).to match("srv-klfkd")
72
+ end
73
+ end
74
+
75
+ context "with --compatibility-mode" do
76
+ let(:argv) { %w[servers update --compatibility-mode srv-ds321] }
77
+
78
+ before do
79
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
80
+ .to_return(:status => 200, :body => {
81
+ id: "srv-ds321",
82
+ server_type: {
83
+ id: "typ-12345"
84
+ },
85
+ cloud_ips: [],
86
+ interfaces: []
87
+ }.to_json)
88
+
89
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
90
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
91
+
92
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
93
+ .with(:body => {})
94
+ .to_return(:status => 200, :body => {
95
+ id: "srv-ds321",
96
+ server_type: {
97
+ id: "typ-12345"
98
+ },
99
+ cloud_ips: [],
100
+ interfaces: []
101
+ }.to_json)
102
+ end
103
+
104
+ it "does not error" do
105
+ expect { output }.to_not raise_error
106
+
107
+ expect(stderr).to eq("Updating server srv-ds321\n")
108
+
109
+ expect(stdout).to match("srv-ds321")
110
+ end
111
+ end
112
+
113
+ context "with --no-compatibility-mode" do
114
+ let(:argv) { %w[servers update --no-compatibility-mode srv-ds321] }
115
+
116
+ before do
117
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
118
+ .to_return(:status => 200, :body => {
119
+ id: "srv-ds321",
120
+ server_type: {
121
+ id: "typ-12345"
122
+ },
123
+ cloud_ips: [],
124
+ interfaces: []
125
+ }.to_json)
126
+
127
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
128
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
129
+
130
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
131
+ .with(:body => {
132
+ compatibility_mode: false
133
+ })
134
+ .to_return(:status => 200, :body => {
135
+ id: "srv-ds321",
136
+ server_type: {
137
+ id: "typ-12345"
138
+ },
139
+ cloud_ips: [],
140
+ interfaces: []
141
+ }.to_json)
142
+ end
143
+
144
+ it "does not error" do
145
+ expect { output }.to_not raise_error
146
+
147
+ expect(stderr).to eq("Updating server srv-ds321\n")
148
+
149
+ expect(stdout).to match("srv-ds321")
150
+ end
151
+ end
152
+
153
+ context "with --base64" do
154
+ let(:argv) { %w[servers update --base64 srv-ds321] }
155
+
156
+ before do
157
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
158
+ .to_return(:status => 200, :body => {
159
+ id: "srv-ds321",
160
+ server_type: {
161
+ id: "typ-12345"
162
+ },
163
+ cloud_ips: [],
164
+ interfaces: []
165
+ }.to_json)
166
+
167
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
168
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
169
+
170
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
171
+ .with(:body => {
172
+ compatibility_mode: false
173
+ })
174
+ .to_return(:status => 200, :body => {
175
+ id: "srv-ds321",
176
+ server_type: {
177
+ id: "typ-12345"
178
+ },
179
+ cloud_ips: [],
180
+ interfaces: []
181
+ }.to_json)
182
+ end
183
+
184
+ it "does not error" do
185
+ expect { output }.to_not raise_error
186
+
187
+ expect(stderr).to eq("Updating server srv-ds321\n")
188
+
189
+ expect(stdout).to match("srv-ds321")
190
+ end
191
+ end
192
+
193
+ context "with --base64 --user-data" do
194
+ let(:argv) { %w[servers update --base64 --user-data hello srv-ds321] }
195
+
196
+ before do
197
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
198
+ .to_return(:status => 200, :body => {
199
+ id: "srv-ds321",
200
+ server_type: {
201
+ id: "typ-12345"
202
+ },
203
+ cloud_ips: [],
204
+ interfaces: []
205
+ }.to_json)
206
+
207
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
208
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
209
+
210
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
211
+ .with(:body => {
212
+ user_data: "aGVsbG8=\n"
213
+ })
214
+ .to_return(:status => 200, :body => {
215
+ id: "srv-ds321",
216
+ server_type: {
217
+ id: "typ-12345"
218
+ },
219
+ cloud_ips: [],
220
+ interfaces: []
221
+ }.to_json)
222
+ end
223
+
224
+ it "does not error" do
225
+ expect { output }.to_not raise_error
226
+
227
+ expect(stderr).to eq("Updating server srv-ds321 with 0.01k of user data\n")
228
+
229
+ expect(stdout).to match("srv-ds321")
230
+ end
231
+ end
232
+
233
+ context "with --no-base64 --user-data" do
234
+ let(:argv) { %w[servers update --no-base64 --user-data hello srv-ds321] }
235
+
236
+ before do
237
+ stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
238
+ .to_return(:status => 200, :body => {
239
+ id: "srv-ds321",
240
+ server_type: {
241
+ id: "typ-12345"
242
+ },
243
+ cloud_ips: [],
244
+ interfaces: []
245
+ }.to_json)
246
+
247
+ stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
248
+ .to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
249
+
250
+ stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
251
+ .with(:body => {
252
+ user_data: "hello"
253
+ })
254
+ .to_return(:status => 200, :body => {
255
+ id: "srv-ds321",
256
+ server_type: {
257
+ id: "typ-12345"
258
+ },
259
+ cloud_ips: [],
260
+ interfaces: []
261
+ }.to_json)
262
+ end
263
+
264
+ it "does not error" do
265
+ expect { output }.to_not raise_error
266
+
267
+ expect(stderr).to eq("Updating server srv-ds321 with 0.00k of user data\n")
268
+
269
+ expect(stdout).to match("srv-ds321")
15
270
  end
16
271
  end
17
272
  end
@@ -26,7 +26,7 @@ describe "brightbox sql instances" do
26
26
  "maintenance_hour":6}')
27
27
 
28
28
  stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
29
- .with(:body => "{\"maintenance_weekday\":\"1\"}")
29
+ .with(body: { maintenance_weekday: "1" }.to_json)
30
30
  end
31
31
 
32
32
  it "sets custom maintenance window settings" do
@@ -46,6 +46,7 @@ describe "brightbox sql instances" do
46
46
  .to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
47
47
 
48
48
  stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
49
+ .with(body: { snapshots_schedule: "0 12 * * 4" }.to_json)
49
50
  .to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
50
51
  end
51
52
 
@@ -59,25 +60,26 @@ describe "brightbox sql instances" do
59
60
  end
60
61
 
61
62
  context "--remove-snapshots-schedule" do
62
- let(:dbs) { Brightbox::DatabaseServer.find("dbs-12345") }
63
- let(:argv) { %w[sql instances update --remove-snapshots-schedule dbs-12345] }
63
+ let(:dbs) { Brightbox::DatabaseServer.find("dbs-432sf") }
64
+ let(:argv) { %w[sql instances update --remove-snapshots-schedule dbs-432sf] }
64
65
  let(:expected_args) { { :snapshots_schedule => nil } }
65
66
 
66
67
  before do
67
- stub_request(:get, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
68
- .to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
69
- .to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
68
+ stub_request(:get, "http://api.brightbox.localhost/1.0/database_servers/dbs-432sf?account_id=acc-12345")
69
+ .to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
70
+ .to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
70
71
 
71
- stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
72
- .to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
72
+ stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-432sf?account_id=acc-12345")
73
+ .with(body: { snapshots_schedule: nil }.to_json)
74
+ .to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
73
75
  end
74
76
 
75
77
  it "clears snapshots schedule" do
76
78
  expect(Brightbox::DatabaseServer).to receive(:find).and_return(dbs)
77
79
  expect(dbs).to receive(:update).with(expected_args).and_call_original
78
80
 
79
- expect(stderr).to eq("Updating dbs-12345\n")
80
- expect(stdout).to include("dbs-12345")
81
+ expect(stderr).to eq("Updating dbs-432sf\n")
82
+ expect(stdout).to include("dbs-432sf")
81
83
  end
82
84
  end
83
85
  end
@@ -46,7 +46,6 @@ describe "brightbox volumes update" do
46
46
  id: "vol-908us",
47
47
  name: "Old",
48
48
  description: nil,
49
- delete_with_server: true,
50
49
  serial: "vol-908us"
51
50
  )
52
51
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 1.9.1
20
+ version: 1.10.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 1.9.1
27
+ version: 1.10.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: fog-core
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +318,7 @@ files:
318
318
  - lib/brightbox-cli/commands/config/client_list.rb
319
319
  - lib/brightbox-cli/commands/config/client_remove.rb
320
320
  - lib/brightbox-cli/commands/config/user_add.rb
321
+ - lib/brightbox-cli/commands/configmaps.rb
321
322
  - lib/brightbox-cli/commands/firewall/policies_apply.rb
322
323
  - lib/brightbox-cli/commands/firewall/policies_create.rb
323
324
  - lib/brightbox-cli/commands/firewall/policies_destroy.rb
@@ -412,6 +413,7 @@ files:
412
413
  - lib/brightbox-cli/config/two_factor_auth.rb
413
414
  - lib/brightbox-cli/config/two_factor_helper.rb
414
415
  - lib/brightbox-cli/config/user_application.rb
416
+ - lib/brightbox-cli/config_map.rb
415
417
  - lib/brightbox-cli/connection_manager.rb
416
418
  - lib/brightbox-cli/database_server.rb
417
419
  - lib/brightbox-cli/database_snapshot.rb
@@ -451,6 +453,7 @@ files:
451
453
  - lib/brightbox-cli/zones.rb
452
454
  - lib/brightbox/cli/config.rb
453
455
  - lib/brightbox_cli.rb
456
+ - lib/gli_patches.rb
454
457
  - locales/en.yml
455
458
  - spec/brightbox_spec.rb
456
459
  - spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_a_collection_of_Accounts.yml
@@ -597,6 +600,11 @@ files:
597
600
  - spec/commands/config/client_list_spec.rb
598
601
  - spec/commands/config/client_remove_spec.rb
599
602
  - spec/commands/config/user_add_spec.rb
603
+ - spec/commands/configmaps/create_spec.rb
604
+ - spec/commands/configmaps/destroy_spec.rb
605
+ - spec/commands/configmaps/list_spec.rb
606
+ - spec/commands/configmaps/show_spec.rb
607
+ - spec/commands/configmaps/update_spec.rb
600
608
  - spec/commands/firewall_policies/update_spec.rb
601
609
  - spec/commands/groups/add_server_spec.rb
602
610
  - spec/commands/groups/create_spec.rb
@@ -959,6 +967,11 @@ test_files:
959
967
  - spec/commands/config/client_list_spec.rb
960
968
  - spec/commands/config/client_remove_spec.rb
961
969
  - spec/commands/config/user_add_spec.rb
970
+ - spec/commands/configmaps/create_spec.rb
971
+ - spec/commands/configmaps/destroy_spec.rb
972
+ - spec/commands/configmaps/list_spec.rb
973
+ - spec/commands/configmaps/show_spec.rb
974
+ - spec/commands/configmaps/update_spec.rb
962
975
  - spec/commands/firewall_policies/update_spec.rb
963
976
  - spec/commands/groups/add_server_spec.rb
964
977
  - spec/commands/groups/create_spec.rb