brightbox-cli 3.0.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5b05513e19a2b2086a60adcdcc9db34da763ea57057fe3cd4565f13d996325
4
- data.tar.gz: 2330375316fccfb4681d2eafd793070821ac58e8af68d73c9b8370301a4ecd43
3
+ metadata.gz: 881d758fc2932375edc56797f613f757a7f83729087cf2335a44736f4554fe1d
4
+ data.tar.gz: cfb933331637277089d47a0feccf9456e18b45f0a248aa27f233c52f24ba2f61
5
5
  SHA512:
6
- metadata.gz: a2b9f70e55d3ac5273a6179ff17bd10f5c99d75c628d67dfd671413d657717d34f00a8ecbbb1397b952b56ed34b55249e836c09417c32b69eebcb677877b941e
7
- data.tar.gz: de89095e13e79781b3c04828a4e20e1150056a4e3f838fa19923f949741c332cbeb4bb4b46b38566f2a7dc2b6e76b893cd658963b5194b33f7a79674cf650314
6
+ metadata.gz: a7b28703cc70a953b900f0caabaf036ff78c1e914810fcba9523b7f8b44ae5c7d148ee09f08d073d71449b587024f7d64ead1f88a659c3a2d2a52c502134d23a
7
+ data.tar.gz: ea62fcbe6b909e8b7cb8744da7acacd50c75bcb0c109fada221ef135ff1c1ac0d88dc01d8975ef3a8068c75e86956ce244ab88abc641e2dc3d79ed474502e59d
@@ -0,0 +1,36 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ strategy:
22
+ matrix:
23
+ ruby: ["2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "3.0"]
24
+
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Set up Ruby ${{ matrix.ruby }}
28
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
29
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ - name: Install dependencies
34
+ run: bundle install
35
+ - name: Run tests
36
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,53 @@
1
+ ### v3.3.0 / 2021-09-17
2
+
3
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.2.0...v3.3.0)
4
+
5
+ Changes:
6
+
7
+ * Update `fog-brightbox` to v1.4.0` (allowing Ruby 3.0 support)
8
+ * Added support for getting 2FA from helper
9
+ * Added missing `sql snapshot` fields
10
+ * Infrastructure changes to test on more versions of Ruby
11
+ * Added GitHub actions support for CI testing.
12
+ * Removed Travis CI support.
13
+
14
+ Bug fixes:
15
+
16
+ * Updates `crack` gem to switch from `safe_yaml` to `rexml`
17
+ * Bump addressable from 2.3.8 to 2.8.0. (fixing ReDoS vulnerability)
18
+ * Bump rexml from 3.2.4 to 3.2.5 (fixing round-trip vulnerability bugs)
19
+
20
+ ### v3.2.0 / 2020-11-26
21
+
22
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.1.0...v3.2.0)
23
+
24
+ Changes:
25
+
26
+ * Add `--disk-encrypted` option to server creation to allow enabling encryption
27
+ at rest during a build.
28
+ * Setup GitHub Actions for Ruby 2.4+ builds to reduce the delays of testing
29
+ using Travis.
30
+ * Reduce number of Travis builds due to incredibly slow start up times. We are
31
+ approaching an hour to get a build taking less than a minute starting.
32
+
33
+ ### v3.1.0 / 2020-11-17
34
+
35
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.0.1...v3.1.0)
36
+
37
+ Changes:
38
+
39
+ * Update `fog-brightbox` to v1.2.0
40
+ * Add `lbs` option for `--min-ssl-ver` to specify the minimum TLS/SSL protocol
41
+ that should be acceptable for use with the load balancer
42
+
43
+ ### v3.0.1 / 2020-07-01
44
+
45
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.0.0...v3.0.1)
46
+
47
+ Bug fixes:
48
+
49
+ * Fix `cloudips update --name` to correctly set blank names
50
+
1
51
  ### v3.0.0 / 2020-07-01
2
52
 
3
53
  [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v2.12.0...v3.0.0)
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightbox-cli (3.0.0)
4
+ brightbox-cli (3.3.0)
5
5
  dry-inflector (< 0.2)
6
- fog-brightbox (>= 1.1.0)
6
+ fog-brightbox (>= 1.3.0)
7
7
  fog-core (< 2.0)
8
8
  gli (~> 2.12.0)
9
9
  highline (~> 1.6.0)
@@ -15,15 +15,16 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- addressable (2.3.8)
18
+ addressable (2.8.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
19
20
  builder (3.2.4)
20
21
  coderay (1.0.9)
21
- crack (0.4.2)
22
- safe_yaml (~> 1.0.0)
22
+ crack (0.4.5)
23
+ rexml
23
24
  diff-lcs (1.4.3)
24
25
  dry-inflector (0.1.2)
25
- excon (0.75.0)
26
- fog-brightbox (1.1.0)
26
+ excon (0.79.0)
27
+ fog-brightbox (1.4.0)
27
28
  dry-inflector
28
29
  fog-core (>= 1.45, < 3.0)
29
30
  fog-json
@@ -52,7 +53,9 @@ GEM
52
53
  pry-remote (0.1.8)
53
54
  pry (~> 0.9)
54
55
  slop (~> 3.0)
56
+ public_suffix (2.0.5)
55
57
  rake (12.3.3)
58
+ rexml (3.2.5)
56
59
  rspec (3.9.0)
57
60
  rspec-core (~> 3.9.0)
58
61
  rspec-expectations (~> 3.9.0)
@@ -66,7 +69,6 @@ GEM
66
69
  diff-lcs (>= 1.2.0, < 2.0)
67
70
  rspec-support (~> 3.9.0)
68
71
  rspec-support (3.9.3)
69
- safe_yaml (1.0.4)
70
72
  slop (3.4.5)
71
73
  vcr (2.5.0)
72
74
  webmock (1.21.0)
data/Jenkinsfile CHANGED
@@ -17,7 +17,7 @@ pipeline {
17
17
  }
18
18
  steps {
19
19
  sh 'bundle install --deployment'
20
- sh 'bundle exec rake test'
20
+ sh 'bundle exec rake spec'
21
21
  }
22
22
  }
23
23
  stage("Ruby 2.1") {
@@ -28,7 +28,7 @@ pipeline {
28
28
  }
29
29
  steps {
30
30
  sh 'bundle install --deployment'
31
- sh 'bundle exec rake test'
31
+ sh 'bundle exec rake spec'
32
32
  }
33
33
  }
34
34
  stage("Ruby 2.2") {
@@ -39,7 +39,7 @@ pipeline {
39
39
  }
40
40
  steps {
41
41
  sh 'bundle install --deployment'
42
- sh 'bundle exec rake test'
42
+ sh 'bundle exec rake spec'
43
43
  }
44
44
  }
45
45
  stage("Ruby 2.3") {
@@ -50,7 +50,7 @@ pipeline {
50
50
  }
51
51
  steps {
52
52
  sh 'bundle install --deployment'
53
- sh 'bundle exec rake test'
53
+ sh 'bundle exec rake spec'
54
54
  }
55
55
  }
56
56
  stage("Ruby 2.4") {
@@ -61,7 +61,7 @@ pipeline {
61
61
  }
62
62
  steps {
63
63
  sh 'bundle install --deployment'
64
- sh 'bundle exec rake test'
64
+ sh 'bundle exec rake spec'
65
65
  }
66
66
  }
67
67
  stage("Ruby 2.5") {
@@ -72,7 +72,7 @@ pipeline {
72
72
  }
73
73
  steps {
74
74
  sh 'bundle install --deployment'
75
- sh 'bundle exec rake test'
75
+ sh 'bundle exec rake spec'
76
76
  }
77
77
  }
78
78
  stage("Ruby 2.6") {
@@ -83,7 +83,7 @@ pipeline {
83
83
  }
84
84
  steps {
85
85
  sh 'bundle install --deployment'
86
- sh 'bundle exec rake test'
86
+ sh 'bundle exec rake spec'
87
87
  }
88
88
  }
89
89
  }
data/README CHANGED
@@ -9,17 +9,6 @@ You can sign up at https://manage.brightbox.com
9
9
 
10
10
  {<img src="https://travis-ci.org/brightbox/brightbox-cli.png?branch=master" alt="Build Status" />}[https://travis-ci.org/brightbox/brightbox-cli]
11
11
 
12
- == UPGRADE NOTES
13
-
14
- Version 1.0.0 adds a new top level `brightbox` command for the suite.
15
-
16
- This may clash with our `brightbox` (brightbox-deployment) gem which, before
17
- version 2.4.0, used `brightbox` as the name for it's binary. Please ensure you
18
- update your `brightbox` gem to avoid using the wrong command.
19
-
20
- We have included backwards compatible binaries for all the older CLI commands
21
- (brightbox-accounts, brightbox-servers etc...) but recommend getting used to the
22
- new form.
23
12
 
24
13
  == Installation instructions
25
14
 
@@ -36,7 +25,11 @@ For a list of available commands use:
36
25
 
37
26
  $ brightbox help
38
27
 
39
- To add client (account based) credentials use:
28
+ To login with your user credentials use:
29
+
30
+ $ brightbox login john@example.com
31
+
32
+ To instead add api client (account-specific) credentials use:
40
33
 
41
34
  $ brightbox config client_add cli-2igtb theclientsecret
42
35
  Using config file /home/ubuntu/.brightbox/config
@@ -49,7 +42,14 @@ To browse available resources use the resource name as the command:
49
42
  $ brightbox images
50
43
  ... List of images
51
44
 
52
- Command structure may be subject to change.
45
+ === Two factor authentication ===
46
+
47
+ If you've enabled two factor authentication for your user, you can enable it in
48
+ your config and the CLI will prompt for a two factor pin when needed:
49
+
50
+ [john@example.com]
51
+ username = john@example.com
52
+ two_factor = true
53
53
 
54
54
  === Integrating with a password manager
55
55
 
@@ -64,6 +64,13 @@ appropriate section:
64
64
  username = john@example.com
65
65
  password_helper_command = pass john-example-com-brightbox
66
66
 
67
+ You can also specify a separate helper command to retrive two factor pins:
68
+
69
+ [john@example.com]
70
+ username = john@example.com
71
+ password_helper_command = pass john-example-com-brightbox
72
+ two_factor_helper_command = get-two-factor-pin john-example-com-brightbox
73
+
67
74
  === Using GPG to secure passwords
68
75
 
69
76
  If you use an OAuth application to access your accounts
@@ -108,6 +115,20 @@ incorrectly or there may be an issue with your GPG configuration.
108
115
 
109
116
  To remove the password delete the `~/.brightbox/main.password.gpg` file.
110
117
 
118
+ === Integrating with a password manager
119
+
120
+ You can retrieve your passwords from an external password manager by specifying
121
+ a password helper command. This command will be executed any time your password
122
+ is required and its output used as your password.
123
+
124
+ Configure the command in your config file (usually ~/.brightbox/config) in the
125
+ appropriate section:
126
+
127
+ [john@example.com]
128
+ username = john@example.com
129
+ password_helper_command = pass john-example-com-brightbox
130
+
131
+
111
132
  == Usage guides
112
133
 
113
134
  * http://docs.brightbox.com/reference/cli
@@ -130,6 +151,18 @@ in the path, just specify the full path to it:
130
151
 
131
152
  complete -C /full/path/to/bin/_brightbox-bash-completer -o filenames brightbox
132
153
 
154
+ == UPGRADE NOTES
155
+
156
+ Version 1.0.0 adds a new top level `brightbox` command for the suite.
157
+
158
+ This may clash with our `brightbox` (brightbox-deployment) gem which, before
159
+ version 2.4.0, used `brightbox` as the name for it's binary. Please ensure you
160
+ update your `brightbox` gem to avoid using the wrong command.
161
+
162
+ We have included backwards compatible binaries for all the older CLI commands
163
+ (brightbox-accounts, brightbox-servers etc...) but recommend getting used to the
164
+ new form.
165
+
133
166
  == Testing
134
167
 
135
168
  You should be able to run the specs and features with the following steps:
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_dependency "fog-brightbox", ">= 1.1.0"
24
+ s.add_dependency "fog-brightbox", ">= 1.3.0"
25
25
  s.add_dependency "fog-core", "< 2.0"
26
26
  s.add_dependency "gli", "~> 2.12.0"
27
27
  s.add_dependency "i18n", "~> 0.6.0"
@@ -75,7 +75,7 @@ module Brightbox
75
75
  params[:reverse_dns] = ""
76
76
  end
77
77
 
78
- if options[:n] && !options[:name].empty?
78
+ if options[:n] && !options[:n].nil?
79
79
  params[:name] = options[:n]
80
80
  end
81
81
 
@@ -52,6 +52,10 @@ module Brightbox
52
52
  c.desc "Filepath to the private key used to sign SSL certificate (OpenSSL supported formats)."
53
53
  c.flag ["ssl-key"]
54
54
 
55
+ c.desc "Sets the minimum version of TLS/SSL to support in the format 'TLSv1.x'"
56
+ c.default_value "TLSv1.2"
57
+ c.flag ["ssl-min-ver"]
58
+
55
59
  c.desc "Enable SSL v3 support"
56
60
  c.switch ["sslv3"]
57
61
 
@@ -118,6 +122,7 @@ module Brightbox
118
122
  :listeners => listeners,
119
123
  :certificate_pem => ssl_cert,
120
124
  :certificate_private_key => ssl_key,
125
+ :ssl_minimum_version => options["ssl-min-ver"],
121
126
  :sslv3 => options["sslv3"],
122
127
  :nodes => nodes)
123
128
  render_table([lb], global_options)
@@ -18,6 +18,7 @@ module Brightbox
18
18
  :created_at,
19
19
  :deleted_at,
20
20
  :policy,
21
+ :ssl_minimum_version,
21
22
  :ssl_issuer,
22
23
  :ssl_subject,
23
24
  :ssl_valid_from,
@@ -45,6 +45,9 @@ module Brightbox
45
45
  c.desc "Filepath to the private key used to sign SSL certificate (OpenSSL supported formats)."
46
46
  c.flag ["ssl-key"]
47
47
 
48
+ c.desc "Sets the minimum version of TLS/SSL to support in the format 'TLSv1.x'"
49
+ c.flag ["ssl-min-ver"]
50
+
48
51
  c.desc "Clears SSL details from the load balancer."
49
52
  c.switch ["remove-ssl"], :negatable => false
50
53
 
@@ -128,6 +131,10 @@ module Brightbox
128
131
  lbopts[:certificate_private_key] = ""
129
132
  end
130
133
 
134
+ if options["ssl-min-ver"]
135
+ lbopts[:ssl_minimum_version] = options["ssl-min-ver"] unless options["ssl-min-ver"].nil?
136
+ end
137
+
131
138
  lbopts.nilify_blanks
132
139
 
133
140
  lb = LoadBalancer.find lb_id
@@ -29,6 +29,10 @@ module Brightbox
29
29
  c.default_value true
30
30
  c.switch [:e, :base64], :negatable => true
31
31
 
32
+ c.desc "Enable encryption at rest for disk"
33
+ c.default_value false
34
+ c.switch ["disk-encrypted"], :negatable => false
35
+
32
36
  c.desc "Server groups to place server in - comma delimited list"
33
37
  c.flag [:g, "server-groups"]
34
38
 
@@ -116,6 +120,7 @@ module Brightbox
116
120
  }
117
121
 
118
122
  params[:cloud_ip] = options[:"cloud-ip"] if options.key?(:"cloud-ip")
123
+ params[:disk_encrypted] = options[:"disk-encrypted"] if options.key?(:"disk-encrypted")
119
124
 
120
125
  servers = Server.create_servers options[:i], params
121
126
  render_table(servers, global_options)
@@ -21,8 +21,13 @@ module Brightbox
21
21
  :name,
22
22
  :description,
23
23
  :status,
24
+ :database_engine,
25
+ :database_version,
24
26
  :locked,
25
- :created_on
27
+ :created_on,
28
+ :created_at,
29
+ :size,
30
+ :source
26
31
  ]
27
32
  )
28
33
  render_table(servers, table_opts)
@@ -17,7 +17,10 @@ module Brightbox
17
17
  end
18
18
 
19
19
  def two_factor_pin
20
- @two_factor_pin ||= prompt_for_two_factor_pin if two_factor_enabled
20
+ if two_factor_enabled
21
+ @two_factor_pin ||= Brightbox.config.two_factor_helper_password
22
+ @two_factor_pin ||= prompt_for_two_factor_pin
23
+ end
21
24
  end
22
25
 
23
26
  def prompt_for_two_factor_pin
@@ -0,0 +1,38 @@
1
+ module Brightbox
2
+ module Config
3
+ module TwoFactorHelper
4
+ attr_accessor :two_factor_helper_password
5
+
6
+ def two_factor_helper_command
7
+ return config[client_name]["two_factor_helper_command"] unless client_name.nil?
8
+ end
9
+
10
+ # Return the two_factor code from the helper if it's possible
11
+ def two_factor_helper_password
12
+ if defined?(@two_factor_helper_password) && !@two_factor_helper_password.nil?
13
+ return @two_factor_helper_password
14
+ end
15
+
16
+ if two_factor_helper_command
17
+ @two_factor_helper_password = two_factor_helper_call
18
+ else
19
+ @two_factor_helper_password = nil
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def two_factor_helper_call
26
+ info "INFO: Calling two factor helper to obtain two factor"
27
+ begin
28
+ cmd = two_factor_helper_command.split(/\s+/)
29
+ IO.popen(cmd, "r") do |io|
30
+ io.readline.chomp
31
+ end
32
+ rescue Errno::ENOENT
33
+ nil
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -15,6 +15,7 @@ module Brightbox
15
15
  include Brightbox::Config::GpgEncryptedPasswords
16
16
  include Brightbox::Config::PasswordHelper
17
17
  include Brightbox::Config::TwoFactorAuth
18
+ include Brightbox::Config::TwoFactorHelper
18
19
  include Brightbox::Config::AuthenticationTokens
19
20
  include Brightbox::Config::Accounts
20
21
  include Brightbox::Config::Clients
@@ -23,7 +23,7 @@ module Brightbox
23
23
  end
24
24
 
25
25
  def self.default_field_order
26
- [:id, :status, :created_on, :name]
26
+ [:id, :status, :created_on, :size, :name]
27
27
  end
28
28
 
29
29
  def to_row
@@ -49,6 +49,7 @@ module Brightbox
49
49
  :ram,
50
50
  :cores,
51
51
  :disk,
52
+ :disk_encrypted,
52
53
  :compatibility_mode,
53
54
  :image,
54
55
  :image_name,
@@ -12,6 +12,7 @@ module Brightbox
12
12
  def to_row
13
13
  attributes.merge(
14
14
  :locked => locked?,
15
+ :ssl_minimum_version => ssl_minimum_version,
15
16
  :ssl_issuer => certificate_issuer,
16
17
  :ssl_subject => certificate_subject,
17
18
  :ssl_valid_from => certificate_valid_from,
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "3.0.0" unless defined?(Brightbox::VERSION)
2
+ VERSION = "3.3.0" unless defined?(Brightbox::VERSION)
3
3
  end
data/lib/brightbox_cli.rb CHANGED
@@ -73,6 +73,7 @@ require_relative "brightbox-cli/config/cache"
73
73
  require_relative "brightbox-cli/config/gpg_encrypted_passwords"
74
74
  require_relative "brightbox-cli/config/password_helper"
75
75
  require_relative "brightbox-cli/config/two_factor_auth"
76
+ require_relative "brightbox-cli/config/two_factor_helper"
76
77
  require_relative "brightbox-cli/config/authentication_tokens"
77
78
  require_relative "brightbox-cli/config/accounts"
78
79
  require_relative "brightbox-cli/config/clients"
@@ -7,6 +7,13 @@ describe "brightbox cloudips" do
7
7
  let(:stdout) { output.stdout }
8
8
  let(:stderr) { output.stderr }
9
9
 
10
+ before do
11
+ config_from_contents(USER_APP_CONFIG_CONTENTS)
12
+
13
+ stub_request(:post, "http://api.brightbox.dev/token").
14
+ to_return(status: 200, body: JSON.dump(access_token: "ACCESS-TOKEN", refresh_token: "REFRESH-TOKEN"))
15
+ end
16
+
10
17
  context "" do
11
18
  let(:argv) { %w(cloudips update) }
12
19
 
@@ -14,5 +21,63 @@ describe "brightbox cloudips" do
14
21
  expect { output }.to_not raise_error
15
22
  end
16
23
  end
24
+
25
+ context "when name is updated" do
26
+ let(:argv) { ["cloudips", "update", "--name=#{new_name}", "cip-12345"] }
27
+
28
+ let(:json_response) do
29
+ <<-EOS
30
+ {
31
+ "id":"cip-12345",
32
+ "name":"#{new_name}"
33
+ }
34
+ EOS
35
+ end
36
+
37
+ context "--name 'New name'" do
38
+ let(:new_name) { "New name" }
39
+ let(:expected_args) { ["cip-12345", { :name => new_name }] }
40
+
41
+ before do
42
+ stub_request(:put, "http://api.brightbox.dev/1.0/cloud_ips/cip-12345?account_id=acc-12345")
43
+ .with(:headers => { "Content-Type" => "application/json" },
44
+ :body => hash_including("name" => "New name"))
45
+ .and_return(:status => 200, :body => json_response)
46
+
47
+ stub_request(:get, "http://api.brightbox.dev/1.0/cloud_ips/cip-12345?account_id=acc-12345")
48
+ .with(:headers => { "Content-Type" => "application/json" })
49
+ .and_return(:status => 200, :body => json_response)
50
+ end
51
+
52
+ it "puts new name in update" do
53
+ expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
54
+ expect(stderr).to eq("")
55
+ expect(stdout).to include("cip-12345")
56
+ expect(stdout).to include("New name")
57
+ end
58
+ end
59
+
60
+ context "--name ''" do
61
+ let(:new_name) { "" }
62
+ let(:expected_args) { ["cip-12345", { :name => "" }] }
63
+
64
+ before do
65
+ stub_request(:put, "http://api.brightbox.dev/1.0/cloud_ips/cip-12345?account_id=acc-12345")
66
+ .with(:headers => { "Content-Type" => "application/json" },
67
+ :body => hash_including("name" => ""))
68
+ .and_return(:status => 200, :body => json_response)
69
+
70
+ stub_request(:get, "http://api.brightbox.dev/1.0/cloud_ips/cip-12345?account_id=acc-12345")
71
+ .with(:headers => { "Content-Type" => "application/json" })
72
+ .and_return(:status => 200, :body => json_response)
73
+ end
74
+
75
+ it "puts new name in update" do
76
+ expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
77
+ expect(stderr).to eq("")
78
+ expect(stdout).to include("cip-12345")
79
+ end
80
+ end
81
+ end
17
82
  end
18
83
  end
@@ -7,6 +7,11 @@ describe "brightbox lbs" do
7
7
  let(:stdout) { output.stdout }
8
8
  let(:stderr) { output.stderr }
9
9
 
10
+ before do
11
+ config = config_from_contents(USER_APP_CONFIG_CONTENTS)
12
+ cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
13
+ end
14
+
10
15
  context "" do
11
16
  let(:argv) { %w(lbs create) }
12
17
 
@@ -14,5 +19,31 @@ describe "brightbox lbs" do
14
19
  expect { output }.to_not raise_error
15
20
  end
16
21
  end
22
+
23
+ context "--ssl-min-ver=TLSv1.0" do
24
+ let(:argv) { ["lbs", "create", "--ssl-min-ver", "TLSv1.0", "srv-12345"] }
25
+ let(:expected_args) { { ssl_minimum_version: "TLSv1.0" } }
26
+
27
+ let(:json_response) do
28
+ <<-EOS
29
+ {
30
+ "id":"lba-12345",
31
+ "ssl_minimum_version":"TLSv1.0"
32
+ }
33
+ EOS
34
+ end
35
+
36
+ before do
37
+ stub_request(:post, "http://api.brightbox.dev/1.0/load_balancers?account_id=acc-12345")
38
+ .with(:body => hash_including("ssl_minimum_version" => "TLSv1.0"))
39
+ .to_return(:status => 202, :body => json_response)
40
+ end
41
+
42
+ it "includes ssl_minimum_version in response" do
43
+ expect(Brightbox::LoadBalancer).to receive(:create).with(hash_including(expected_args)).and_call_original
44
+ expect(stderr).to eq("Creating a new load balancer\n")
45
+ expect(stdout).to include("lba-12345")
46
+ end
47
+ end
17
48
  end
18
49
  end
@@ -7,6 +7,11 @@ describe "brightbox lbs" do
7
7
  let(:stdout) { output.stdout }
8
8
  let(:stderr) { output.stderr }
9
9
 
10
+ before do
11
+ config = config_from_contents(USER_APP_CONFIG_CONTENTS)
12
+ cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
13
+ end
14
+
10
15
  context "" do
11
16
  let(:argv) { %w(lbs update) }
12
17
 
@@ -14,5 +19,32 @@ describe "brightbox lbs" do
14
19
  expect { output }.to_not raise_error
15
20
  end
16
21
  end
22
+
23
+ context "--ssl-min-ver=TLSv1.0" do
24
+ let(:argv) { ["lbs", "update", "--ssl-min-ver", "TLSv1.0", "lba-12345"] }
25
+
26
+ let(:json_response) do
27
+ <<-EOS
28
+ {
29
+ "id":"lba-12345",
30
+ "ssl_minimum_version":"TLSv1.0"
31
+ }
32
+ EOS
33
+ end
34
+
35
+ before do
36
+ stub_request(:get, "http://api.brightbox.dev/1.0/load_balancers/lba-12345?account_id=acc-12345")
37
+ .to_return(:status => 200, :body => '{"id":"lba-12345"}')
38
+
39
+ stub_request(:put, "http://api.brightbox.dev/1.0/load_balancers/lba-12345?account_id=acc-12345")
40
+ .with(:body => hash_including("ssl_minimum_version" => "TLSv1.0"))
41
+ .to_return(:status => 202, :body => json_response)
42
+ end
43
+
44
+ it "includes ssl_minimum_version in response" do
45
+ expect(stderr).to eq("Updating load balancer lba-12345\n")
46
+ expect(stdout).to include("lba-12345")
47
+ end
48
+ end
17
49
  end
18
50
  end
@@ -7,6 +7,10 @@ describe "brightbox servers" do
7
7
  let(:stdout) { output.stdout }
8
8
  let(:stderr) { output.stderr }
9
9
 
10
+ let(:image) { double(:id => "img-12345", :name => "Linux") }
11
+ let(:type) { double(:id => "typ-12345", :handle => "nano") }
12
+ let(:zone) { double(:handle => "gb1-a") }
13
+
10
14
  before do
11
15
  config = config_from_contents(USER_APP_CONFIG_CONTENTS)
12
16
  cache_access_token(config, "f83da712e6299cda953513ec07f7a754f747d727")
@@ -27,10 +31,6 @@ describe "brightbox servers" do
27
31
  context "with --cloud-ip with nominated IP argument" do
28
32
  let(:argv) { %w(servers create --cloud-ip cip-12345 img-12345) }
29
33
 
30
- let(:image) { double(:id => "img-12345", :name => "Linux") }
31
- let(:type) { double(:id => "typ-12345", :handle => "nano") }
32
- let(:zone) { double(:handle => "gb1-a") }
33
-
34
34
  before do
35
35
  expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
36
36
  expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
@@ -50,10 +50,6 @@ describe "brightbox servers" do
50
50
  context "with --cloud-ip true argument" do
51
51
  let(:argv) { %w(servers create --cloud-ip true img-12345) }
52
52
 
53
- let(:image) { double(:id => "img-12345", :name => "Linux") }
54
- let(:type) { double(:id => "typ-12345", :handle => "nano") }
55
- let(:zone) { double(:handle => "gb1-a") }
56
-
57
53
  before do
58
54
  expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
59
55
  expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
@@ -70,6 +66,26 @@ describe "brightbox servers" do
70
66
  end
71
67
  end
72
68
 
69
+ context "with --disk-encrypted switch" do
70
+ let(:argv) { %w(servers create --disk-encrypted img-12345) }
71
+
72
+ before do
73
+ expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
74
+ expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
75
+ end
76
+
77
+ it "requests new server with encryption at rest enabled" do
78
+ stub_request(:post, "http://api.brightbox.dev/1.0/servers?account_id=acc-12345")
79
+ .with(:headers => { "Content-Type" => "application/json" },
80
+ :body => hash_including(:disk_encrypted => true))
81
+ .and_return(:status => 202, :body => sample_response)
82
+
83
+ expect(stderr).to match("Creating a nano")
84
+ expect(stderr).not_to match("ERROR")
85
+ expect(stdout).to match("srv-12345")
86
+ end
87
+ end
88
+
73
89
  def sample_response
74
90
  '{
75
91
  "id": "srv-12345",
@@ -104,6 +104,32 @@ describe "brightbox sql instances" do
104
104
  end
105
105
  end
106
106
 
107
+ context "--snapshot=dbi-1493j" do
108
+ let(:argv) { ["sql", "instances", "create", "--snapshot=dbi-1493j"] }
109
+ let(:expected_args) { { :snapshot_id => "dbi-1493j" } }
110
+
111
+ let(:json_response) do
112
+ <<-EOS
113
+ {
114
+ "id":"dbs-12345"
115
+ }
116
+ EOS
117
+ end
118
+
119
+ before do
120
+ stub_request(:post, "http://api.brightbox.dev/1.0/database_servers?account_id=acc-12345")
121
+ .with(:headers => { "Content-Type" => "application/json" },
122
+ :body => hash_including("snapshot" => "dbi-1493j"))
123
+ .and_return(:status => 202, :body => json_response)
124
+ end
125
+
126
+ it "includes schedule fields in response" do
127
+ expect(Brightbox::DatabaseServer).to receive(:create).with(expected_args).and_call_original
128
+ expect(stdout).to include("id: dbs-12345")
129
+ expect(stderr).to eql("")
130
+ end
131
+ end
132
+
107
133
  context "--snapshots-schedule='0 12 * * 4'" do
108
134
  let(:argv) { ["sql", "instances", "create", "--snapshots-schedule=0 12 * * 4"] }
109
135
  let(:expected_args) { { :snapshots_schedule => "0 12 * * 4" } }
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: 3.0.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fog-core
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -241,8 +241,8 @@ executables:
241
241
  extensions: []
242
242
  extra_rdoc_files: []
243
243
  files:
244
+ - ".github/workflows/ruby.yml"
244
245
  - ".gitignore"
245
- - ".travis.yml"
246
246
  - CHANGELOG.md
247
247
  - Gemfile
248
248
  - Gemfile.lock
@@ -372,6 +372,7 @@ files:
372
372
  - lib/brightbox-cli/config/sections.rb
373
373
  - lib/brightbox-cli/config/to_fog.rb
374
374
  - lib/brightbox-cli/config/two_factor_auth.rb
375
+ - lib/brightbox-cli/config/two_factor_helper.rb
375
376
  - lib/brightbox-cli/config/user_application.rb
376
377
  - lib/brightbox-cli/connection_manager.rb
377
378
  - lib/brightbox-cli/database_server.rb
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- rvm:
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- - 2.3
9
- - 2.4
10
- - 2.6