misty 0.3.2 → 0.4.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
  SHA1:
3
- metadata.gz: 83575874d30a942a02efcc8c425c0b866a5785c0
4
- data.tar.gz: 0f1e48ace0eb01ddce6b877fe6ffb8b1b7ab27dd
3
+ metadata.gz: 8871dd676eb4b94f5ba8c83606aa8c058b3308bd
4
+ data.tar.gz: 1189ed46c9ff27f495195777eab3738e868c19c7
5
5
  SHA512:
6
- metadata.gz: 62ba32820ad2cb2614041f8fb7db9dc024ec85bd3508cb8eb3d6796efeb02f8f7d4e5a8235a625bb9ea10368327514c63a5ec904f7318e95a328f5907219f531
7
- data.tar.gz: 8af6446a5b734974dbda856e54c629594e2192585e139e1aad9ce92fa64b70724fe19934245bf135bcbf7dc40a338b2858b7af1e0b0f2aed83ea8f87aded20f8
6
+ metadata.gz: 94215114f14ce374973f08066ec787156b7863740ba85c748cfb7d5c2d29552996ca47d433b893ec3c17c585ec5fa8fc0a46d6a298913db76203ca29b529166f
7
+ data.tar.gz: 740e770a49088a9a7c86b8bbc54e8b576837932fcb546ee99da12f67566a977632c282039c56e127ff70135458c77bb7976af57c92dc4e151c8653584d8420fb
data/README.md CHANGED
@@ -122,18 +122,66 @@ openstack.compute.requests
122
122
  ### Authentication information parameter
123
123
  The URL and credentials details are necessary to authenticate with the identity server (Keystone).
124
124
 
125
- To provide a Keystone V3, which is the default recommended version:
125
+ The credentials are a combination of "id" and "name" used to uniquely identify projects, users and their domains.
126
+ When using only the name, a domain must be specified to guarantee a unique record from the Identity service.
127
+
128
+ The following parameters can be used:
129
+ * `:domain_id`
130
+ Domain id used for authentication scope
131
+ Default: `"default"`
132
+ * `:domain`
133
+ Domain name used for authentication scope
134
+ Default: `"Default"`
135
+ * `:project_id`
136
+ Project id
137
+ * `:project`
138
+ Project name
139
+ * `:project_domain_id`
140
+ Project domain id
141
+ * `:project_domain`
142
+ Project domain name
143
+ * `:tenant_id`
144
+ Tenant id, used only for Keystone v2.0
145
+ * `:tenant`
146
+ Tenant name, used only for Keystone v2.0
147
+ * `:user_id`
148
+ User id
149
+ * `:user`
150
+ User name
151
+ * `:user_domain_id`
152
+ User domain id
153
+ * `:user_domain`
154
+ User domain name
155
+
156
+ #### Keystone v3
157
+ Keystone v3 is default recommended version:
158
+
126
159
  ```ruby
127
160
  auth = {
128
- :url => "http://localhost:5000",
129
- :user => "admin",
130
- :password => "secret",
131
- :project => "admin",
132
- :domain => "default"
161
+ :url => "http://localhost:5000",
162
+ :user => "admin",
163
+ :user_domain => "default",
164
+ :password => "secret",
165
+ :project => "admin",
166
+ :project_domain => "default"
167
+ }
168
+ }
169
+ ```
170
+
171
+ Alternatively, using IDs:
172
+
173
+ ```ruby
174
+ auth = {
175
+ :url => "http://localhost:5000",
176
+ :user_id => "48985e6b8da145699d411f12a3459fca",
177
+ :password => "secret",
178
+ :project_id => "8e1e232f6cbb4116bbef715d8a0afe6e",
133
179
  }
134
180
  }
135
181
  ```
136
- Alternatively, for Keystone V2, just provide the tenant details, Misty will detect it's using Keystone V2:
182
+ #### Keystone v2.0
183
+ Provide the tenant details, Misty will detect it's using v2.0 for authentication:
184
+
137
185
  ```ruby
138
186
  auth = {
139
187
  :url => "http://localhost:5000",
@@ -1,3 +1,6 @@
1
+ require 'misty/http/net_http'
2
+ require 'misty/auth/name'
3
+
1
4
  module Misty
2
5
  class Auth
3
6
  class AuthenticationError < StandardError; end
@@ -9,11 +12,13 @@ module Misty
9
12
  class InitError < RuntimeError; end
10
13
  class URLError < RuntimeError; end
11
14
 
12
- def self.factory(options = {})
13
- if options[:project]
14
- return Misty::AuthV3.new(options)
15
- elsif options[:tenant]
16
- return Misty::AuthV2.new(options)
15
+ include Misty::HTTP::NetHTTP
16
+
17
+ def self.factory(options, *args)
18
+ if options[:project_id] || options[:project]
19
+ return Misty::AuthV3.new(options, *args)
20
+ elsif options[:tenant_id] || options[:tenant]
21
+ return Misty::AuthV2.new(options, *args)
17
22
  else
18
23
  raise CredentialsError, "Cannot identify version from credentials"
19
24
  end
@@ -21,9 +26,10 @@ module Misty
21
26
 
22
27
  attr_reader :catalog
23
28
 
24
- def initialize(options)
25
- raise CredentialsError unless credentials_valid?(options)
26
- @credentials = scoped_credentials(options)
29
+ def initialize(options, ssl_verify_mode, log)
30
+ @ssl_verify_mode, @log = ssl_verify_mode, log
31
+ @credentials = scoped_authentication
32
+
27
33
  raise URLError, "No URL provided" unless options[:url] && !options[:url].empty?
28
34
  @uri = URI.parse(options[:url])
29
35
  @token = nil
@@ -32,7 +38,7 @@ module Misty
32
38
  end
33
39
 
34
40
  def authenticate
35
- http = Net::HTTP.new(@uri.host, @uri.port)
41
+ http = net_http(@uri, @ssl_verify_mode, @log)
36
42
  response = http.post(self.class.path, @credentials.to_json, Misty::HEADER_JSON)
37
43
  raise AuthenticationError, "Response code=#{response.code}, Msg=#{response.msg}" unless response.code =~ /200|201/
38
44
  response
@@ -6,6 +6,13 @@ module Misty
6
6
  "/v2.0/tokens"
7
7
  end
8
8
 
9
+ def initialize(options, *args)
10
+ @user = Misty::Auth::User.new(options[:user_id], options[:user])
11
+ @user.password = options[:password]
12
+ @tenant = Misty::Auth::Name.new(options[:tenant_id], options[:tenant])
13
+ super(options, *args)
14
+ end
15
+
9
16
  def catalog_endpoints(endpoints, region, interface)
10
17
  endpoints.each do |endpoint|
11
18
  if endpoint["region"] == region && endpoint["#{interface}URL"]
@@ -14,10 +21,6 @@ module Misty
14
21
  end
15
22
  end
16
23
 
17
- def credentials_valid?(creds)
18
- true if creds[:user] && creds[:password] && creds[:tenant]
19
- end
20
-
21
24
  def get_endpoint_url(endpoints, region, interface)
22
25
  endpoint = endpoints.select { |ep| !ep[interface].empty? }
23
26
  raise CatalogError, "No endpoint available for region '#{region}' and interface '#{interface}'" unless endpoint
@@ -31,16 +34,37 @@ module Misty
31
34
  @expires = payload["access"]["token"]["expires"]
32
35
  end
33
36
 
34
- def scoped_credentials(creds)
37
+ def scoped_authentication
38
+ raise Misty::Auth::CredentialsError, "#{self.class}: User name is required" if @user.name.nil?
39
+ raise Misty::Auth::CredentialsError, "#{self.class}: User password is required" if @user.password.nil?
40
+ return auth_by_id if @tenant.id
41
+ return auth_by_name if @tenant.name
42
+ raise Misty::Auth::CredentialsError, "#{self.class}: No tenant available"
43
+ end
44
+
45
+ def auth_by_name
46
+ {
47
+ "auth": {
48
+ "passwordCredentials": credentials,
49
+ "tenantName": @tenant.name
50
+ }
51
+ }
52
+ end
53
+
54
+ def auth_by_id
35
55
  {
36
56
  "auth": {
37
- "passwordCredentials": {
38
- "username": creds[:user],
39
- "password": creds[:password]
40
- },
41
- "tenantName": creds[:tenant]
57
+ "passwordCredentials": credentials,
58
+ "tenantId": @tenant.id
42
59
  }
43
60
  }
44
61
  end
62
+
63
+ def credentials
64
+ {
65
+ "username": @user.name,
66
+ "password": @user.password
67
+ }
68
+ end
45
69
  end
46
70
  end
@@ -2,6 +2,23 @@ require 'misty/auth'
2
2
 
3
3
  module Misty
4
4
  class AuthV3 < Misty::Auth
5
+ def initialize(options, *args)
6
+ domain_id = options[:domain_id] ? options[:domain_id] : Misty::DOMAIN_ID
7
+ project_domain_id = options[:project_domain_id] ? options[:project_domain_id] : Misty::DOMAIN_ID
8
+ user_domain_id = options[:user_domain_id] ? options[:user_domain_id] : Misty::DOMAIN_ID
9
+
10
+ @domain = Misty::Auth::Name.new(domain_id, options[:domain])
11
+
12
+ @user = Misty::Auth::User.new(options[:user_id], options[:user])
13
+ @user.password = options[:password]
14
+ @user.domain = Misty::Auth::Name.new(user_domain_id, options[:user_domain])
15
+
16
+ @project = Misty::Auth::Project.new(options[:project_id], options[:project])
17
+ @project.domain = Misty::Auth::Name.new(project_domain_id, options[:user_domain])
18
+
19
+ super(options, *args)
20
+ end
21
+
5
22
  def self.path
6
23
  "/v3/auth/tokens"
7
24
  end
@@ -14,45 +31,35 @@ module Misty
14
31
  end
15
32
  end
16
33
 
17
- def credentials_valid?(creds)
18
- true if creds[:user] && creds[:password] && creds[:project]
19
- end
20
-
21
34
  def get_endpoint_url(endpoints, region, interface)
22
35
  endpoint = endpoints.select { |ep| ep["region_id"] == region && ep["interface"] == interface }
23
36
  raise CatalogError, "No endpoint available for region '#{region}' and interface '#{interface}'" unless endpoint
24
37
  endpoint[0]["url"]
25
38
  end
26
39
 
27
- def setup(response)
28
- payload = JSON.load(response.body)
29
- @token = response["x-subject-token"]
30
- @catalog = payload["token"]["catalog"]
31
- @expires = payload["token"]["expires_at"]
32
- end
33
-
34
- def scoped_credentials(creds)
35
- creds[:domain] ||= "default"
40
+ def scoped_authentication
36
41
  {
37
42
  "auth": {
38
43
  "identity": {
39
44
  "methods": ["password"],
40
- "password": {
41
- "user": {
42
- "name": creds[:user],
43
- "domain": { "id": "default" },
44
- "password": creds[:password]
45
- }
46
- }
45
+ "password": @user.identity
47
46
  },
48
- "scope": {
49
- "project": {
50
- "name": creds[:project],
51
- "domain": { "id": creds[:domain] }
52
- }
53
- }
47
+ "scope": scope
54
48
  }
55
49
  }
56
50
  end
51
+
52
+ def scope
53
+ return @project.identity if @project
54
+ return @domain.identity if @domain
55
+ raise Misty::Auth::CredentialsError, "#{self.class}: No scope available"
56
+ end
57
+
58
+ def setup(response)
59
+ payload = JSON.load(response.body)
60
+ @token = response["x-subject-token"]
61
+ @catalog = payload["token"]["catalog"]
62
+ @expires = payload["token"]["expires_at"]
63
+ end
57
64
  end
58
65
  end
@@ -0,0 +1,53 @@
1
+ module Misty
2
+ class Auth
3
+ module Domain
4
+ attr_accessor :domain
5
+
6
+ def identity
7
+ data = {}
8
+ if !id.nil?
9
+ data.merge!(to_h(:id))
10
+ elsif !name.nil? && !domain.nil?
11
+ data.merge!(to_h(:name))
12
+ data.merge!({ :domain => @domain.identity })
13
+ else
14
+ raise Misty::Auth::CredentialsError, "#{self.class}: An Id, or a name with its domain, must be provided"
15
+ end
16
+ data
17
+ end
18
+ end
19
+
20
+ class Name < Struct.new(:id, :name)
21
+ def identity
22
+ return to_h(:id) unless id.nil?
23
+ return to_h(:name) unless name.nil?
24
+ raise Misty::Auth::CredentialsError, "#{self.class}: No available id or name"
25
+ end
26
+
27
+ def to_h(var)
28
+ { var => self.send(var) }
29
+ end
30
+ end
31
+
32
+ class Project < Name
33
+ include Misty::Auth::Domain
34
+
35
+ def identity
36
+ { :project => super }
37
+ end
38
+ end
39
+
40
+ class User < Name
41
+ include Misty::Auth::Domain
42
+
43
+ attr_accessor :password
44
+
45
+ def identity
46
+ data = super
47
+ raise Misty::Auth::CredentialsError, "#{self.class}: No password available" if password.nil?
48
+ data.merge!(to_h(:password))
49
+ { :user => data }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -19,13 +19,13 @@ module Misty
19
19
 
20
20
  def self.setup(params)
21
21
  setup = Setup.new
22
- setup.auth = Misty::Auth.factory(params[:auth])
23
22
  setup.content_type = params[:content_type] ? params[:content_type] : Misty::CONTENT_TYPE
24
23
  setup.interface = params[:interface] ? params[:interface] : Misty::INTERFACE
25
24
  setup.log = Logger.new(params[:log_file] ? params[:log_file] : Misty::LOG_FILE)
26
25
  setup.log.level = params[:log_level] ? params[:log_level] : Misty::LOG_LEVEL
27
26
  setup.region_id = params[:region_id] ? params[:region_id] : Misty::REGION_ID
28
27
  setup.ssl_verify_mode = params[: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)
29
29
  setup
30
30
  end
31
31
 
@@ -1,3 +1,4 @@
1
+ require 'misty/http/net_http'
1
2
  require 'misty/http/method_builder'
2
3
  require 'misty/http/request'
3
4
  require 'misty/http/direct'
@@ -7,6 +8,7 @@ module Misty
7
8
  class Client
8
9
  class InvalidDataError < StandardError; end
9
10
 
11
+ include Misty::HTTP::NetHTTP
10
12
  include Misty::HTTP::MethodBuilder
11
13
  include Misty::HTTP::Request
12
14
  include Misty::HTTP::Direct
@@ -49,7 +51,7 @@ module Misty
49
51
  @uri = URI.parse(@setup.auth.get_endpoint(@options.service_names, @options.region_id, @options.interface))
50
52
  @base_path = @options.base_path ? @options.base_path : @uri.path
51
53
  @base_path = @base_path.chomp("/")
52
- @http = net_http(@uri)
54
+ @http = net_http(@uri, @options[:ssl_verify_mode], @setup.log)
53
55
  @version = nil
54
56
  @microversion = false
55
57
  end
@@ -81,16 +83,6 @@ module Misty
81
83
  self.class.to_s.split('::')[-1]
82
84
  end
83
85
 
84
- def net_http(uri)
85
- http = Net::HTTP.new(uri.host, uri.port)
86
- http.set_debug_output($stdout) if @setup.log.level == Logger::DEBUG
87
- if uri.scheme == "https"
88
- http.use_ssl = true
89
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @options[:ssl_verify_mode]
90
- end
91
- http
92
- end
93
-
94
86
  def setup(params)
95
87
  options = Options.new()
96
88
  options.base_path = params[:base_path] ? params[:base_path] : nil
@@ -0,0 +1,15 @@
1
+ module Misty
2
+ module HTTP
3
+ module NetHTTP
4
+ def net_http(uri, ssl_verify_mode, log)
5
+ http = Net::HTTP.new(uri.host, uri.port)
6
+ http.set_debug_output(log) if log.level == Logger::DEBUG
7
+ if uri.scheme == "https"
8
+ http.use_ssl = true
9
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ssl_verify_mode
10
+ end
11
+ http
12
+ end
13
+ end
14
+ end
15
+ end
@@ -14,6 +14,9 @@ module Misty
14
14
  # Ruby structures: :ruby
15
15
  CONTENT_TYPE = :ruby
16
16
 
17
+ # Defaults Domain ID
18
+ DOMAIN_ID = "default"
19
+
17
20
  # Default Interface
18
21
  INTERFACE = "public"
19
22
 
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,112 @@
1
+ require 'test_helper'
2
+ require 'misty/auth/name'
3
+
4
+ describe Misty::Auth::Name do
5
+ describe "creates" do
6
+ it "when id and name are provided" do
7
+ name = Misty::Auth::Name.new("default", "Default")
8
+ name.id.must_equal "default"
9
+ name.name.must_equal "Default"
10
+ end
11
+
12
+ it "when id is null" do
13
+ name = Misty::Auth::Name.new(nil, "Default")
14
+ name.id.must_be_nil
15
+ name.name.must_equal "Default"
16
+ end
17
+
18
+ name = Misty::Auth::Name.new(nil, nil)
19
+ it "when name is null" do
20
+ name = Misty::Auth::Name.new("default", nil)
21
+ name.id.must_equal "default"
22
+ name.name.must_be_nil
23
+ end
24
+
25
+ it "when both id and name is null" do
26
+ name = Misty::Auth::Name.new(nil, nil)
27
+ name.name.must_be_nil
28
+ end
29
+ end
30
+
31
+ describe "#to_h" do
32
+ it "returns the hash of provided attribute" do
33
+ name = Misty::Auth::Name.new("default", "Default")
34
+ name.to_h(:id).must_equal ({:id => "default"})
35
+ name.to_h(:name).must_equal ({:name => "Default"})
36
+ end
37
+ end
38
+ end
39
+
40
+ describe Misty::Auth::User do
41
+ describe "#password" do
42
+ it "set/get password" do
43
+ user = Misty::Auth::User.new("user_id", "User")
44
+ user.password = "secret"
45
+ user.identity.must_equal ({:user=>{:id=>"user_id", :password=>"secret"}})
46
+ end
47
+ end
48
+
49
+ describe "#identity" do
50
+ it "raises an error when password is missing" do
51
+ proc do
52
+ user = Misty::Auth::User.new("user_id", "User")
53
+ user.identity
54
+ end.must_raise Misty::Auth::CredentialsError
55
+ end
56
+
57
+ it "when id is provided it doesn't require domain" do
58
+ user = Misty::Auth::User.new("user_id", "User")
59
+ user.password = "secret"
60
+ user.identity.must_equal ({:user=>{:id=>"user_id", :password=>"secret"}})
61
+ end
62
+
63
+ it "when id is nul and name is provided it uses domain id" do
64
+ user = Misty::Auth::User.new(nil, "User")
65
+ user.password = "secret"
66
+ user.domain = Misty::Auth::Name.new("default", nil)
67
+ user.identity.must_equal ({:user=>{:name=>"User", :domain=>{:id=>"default"}, :password=>"secret"}})
68
+ end
69
+
70
+ it "when id is nul and name is provided it uses domain name" do
71
+ user = Misty::Auth::User.new(nil, "User")
72
+ user.password = "secret"
73
+ user.domain = Misty::Auth::Name.new(nil, "Default")
74
+ user.identity.must_equal ({:user=>{:name=>"User", :domain=>{:name=>"Default"}, :password=>"secret"}})
75
+ end
76
+
77
+ it "raises an error with no user id and no domain are provided" do
78
+ proc do
79
+ user = Misty::Auth::User.new(nil, "User")
80
+ user.identity
81
+ end.must_raise Misty::Auth::CredentialsError
82
+ end
83
+ end
84
+ end
85
+
86
+ describe Misty::Auth::Project do
87
+ describe "#identity" do
88
+ it "when id is provided it doesn't require domain" do
89
+ project = Misty::Auth::Project.new("project_id", "Project")
90
+ project.identity.must_equal ({:project=>{:id=>"project_id"}})
91
+ end
92
+
93
+ it "when id is nul and name is provided it uses domain id" do
94
+ project = Misty::Auth::Project.new(nil, "Project")
95
+ project.domain = Misty::Auth::Name.new("default", nil)
96
+ project.identity.must_equal ({:project=>{:name=>"Project", :domain=>{:id=>"default"}}})
97
+ end
98
+
99
+ it "when id is nul and name is provided it uses domain name" do
100
+ project = Misty::Auth::Project.new(nil, "Project")
101
+ project.domain = Misty::Auth::Name.new(nil, "Default")
102
+ project.identity.must_equal ({:project=>{:name=>"Project", :domain=>{:name=>"Default"}}})
103
+ end
104
+
105
+ it "raises an error with no project id and no domain are provided" do
106
+ proc do
107
+ project = Misty::Auth::Project.new(nil, "Project")
108
+ project.identity
109
+ end.must_raise Misty::Auth::CredentialsError
110
+ end
111
+ end
112
+ end
@@ -28,7 +28,7 @@ describe Misty::Auth do
28
28
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {"x-subject-token"=>"token_data"})
29
29
 
30
30
  proc do
31
- Misty::AuthV3.new({})
31
+ Misty::AuthV3.new({}, false, Logger.new('/dev/null'))
32
32
  end.must_raise Misty::Auth::CredentialsError
33
33
  end
34
34
 
@@ -36,7 +36,7 @@ describe Misty::Auth do
36
36
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
37
37
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
38
38
 
39
- auth = Misty::AuthV3.new(authv3_creds)
39
+ auth = Misty::AuthV3.new(authv3_creds, false, Logger.new('/dev/null'))
40
40
  auth.stub :expired?, false do
41
41
  auth.get_token.must_equal "token_data"
42
42
  end
@@ -46,7 +46,7 @@ describe Misty::Auth do
46
46
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
47
47
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
48
48
 
49
- auth = Misty::AuthV3.new(authv3_creds)
49
+ auth = Misty::AuthV3.new(authv3_creds, false, Logger.new('/dev/null'))
50
50
  auth.catalog.must_equal ["catalog_data"]
51
51
  end
52
52
 
@@ -54,7 +54,7 @@ describe Misty::Auth do
54
54
  stub_request(:post, "http://localhost:5000/v3/auth/tokens").
55
55
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
56
56
 
57
- auth = Misty::AuthV3.new(authv3_creds)
57
+ auth = Misty::AuthV3.new(authv3_creds, false, Logger.new('/dev/null'))
58
58
  auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
59
59
  end
60
60
  end
@@ -65,7 +65,7 @@ describe Misty::Auth do
65
65
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
66
66
 
67
67
  proc do
68
- Misty::AuthV2.new({})
68
+ Misty::AuthV2.new({}, false, Logger.new('/dev/null'))
69
69
  end.must_raise Misty::Auth::CredentialsError
70
70
  end
71
71
 
@@ -73,7 +73,7 @@ describe Misty::Auth do
73
73
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
74
74
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
75
75
 
76
- auth = Misty::AuthV2.new(authv2_creds)
76
+ auth = Misty::AuthV2.new(authv2_creds, false, Logger.new('/dev/null'))
77
77
  auth.stub :expired?, false do
78
78
  auth.get_token.must_equal "token_data"
79
79
  end
@@ -83,7 +83,7 @@ describe Misty::Auth do
83
83
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
84
84
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
85
85
 
86
- auth = Misty::AuthV2.new(authv2_creds)
86
+ auth = Misty::AuthV2.new(authv2_creds, false, Logger.new('/dev/null'))
87
87
  auth.catalog.must_equal ["catalog_data"]
88
88
  end
89
89
 
@@ -91,7 +91,7 @@ describe Misty::Auth do
91
91
  stub_request(:post, "http://localhost:5000/v2.0/tokens").
92
92
  to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
93
93
 
94
- auth = Misty::AuthV2.new(authv2_creds)
94
+ auth = Misty::AuthV2.new(authv2_creds, false, Logger.new('/dev/null'))
95
95
  auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
96
96
  end
97
97
  end
@@ -42,7 +42,7 @@ describe Misty::HTTP::Client do
42
42
  describe "#net_http" do
43
43
  it "returns a Net/http instance" do
44
44
  uri = URI.parse("http://localhost")
45
- service.send(:net_http, uri).must_be_instance_of Net::HTTP
45
+ service.send(:net_http, uri, false, Logger.new("/dev/null")).must_be_instance_of Net::HTTP
46
46
  end
47
47
  end
48
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
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-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -124,11 +124,13 @@ files:
124
124
  - lib/misty/auth.rb
125
125
  - lib/misty/auth/auth_v2.rb
126
126
  - lib/misty/auth/auth_v3.rb
127
+ - lib/misty/auth/name.rb
127
128
  - lib/misty/autoload.rb
128
129
  - lib/misty/cloud.rb
129
130
  - lib/misty/http/client.rb
130
131
  - lib/misty/http/direct.rb
131
132
  - lib/misty/http/method_builder.rb
133
+ - lib/misty/http/net_http.rb
132
134
  - lib/misty/http/request.rb
133
135
  - lib/misty/misty.rb
134
136
  - lib/misty/openstack/aodh/aodh_v2.rb
@@ -186,6 +188,7 @@ files:
186
188
  - test/integration/vcr/compute_using_nova_v2_1.yml
187
189
  - test/integration/vcr/network_using_neutron_v2_0.yml
188
190
  - test/integration/vcr/orchestration_using_heat_v1.yml
191
+ - test/unit/auth/name_test.rb
189
192
  - test/unit/auth_helper.rb
190
193
  - test/unit/auth_test.rb
191
194
  - test/unit/cloud/requests_test.rb