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 +4 -4
- data/README.md +13 -8
- data/lib/misty/auth.rb +16 -5
- data/lib/misty/auth/auth_v3.rb +6 -2
- data/lib/misty/version.rb +1 -1
- data/test/integration/test_helper.rb +6 -5
- data/test/unit/auth_test.rb +5 -4
- data/test/unit/cloud/requests_test.rb +6 -5
- data/test/unit/cloud/services_test.rb +2 -1
- data/test/unit/cloud_test.rb +5 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b46444639b793223b76621ff379c0bf749ba3a1
|
4
|
+
data.tar.gz: 6866fbf4eb5b156f9e630b4b4a812a485f0645a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
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:
|
data/lib/misty/auth.rb
CHANGED
@@ -17,8 +17,11 @@ module Misty
|
|
17
17
|
attr_reader :catalog
|
18
18
|
|
19
19
|
def self.factory(auth, config)
|
20
|
-
|
21
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
data/lib/misty/auth/auth_v3.rb
CHANGED
@@ -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]
|
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[:
|
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]
|
data/lib/misty/version.rb
CHANGED
@@ -10,10 +10,11 @@ end
|
|
10
10
|
|
11
11
|
def auth
|
12
12
|
{
|
13
|
-
:url
|
14
|
-
:user
|
15
|
-
:password
|
16
|
-
:project
|
17
|
-
:
|
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
|
data/test/unit/auth_test.rb
CHANGED
@@ -152,10 +152,11 @@ describe Misty::Auth do
|
|
152
152
|
describe "when authenticated" do
|
153
153
|
let(:authv3_creds) do
|
154
154
|
{
|
155
|
-
:url
|
156
|
-
:user
|
157
|
-
:password
|
158
|
-
:project
|
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
|
8
|
-
:user
|
9
|
-
:password
|
10
|
-
:project
|
11
|
-
:
|
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)
|
data/test/unit/cloud_test.rb
CHANGED
@@ -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
|
22
|
-
:user
|
23
|
-
:password
|
24
|
-
:project
|
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.
|
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-
|
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.
|
235
|
+
rubygems_version: 2.6.11
|
236
236
|
signing_key:
|
237
237
|
specification_version: 4
|
238
238
|
summary: Misty is an OpenStack API client
|