misty 0.6.1 → 0.6.2

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: 199084962ac01539f791b1d9c2f825250dac494d
4
- data.tar.gz: b83a3c147b00475928747f9ad234667cb93f92fe
3
+ metadata.gz: 0b46444639b793223b76621ff379c0bf749ba3a1
4
+ data.tar.gz: 6866fbf4eb5b156f9e630b4b4a812a485f0645a9
5
5
  SHA512:
6
- metadata.gz: a46ae9b346bf59365903f900602ffda726ea82f7d699621a2009909287306398f09a6577d0413e48449510aa50a8ef437088747110eda7b4d7aca5c57e0d22a6
7
- data.tar.gz: 5d344630bc6c7fb6a857cf0c0aa429a610345c3deb633ac41dc7c73315c5bcae566b1296d34f25a7fc9ec42ee0c3e8001bc5da178145fc640141ab25612bcc85
6
+ metadata.gz: e720372b9ea867e4dc8a5ad1a4b71fc2a9bbdbb93180c96a1c08a406ad4e41142afd076e43af7beafeb7fb6155e293205573abaa5bf5aae90932432c47cb2acc
7
+ data.tar.gz: cb9cbf61569180b18c59593f6732406492e16f6d4b2c61be05d00e78a4f67df12cc2cf86d97a4687d7ccc0f6b51f6a29d7ab44fc469e56fced081f2c4227d708
data/README.md CHANGED
@@ -15,11 +15,12 @@ APIs experience.
15
15
  * Direct HTTP Methods for custom needs
16
16
 
17
17
  ## A solid KISS
18
- For REST transactions, Misty uses only Net/HTTP from the Ruby Standard Library. So besides 'json', no other gem are
19
- required.
20
- Because OpenStack authentication and Service Catalog management are very specific and shared by all the APIs, once taken
21
- care of, there is no need for a complex HTTP framework.
22
- This offers a solid foundation with reduced dependencies.
18
+ For REST transactions, Misty relies on Net/HTTP, from the Standard Library, therefore no other gem is required
19
+ besides 'json'.
20
+
21
+ The choice to not use the help of a more complex HTTP framework reduces dependencies.
22
+ Effectively, once taken care of, the authentication process provides a Service Catalog which allow to serve all
23
+ available APIs.
23
24
 
24
25
  ## APIs Definitions
25
26
  The rich variety of OpenStack projects requires lots of Application Program Interfaces to handle.
@@ -152,10 +153,14 @@ The following parameters can be used:
152
153
  User domain id
153
154
  * `:user_domain`
154
155
  User domain name
155
- * `:password`
156
+ * `:password`
156
157
  Password for user. Cannot be used together with `:token`.
157
- * `:token`
158
- Previous Keystone v3 token for user. Can only be used with Keystone v3. Overrides all user and password parameters.
158
+ * `:token`
159
+ User provided token, overrides all user and password parameters.
160
+ * `:context`
161
+ I you have a proper context with `token id`, `service catalog` and `expire date` you can bypass the authentication to save the api call
162
+ Overrides all user and password parameters
163
+ Example: ``{:context => { :token => token_id, :catalog => service_catalog, :expires => expire_date }}``
159
164
 
160
165
  #### Keystone v3
161
166
  Keystone v3 is default recommended version:
@@ -17,8 +17,11 @@ module Misty
17
17
  attr_reader :catalog
18
18
 
19
19
  def self.factory(auth, config)
20
- raise URLError, "No URL provided" unless auth[:url] && !auth[:url].empty?
21
- http = Misty::HTTP::NetHTTP.net_http(URI.parse(auth[:url]), config.ssl_verify_mode, config.log)
20
+ http = nil
21
+ unless auth[:context]
22
+ raise URLError, "No URL provided" unless auth[:url] && !auth[:url].empty?
23
+ http = Misty::HTTP::NetHTTP.net_http(URI.parse(auth[:url]), config.ssl_verify_mode, config.log)
24
+ end
22
25
 
23
26
  if auth[:tenant_id] || auth[:tenant]
24
27
  return Misty::AuthV2.new(auth, http)
@@ -28,9 +31,17 @@ module Misty
28
31
  end
29
32
 
30
33
  def initialize(auth, http)
31
- @http = http
32
- @credentials = set_credentials(auth)
33
- @token, @catalog, @expires = set(authenticate)
34
+ if auth[:context]
35
+ # bypass the authentication by given token catalog and expire date
36
+ @token = auth[:context][:token]
37
+ @catalog = auth[:context][:catalog]
38
+ @expires = auth[:context][:expires]
39
+ else
40
+ @http = http
41
+ # autheticate
42
+ @credentials = set_credentials(auth)
43
+ @token, @catalog, @expires = set(authenticate)
44
+ end
34
45
  end
35
46
 
36
47
  def authenticate
@@ -57,9 +57,13 @@ module Misty
57
57
  def set_credentials(auth)
58
58
  if auth[:project_id] || auth[:project]
59
59
  # scope: project
60
- project_domain_id = auth[:project_domain_id] ? auth[:project_domain_id] : Misty::DOMAIN_ID
60
+ project_domain_id = auth[:project_domain_id]
61
+ if project_domain_id.nil? && auth[:project_domain].nil?
62
+ project_domain_id = Misty::DOMAIN_ID
63
+ end
64
+
61
65
  @project = Misty::Auth::ProjectScope.new(auth[:project_id], auth[:project])
62
- @project.domain = Misty::Auth::Name.new(project_domain_id, auth[:user_domain])
66
+ @project.domain = Misty::Auth::Name.new(project_domain_id, auth[:project_domain])
63
67
  else
64
68
  # scope: domain
65
69
  if auth[:domain_id] || auth[:domain]
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -10,10 +10,11 @@ end
10
10
 
11
11
  def auth
12
12
  {
13
- :url => "http://192.0.2.21:5000",
14
- :user => "admin",
15
- :password => "CJk9hb2ZFR96Ypu74KFFGWuhv",
16
- :project => "admin",
17
- :domain => "default"
13
+ :url => "http://192.0.2.21:5000",
14
+ :user => "admin",
15
+ :password => "CJk9hb2ZFR96Ypu74KFFGWuhv",
16
+ :project => "admin",
17
+ :project_domain_id => 'default',
18
+ :domain => "default"
18
19
  }
19
20
  end
@@ -152,10 +152,11 @@ describe Misty::Auth do
152
152
  describe "when authenticated" do
153
153
  let(:authv3_creds) do
154
154
  {
155
- :url => "http://localhost:5000",
156
- :user => "admin",
157
- :password => "secret",
158
- :project => "admin"
155
+ :url => "http://localhost:5000",
156
+ :user => "admin",
157
+ :password => "secret",
158
+ :project => "admin",
159
+ :project_domain_id=> 'default'
159
160
  }
160
161
  end
161
162
 
@@ -4,11 +4,12 @@ require 'auth_helper'
4
4
  describe Misty::Cloud do
5
5
  let(:cloud) do
6
6
  auth = {
7
- :url => "http://localhost:5000",
8
- :user => "admin",
9
- :password => "secret",
10
- :project => "admin",
11
- :domain => "default"
7
+ :url => "http://localhost:5000",
8
+ :user => "admin",
9
+ :password => "secret",
10
+ :project => "admin",
11
+ :project_domain_id => 'default',
12
+ :domain => "default"
12
13
  }
13
14
 
14
15
  Misty::Cloud.new(:auth => auth)
@@ -7,7 +7,8 @@ describe "Misty::Cloud" do
7
7
  :url => "http://localhost:5000",
8
8
  :user => "admin",
9
9
  :password => "secret",
10
- :project => "admin"
10
+ :project => "admin",
11
+ :project_domain_id => "default"
11
12
  }
12
13
 
13
14
  Misty::Cloud.new(:auth => auth)
@@ -18,10 +18,11 @@ describe Misty::Cloud do
18
18
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
19
19
 
20
20
  auth = {
21
- :url => "http://localhost:5000",
22
- :user => "admin",
23
- :password => "secret",
24
- :project => "admin",
21
+ :url => "http://localhost:5000",
22
+ :user => "admin",
23
+ :password => "secret",
24
+ :project => "admin",
25
+ :project_domain_id => 'default'
25
26
  }
26
27
  end
27
28
 
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.6.1
4
+ version: 0.6.2
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-05-29 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.5.2
235
+ rubygems_version: 2.6.11
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Misty is an OpenStack API client