misty 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e38a7bebc3932af882c764468517ea29bf58fd63
4
- data.tar.gz: 983fccc9ff8b973fb061eb29d4e6c8b0ce35b721
3
+ metadata.gz: '0108d5bb9451b9500d689c21f6cf43b4ae90186c'
4
+ data.tar.gz: a6d0744f4806007d55044ad7fe3f96e4be645ec0
5
5
  SHA512:
6
- metadata.gz: 250e7593f02b12ae22e74d8ff95c7adf62835c6a42ba55f54e7d87c71d205156b9fb868a4e8c094177e899ccd66885ea9106332126b1f3e26739858fae5a5b6a
7
- data.tar.gz: ff9ddfb7376a44aba4f21f663afd293a15e73223635104c7426a2f7da11e13f480e66080ac2748cf93208c569f7fb369f5f35d37c19e9dc92e6daf2385d49ded
6
+ metadata.gz: b73c8d875c03a7495c5e84be31ca00e9b6b13667d0a576334e710f76a6586ec47a7400022ef29f6e896cea866793ac2d41f174cbfb9b81b6b016137875957335
7
+ data.tar.gz: 8df0ce513d52b08551537a0fe6dc702ce1d6f7e9f06ac43082c1f14a7c27d33952d136273592a8eb8ba6a936077c9eca8450bc49a897ef3dfcc85caae4d5a943
data/README.md CHANGED
@@ -212,6 +212,10 @@ The following options are applied to each service unless specifically provided f
212
212
  Type: String
213
213
  Allowed values: "public", "internal", "admin"
214
214
  Default: "public"
215
+ * :http_proxy
216
+ For example: `"http://userid:password@somewhere.com:8080/"` or `ENV["http_proxy"]`
217
+ Type: String
218
+ Default: `""`
215
219
  * :ssl_verify_mode
216
220
  When using SSL mode (defined by URI scheme => "https://")
217
221
  Type: Boolean
@@ -24,19 +24,20 @@ module Misty
24
24
 
25
25
  attr_reader :catalog
26
26
 
27
- def initialize(options, ssl_verify_mode, log)
27
+ def initialize(options, proxy, ssl_verify_mode, log)
28
28
  @ssl_verify_mode, @log = ssl_verify_mode, log
29
29
  @credentials = scoped_authentication
30
30
 
31
31
  raise URLError, "No URL provided" unless options[:url] && !options[:url].empty?
32
32
  @uri = URI.parse(options[:url])
33
+ @proxy = proxy
33
34
  @token = nil
34
35
  setup(authenticate)
35
36
  raise CatalogError, "No catalog provided during authentication" if @catalog.empty?
36
37
  end
37
38
 
38
39
  def authenticate
39
- http = net_http(@uri, @ssl_verify_mode, @log)
40
+ http = net_http(@uri, @proxy, @ssl_verify_mode, @log)
40
41
  response = http.post(self.class.path, @credentials.to_json, Misty::HEADER_JSON)
41
42
  raise AuthenticationError, "Response code=#{response.code}, Msg=#{response.msg}" unless response.code =~ /200|201/
42
43
  response
@@ -3,7 +3,9 @@ require 'misty/auth/auth_v3'
3
3
 
4
4
  module Misty
5
5
  class Cloud
6
- Setup = Struct.new(:auth, :content_type, :log, :interface, :region_id, :ssl_verify_mode)
6
+ class Setup
7
+ attr_accessor :auth, :content_type, :log, :interface, :proxy, :region_id, :ssl_verify_mode
8
+ end
7
9
 
8
10
  Options = Struct.new(:alarming, :baremetal, :block_storage, :clustering, :compute, :container, :data_processing,
9
11
  :database, :data_protection, :dns, :identity, :image, :messaging, :metering, :network, :object_storage,
@@ -25,7 +27,9 @@ module Misty
25
27
  setup.log.level = params[:log_level] ? params[:log_level] : Misty::LOG_LEVEL
26
28
  setup.region_id = params[:region_id] ? params[:region_id] : Misty::REGION_ID
27
29
  setup.ssl_verify_mode = params.key?(:ssl_verify_mode) ? params[:ssl_verify_mode] : Misty::SSL_VERIFY_MODE
28
- setup.auth = Misty::Auth.factory(params[:auth], setup.ssl_verify_mode, setup.log)
30
+ http_proxy = params[:http_proxy] ? params[:http_proxy] : ""
31
+ setup.proxy = URI.parse(http_proxy)
32
+ setup.auth = Misty::Auth.factory(params[:auth], setup.proxy, setup.ssl_verify_mode, setup.log)
29
33
  setup
30
34
  end
31
35
 
@@ -51,7 +51,7 @@ module Misty
51
51
  @uri = URI.parse(@setup.auth.get_endpoint(@options.service_names, @options.region_id, @options.interface))
52
52
  @base_path = @options.base_path ? @options.base_path : @uri.path
53
53
  @base_path = @base_path.chomp("/")
54
- @http = net_http(@uri, @options[:ssl_verify_mode], @setup.log)
54
+ @http = net_http(@uri, @setup.proxy, @options[:ssl_verify_mode], @setup.log)
55
55
  @version = nil
56
56
  @microversion = false
57
57
  end
@@ -1,10 +1,10 @@
1
1
  module Misty
2
2
  module HTTP
3
3
  module NetHTTP
4
- def net_http(uri, ssl_verify_mode, log)
5
- http = Net::HTTP.new(uri.host, uri.port)
4
+ def net_http(endpoint, proxy, ssl_verify_mode, log)
5
+ http = Net::HTTP.new(endpoint.host, endpoint.port, proxy.host, proxy.port, proxy.user, proxy.password)
6
6
  http.set_debug_output(log) if log.level == Logger::DEBUG
7
- if uri.scheme == "https"
7
+ if endpoint.scheme == "https"
8
8
  http.use_ssl = true
9
9
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ssl_verify_mode
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -19,7 +19,7 @@ describe Misty::Auth do
19
19
  :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
20
20
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
21
21
 
22
- Misty::AuthV3.new(auth, false, log)
22
+ Misty::AuthV3.new(auth, URI.parse(""), false, log)
23
23
  end
24
24
 
25
25
  it "authenticates using domain scoped authorization" do
@@ -34,7 +34,7 @@ describe Misty::Auth do
34
34
  :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
35
35
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
36
36
 
37
- Misty::AuthV3.new(auth, false, log)
37
+ Misty::AuthV3.new(auth, URI.parse(""), false, log)
38
38
  end
39
39
  end
40
40
 
@@ -53,7 +53,7 @@ describe Misty::Auth do
53
53
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {"x-subject-token"=>"token_data"})
54
54
 
55
55
  proc do
56
- Misty::AuthV3.new({}, false, log)
56
+ Misty::AuthV3.new({}, URI.parse(""), false, log)
57
57
  end.must_raise Misty::Auth::CredentialsError
58
58
  end
59
59
 
@@ -61,7 +61,7 @@ describe Misty::Auth do
61
61
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
62
62
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
63
63
 
64
- auth = Misty::AuthV3.new(authv3_creds, false, log)
64
+ auth = Misty::AuthV3.new(authv3_creds, URI.parse(""), false, log)
65
65
  auth.stub :expired?, false do
66
66
  auth.get_token.must_equal "token_data"
67
67
  end
@@ -71,7 +71,7 @@ describe Misty::Auth do
71
71
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
72
72
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
73
73
 
74
- auth = Misty::AuthV3.new(authv3_creds, false, log)
74
+ auth = Misty::AuthV3.new(authv3_creds, URI.parse(""), false, log)
75
75
  auth.catalog.must_equal ["catalog_data"]
76
76
  end
77
77
 
@@ -79,7 +79,7 @@ describe Misty::Auth do
79
79
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
80
80
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
81
81
 
82
- auth = Misty::AuthV3.new(authv3_creds, false, log)
82
+ auth = Misty::AuthV3.new(authv3_creds, URI.parse(""), false, log)
83
83
  auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
84
84
  end
85
85
  end
@@ -92,7 +92,7 @@ describe Misty::Auth do
92
92
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
93
93
 
94
94
  proc do
95
- Misty::AuthV2.new({}, false, log)
95
+ Misty::AuthV2.new({}, URI.parse(""), false, log)
96
96
  end.must_raise Misty::Auth::CredentialsError
97
97
  end
98
98
  end
@@ -111,7 +111,7 @@ describe Misty::Auth do
111
111
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
112
112
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
113
113
 
114
- auth = Misty::AuthV2.new(authv2_creds, false, log)
114
+ auth = Misty::AuthV2.new(authv2_creds, URI.parse(""), false, log)
115
115
  auth.stub :expired?, false do
116
116
  auth.get_token.must_equal "token_data"
117
117
  end
@@ -121,7 +121,7 @@ describe Misty::Auth do
121
121
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
122
122
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
123
123
 
124
- auth = Misty::AuthV2.new(authv2_creds, false, log)
124
+ auth = Misty::AuthV2.new(authv2_creds, URI.parse(""), false, log)
125
125
  auth.catalog.must_equal ["catalog_data"]
126
126
  end
127
127
 
@@ -129,7 +129,7 @@ describe Misty::Auth do
129
129
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
130
130
  to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
131
131
 
132
- auth = Misty::AuthV2.new(authv2_creds, false, log)
132
+ auth = Misty::AuthV2.new(authv2_creds, URI.parse(""), false, log)
133
133
  auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
134
134
  end
135
135
  end
@@ -54,10 +54,12 @@ describe Misty::Cloud do
54
54
  it "sets up default values" do
55
55
  Misty::Auth.stub :factory, nil do
56
56
  setup = Misty::Cloud.setup({})
57
- setup.must_be_kind_of Struct
57
+ setup.must_be_kind_of Misty::Cloud::Setup
58
58
  setup.content_type.must_equal Misty::CONTENT_TYPE
59
59
  setup.log.must_be_kind_of Logger
60
60
  setup.interface.must_equal Misty::INTERFACE
61
+ setup.proxy.must_be_kind_of URI
62
+ setup.proxy.host.must_be_nil
61
63
  setup.region_id.must_equal Misty::REGION_ID
62
64
  setup.ssl_verify_mode.must_equal Misty::SSL_VERIFY_MODE
63
65
  end
@@ -41,8 +41,9 @@ describe Misty::HTTP::Client do
41
41
 
42
42
  describe "#net_http" do
43
43
  it "returns a Net/http instance" do
44
- uri = URI.parse("http://localhost")
45
- service.send(:net_http, uri, false, Logger.new("/dev/null")).must_be_instance_of Net::HTTP
44
+ endpoint = URI.parse("http://localhost")
45
+ proxy = URI.parse("")
46
+ service.send(:net_http, endpoint, proxy, false, Logger.new("/dev/null")).must_be_instance_of Net::HTTP
46
47
  end
47
48
  end
48
49
 
@@ -31,7 +31,14 @@ describe Misty::HTTP::Microversion do
31
31
  "token_id"
32
32
  end
33
33
 
34
- setup = Misty::Cloud::Setup.new(auth, :ruby, Logger.new('/dev/null'), Misty::INTERFACE, Misty::REGION_ID, Misty::SSL_VERIFY_MODE)
34
+ setup = Misty::Cloud::Setup.new
35
+ setup.auth = auth
36
+ setup.content_type = :ruby
37
+ setup.log = Logger.new('/dev/null')
38
+ setup.interface = Misty::INTERFACE
39
+ setup.proxy = URI.parse('')
40
+ setup.region_id = Misty::REGION_ID
41
+ setup.ssl_verify_mode = Misty::SSL_VERIFY_MODE
35
42
 
36
43
  stub_request(:get, "http://localhost/").
37
44
  with(:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
@@ -15,7 +15,14 @@ def service(content_type = :ruby)
15
15
  "token_id"
16
16
  end
17
17
 
18
- setup = Misty::Cloud::Setup.new(auth, content_type, Logger.new('/dev/null'), Misty::INTERFACE, Misty::REGION_ID, Misty::SSL_VERIFY_MODE)
18
+ setup = Misty::Cloud::Setup.new
19
+ setup.auth = auth
20
+ setup.content_type = content_type
21
+ setup.log = Logger.new('/dev/null')
22
+ setup.interface = Misty::INTERFACE
23
+ setup.proxy = URI.parse("")
24
+ setup.region_id = Misty::REGION_ID
25
+ setup.ssl_verify_mode = Misty::SSL_VERIFY_MODE
19
26
 
20
27
  stub_request(:get, "http://localhost/").
21
28
  with(:headers => request_header).
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.3
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '2.0'
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.8.3
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '2.0'
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +211,7 @@ files:
205
211
  - test/unit/test_helper.rb
206
212
  homepage: https://github.com/flystack/misty
207
213
  licenses:
208
- - Apache License Version 2.0
214
+ - Apache-2.0
209
215
  metadata: {}
210
216
  post_install_message:
211
217
  rdoc_options:
@@ -227,6 +233,5 @@ rubyforge_project:
227
233
  rubygems_version: 2.5.2
228
234
  signing_key:
229
235
  specification_version: 4
230
- summary: Misty is a dedicated HTTP client for OpenStack providing dynamic APIs requests
231
- management.
236
+ summary: Misty is an OpenStack API client
232
237
  test_files: []