brightbox-cli 2.3.0 → 2.3.1

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
  SHA1:
3
- metadata.gz: 878ff7e5b319cc7c15095db32d0091a6e1d2988b
4
- data.tar.gz: d5809b9c66921ea3820855723d871fb1eeeb99ec
3
+ metadata.gz: f27bf83c2b327b366e844aeb2a3d3f6734689870
4
+ data.tar.gz: 8184ccc9096fbc3117807938aca84b0c71224d49
5
5
  SHA512:
6
- metadata.gz: 95b4dce981e19ad00c6f79636cc4bd29c620eee0ca43eb5256be40c2a5c60be9de634348c861177a21f4d4d72720ed1b26b8c8efbb787c8948011bddc55d148b
7
- data.tar.gz: e5f9235468da53a0f4635665376dae4f9f35d4d43612c144ef36bc343342f03496cf1eb415fa682217fd101b09bd1ac06222f6f58b28d5987fb3ca12cf53765e
6
+ metadata.gz: 961e3af440fb8e7614d47f52d60ab5ec05af1563a07e28f702f78dc25414016252b14aa580ee16c009844f9db2be737b3c7bef1418ee9db7e20eac55383dd8e8
7
+ data.tar.gz: 0c61aef7964334ececb2cd7c57351fec449a20638bbc30238badeaf4ca051fe076fcd8165d3445b23f3ebb602bd2adcbb31a6488b9e639717d20e546bab0d47b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### v2.3.1 / 2015-10-26
2
+
3
+ [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v2.3.0...v2.3.1)
4
+
5
+ Bug fixes:
6
+
7
+ * Fix issue when `login` command would reset custom URLs to the defaults.
8
+
1
9
  ### v2.3.0 / 2015-10-23
2
10
 
3
11
  [Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v2.2.0...v2.3.0)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightbox-cli (2.3.0)
4
+ brightbox-cli (2.3.1)
5
5
  fog-brightbox (>= 0.9.0)
6
6
  gli (~> 2.12.0)
7
7
  highline (~> 1.6.0)
@@ -13,8 +13,11 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ addressable (2.3.8)
16
17
  builder (3.2.2)
17
18
  coderay (1.0.9)
19
+ crack (0.4.2)
20
+ safe_yaml (~> 1.0.0)
18
21
  diff-lcs (1.2.5)
19
22
  excon (0.45.4)
20
23
  fog-brightbox (0.9.0)
@@ -62,8 +65,12 @@ GEM
62
65
  rspec-expectations (2.99.1)
63
66
  diff-lcs (>= 1.1.3, < 2.0)
64
67
  rspec-mocks (2.99.1)
68
+ safe_yaml (1.0.4)
65
69
  slop (3.4.5)
66
70
  vcr (2.5.0)
71
+ webmock (1.21.0)
72
+ addressable (>= 2.3.6)
73
+ crack (>= 0.3.2)
67
74
 
68
75
  PLATFORMS
69
76
  ruby
@@ -75,6 +82,7 @@ DEPENDENCIES
75
82
  rake
76
83
  rspec (~> 2.99)
77
84
  vcr (~> 2.5)
85
+ webmock
78
86
 
79
87
  BUNDLED WITH
80
88
  1.10.6
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_development_dependency "rake"
35
35
  s.add_development_dependency "rspec", "~> 2.99"
36
36
  s.add_development_dependency "vcr", "~> 2.5"
37
+ s.add_development_dependency "webmock"
37
38
 
38
39
  s.post_install_message = <<-EOS
39
40
  The CLI command is now `brightbox` with subcommands for the resources.
@@ -31,17 +31,16 @@ module Brightbox
31
31
  end
32
32
  raise "You must specify your Brightbox password." if password.empty?
33
33
 
34
- api_url = options[:"api-url"] || DEFAULT_API_ENDPOINT
35
- auth_url = options[:"auth-url"] || api_url
36
-
37
34
  section_options = {
38
35
  :client_name => config_name,
39
36
  :alias => config_name,
40
37
  :username => email,
41
- :password => password,
42
- :api_url => api_url,
43
- :auth_url => auth_url
38
+ :password => password
44
39
  }
40
+
41
+ section_options[:api_url] = options[:"api-url"] if options[:"api-url"]
42
+ section_options[:auth_url] = options[:"auth-url"] if options[:"auth-url"]
43
+
45
44
  section_options[:default_account] = options[:"default-account"] if options[:"default-account"]
46
45
 
47
46
  section_options[:client_id] = options[:"application-id"] if options[:"application-id"]
@@ -24,7 +24,7 @@ module Brightbox
24
24
  config_section["api_url"] = DEFAULT_API_ENDPOINT unless config_section["api_url"]
25
25
 
26
26
  config_section["auth_url"] = options[:auth_url] if options.key?(:auth_url)
27
- config_section["auth_url"] = config_section["api_url"]
27
+ config_section["auth_url"] = config_section["api_url"] unless config_section["auth_url"]
28
28
 
29
29
  config_section["default_account"] = options[:default_account] if options.key?(:default_account)
30
30
 
@@ -1,3 +1,3 @@
1
1
  module Brightbox
2
- VERSION = "2.3.0" unless defined?(Brightbox::VERSION)
2
+ VERSION = "2.3.1" unless defined?(Brightbox::VERSION)
3
3
  end
@@ -236,4 +236,59 @@ describe "brightbox login" do
236
236
  expect(stderr).to_not include("please re-run your command")
237
237
  end
238
238
  end
239
+
240
+ context "when login is used to refresh tokens" do
241
+ let(:email) { "jason.null@brightbox.com" }
242
+ let(:client_alias) { "#{email}/custom" }
243
+ let(:custom_api_url) { "https://api.example.com" }
244
+ let(:custom_auth_url) { "https://auth.example.com" }
245
+ let(:default_account) { "acc-custom" }
246
+
247
+ let(:contents) do
248
+ <<-EOS
249
+ [core]
250
+ default_client = #{client_alias}
251
+
252
+ [#{client_alias}]
253
+ username = #{email}
254
+ api_url = #{custom_api_url}
255
+ auth_url = #{custom_auth_url}
256
+ default_account = #{default_account}
257
+ EOS
258
+ end
259
+ let(:config) { Brightbox::BBConfig.new }
260
+
261
+ let(:argv) { ["login", client_alias] }
262
+
263
+ before do
264
+ config_from_contents(contents)
265
+ mock_password_entry(password)
266
+
267
+ stub_request(:post, "https://auth.example.com/token").to_return(
268
+ :status => 200,
269
+ :body => '{"access_token":"44320b29286077c44f14c4efdfed70f63f4a8361","token_type":"Bearer","refresh_token":"759b2b28c228948a0ba5d07a89f39f9e268a95c0","scope":"infrastructure orbit","expires_in":7200}').times(2)
270
+ end
271
+
272
+ it "does not change the config" do
273
+ expect { output }.to_not raise_error
274
+
275
+ client_section = config.config[client_alias]
276
+
277
+ expect(client_section["api_url"]).to eql(custom_api_url)
278
+ expect(client_section["auth_url"]).to eql(custom_auth_url)
279
+ expect(client_section["username"]).to eql(email)
280
+ expect(client_section["default_account"]).to eql(default_account)
281
+ end
282
+
283
+ it "requests access tokens" do
284
+ expect { output }.to_not raise_error
285
+
286
+ expect(cached_access_token(config)).to eql(config.access_token)
287
+ expect(cached_refresh_token(config)).to eql(config.refresh_token)
288
+ end
289
+
290
+ it "does not prompt to rerun the command" do
291
+ expect(stderr).to_not include("please re-run your command")
292
+ end
293
+ end
239
294
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,9 @@ require "tmpdir"
8
8
 
9
9
  Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
10
10
 
11
+ require "webmock/rspec"
12
+ WebMock.disable_net_connect!
13
+
11
14
  # API_CLIENT_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/api_client")
12
15
  # USER_APP_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/user_application")
13
16
 
data/spec/support/vcr.rb CHANGED
@@ -3,7 +3,7 @@ require "vcr"
3
3
  VCR.configure do |vcr|
4
4
  vcr.cassette_library_dir = File.join(File.dirname(__FILE__), "../cassettes")
5
5
  vcr.allow_http_connections_when_no_cassette = false
6
- vcr.hook_into :excon
6
+ vcr.hook_into :webmock
7
7
 
8
8
  vcr.configure_rspec_metadata!
9
9
  vcr.default_cassette_options = {
@@ -30,3 +30,13 @@ VCR.configure do |vcr|
30
30
  end
31
31
  end
32
32
  end
33
+
34
+ VCR.turn_off!
35
+
36
+ VCR.extend Module.new {
37
+ def use_cassette(*args)
38
+ VCR.turn_on!
39
+ super
40
+ VCR.turn_off!
41
+ end
42
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-brightbox
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '2.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: webmock
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  description: Scripts to interact with the Brightbox cloud API
182
196
  email:
183
197
  - john@brightbox.co.uk