misty 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/misty/auth.rb +7 -7
- data/lib/misty/auth/auth_v2.rb +25 -26
- data/lib/misty/auth/auth_v3.rb +6 -2
- data/lib/misty/http/client.rb +1 -1
- data/lib/misty/http/net_http.rb +1 -1
- data/lib/misty/services.rb +12 -4
- data/lib/misty/version.rb +1 -1
- data/test/unit/auth_test.rb +199 -69
- data/test/unit/http/client_test.rb +1 -1
- data/test/unit/services_test.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199084962ac01539f791b1d9c2f825250dac494d
|
4
|
+
data.tar.gz: b83a3c147b00475928747f9ad234667cb93f92fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46ae9b346bf59365903f900602ffda726ea82f7d699621a2009909287306398f09a6577d0413e48449510aa50a8ef437088747110eda7b4d7aca5c57e0d22a6
|
7
|
+
data.tar.gz: 5d344630bc6c7fb6a857cf0c0aa429a610345c3deb633ac41dc7c73315c5bcae566b1296d34f25a7fc9ec42ee0c3e8001bc5da178145fc640141ab25612bcc85
|
data/lib/misty/auth.rb
CHANGED
@@ -17,20 +17,20 @@ 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)
|
22
|
+
|
20
23
|
if auth[:tenant_id] || auth[:tenant]
|
21
|
-
return Misty::AuthV2.new(auth,
|
24
|
+
return Misty::AuthV2.new(auth, http)
|
22
25
|
else
|
23
|
-
return Misty::AuthV3.new(auth,
|
26
|
+
return Misty::AuthV3.new(auth, http)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
def initialize(auth,
|
28
|
-
|
30
|
+
def initialize(auth, http)
|
31
|
+
@http = http
|
29
32
|
@credentials = set_credentials(auth)
|
30
|
-
@http = net_http(URI.parse(auth[:url]), config.ssl_verify_mode, config.log)
|
31
|
-
@token = nil
|
32
33
|
@token, @catalog, @expires = set(authenticate)
|
33
|
-
raise CatalogError, "No catalog provided during authentication" if @catalog.empty?
|
34
34
|
end
|
35
35
|
|
36
36
|
def authenticate
|
data/lib/misty/auth/auth_v2.rb
CHANGED
@@ -15,35 +15,29 @@ module Misty
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def credentials
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
if @token
|
19
|
+
identity = { "token": { "id": @token } }
|
20
|
+
else
|
21
|
+
raise Misty::Auth::CredentialsError, "#{self.class}: User name is required" if @user.name.nil?
|
22
|
+
raise Misty::Auth::CredentialsError, "#{self.class}: User password is required" if @user.password.nil?
|
23
|
+
identity = { "passwordCredentials": user_credentials }
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
"
|
29
|
-
|
30
|
-
|
26
|
+
if @tenant.id
|
27
|
+
identity.merge!("tenantId": @tenant.id)
|
28
|
+
elsif @tenant.name
|
29
|
+
identity.merge!("tenantName": @tenant.name)
|
30
|
+
else
|
31
|
+
raise Misty::Auth::CredentialsError, "#{self.class}: No tenant available"
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
{
|
34
|
-
"auth": {
|
35
|
-
"passwordCredentials": credentials_data,
|
36
|
-
"tenantName": @tenant.name
|
37
|
-
}
|
38
|
-
}
|
34
|
+
{ "auth": identity }
|
39
35
|
end
|
40
36
|
|
41
|
-
def
|
37
|
+
def user_credentials
|
42
38
|
{
|
43
|
-
"
|
44
|
-
|
45
|
-
"tenantId": @tenant.id
|
46
|
-
}
|
39
|
+
"username": @user.name,
|
40
|
+
"password": @user.password
|
47
41
|
}
|
48
42
|
end
|
49
43
|
|
@@ -62,8 +56,13 @@ module Misty
|
|
62
56
|
end
|
63
57
|
|
64
58
|
def set_credentials(auth)
|
65
|
-
|
66
|
-
|
59
|
+
if auth[:token]
|
60
|
+
@token = auth[:token]
|
61
|
+
else
|
62
|
+
@user = Misty::Auth::User.new(auth[:user_id], auth[:user])
|
63
|
+
@user.password = auth[:password]
|
64
|
+
end
|
65
|
+
|
67
66
|
@tenant = Misty::Auth::Name.new(auth[:tenant_id], auth[:tenant])
|
68
67
|
credentials
|
69
68
|
end
|
data/lib/misty/auth/auth_v3.rb
CHANGED
@@ -62,8 +62,12 @@ module Misty
|
|
62
62
|
@project.domain = Misty::Auth::Name.new(project_domain_id, auth[:user_domain])
|
63
63
|
else
|
64
64
|
# scope: domain
|
65
|
-
|
66
|
-
|
65
|
+
if auth[:domain_id] || auth[:domain]
|
66
|
+
@domain = Misty::Auth::DomainScope.new(auth[:domain_id], auth[:domain])
|
67
|
+
else
|
68
|
+
# Use default Domain
|
69
|
+
@domain = Misty::Auth::DomainScope.new(Misty::DOMAIN_ID, nil)
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
if auth[:token]
|
data/lib/misty/http/client.rb
CHANGED
@@ -54,7 +54,7 @@ module Misty
|
|
54
54
|
@uri = URI.parse(@auth.get_endpoint(@options.service_names, @options.region_id, @options.interface))
|
55
55
|
@base_path = @options.base_path ? @options.base_path : @uri.path
|
56
56
|
@base_path = @base_path.chomp("/")
|
57
|
-
@http = net_http(@uri, @options.ssl_verify_mode, @config.log)
|
57
|
+
@http = Misty::HTTP::NetHTTP.net_http(@uri, @options.ssl_verify_mode, @config.log)
|
58
58
|
@version = nil
|
59
59
|
@microversion = false
|
60
60
|
end
|
data/lib/misty/http/net_http.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Misty
|
2
2
|
module HTTP
|
3
3
|
module NetHTTP
|
4
|
-
def net_http(endpoint, ssl_verify_mode, log)
|
4
|
+
def self.net_http(endpoint, ssl_verify_mode, log)
|
5
5
|
http = Net::HTTP.new(endpoint.host, endpoint.port)
|
6
6
|
http.set_debug_output(log) if log.level == Logger::DEBUG
|
7
7
|
if endpoint.scheme == "https"
|
data/lib/misty/services.rb
CHANGED
@@ -14,6 +14,10 @@ module Misty
|
|
14
14
|
@options = val
|
15
15
|
end
|
16
16
|
|
17
|
+
def to_s
|
18
|
+
"#{name}: #{project}: #{versions}"
|
19
|
+
end
|
20
|
+
|
17
21
|
def version=(val)
|
18
22
|
if @versions.include?(val)
|
19
23
|
@version = val
|
@@ -22,10 +26,6 @@ module Misty
|
|
22
26
|
@version = versions.sort[-1]
|
23
27
|
end
|
24
28
|
end
|
25
|
-
|
26
|
-
def to_s
|
27
|
-
"#{name}: #{project} => #{versions}"
|
28
|
-
end
|
29
29
|
end
|
30
30
|
|
31
31
|
include Enumerable
|
@@ -45,5 +45,13 @@ module Misty
|
|
45
45
|
yield service
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
list = ""
|
51
|
+
@services.each do |service|
|
52
|
+
list << service.to_s + "\n"
|
53
|
+
end
|
54
|
+
list
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
data/lib/misty/version.rb
CHANGED
data/test/unit/auth_test.rb
CHANGED
@@ -2,77 +2,154 @@ require 'test_helper'
|
|
2
2
|
require 'auth_helper'
|
3
3
|
|
4
4
|
describe Misty::Auth do
|
5
|
-
let(:
|
6
|
-
|
7
|
-
|
8
|
-
config.ssl_verify_mode = false
|
9
|
-
config
|
5
|
+
let(:http) do
|
6
|
+
endpoint = URI.parse("http://localhost:5000")
|
7
|
+
Net::HTTP.new(endpoint.host, endpoint.port)
|
10
8
|
end
|
11
9
|
|
12
10
|
describe Misty::AuthV3 do
|
13
11
|
describe "#new" do
|
14
|
-
it "
|
15
|
-
auth = {
|
16
|
-
:url => "http://localhost:5000",
|
17
|
-
:user_id => "user_id",
|
18
|
-
:password => "secret",
|
19
|
-
:project_id => "project_id"
|
20
|
-
}
|
21
|
-
|
12
|
+
it "fails when missing credentials" do
|
22
13
|
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
23
|
-
|
24
|
-
:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
|
25
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
14
|
+
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {"x-subject-token"=>"token_data"})
|
26
15
|
|
27
|
-
|
16
|
+
proc do
|
17
|
+
Misty::AuthV3.new({}, http)
|
18
|
+
end.must_raise Misty::Auth::CredentialsError
|
28
19
|
end
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
describe "using the password method" do
|
22
|
+
describe "with a project scope" do
|
23
|
+
it "authenticates using a project id" do
|
24
|
+
auth = {
|
25
|
+
:url => "http://localhost:5000",
|
26
|
+
:user_id => "user_id",
|
27
|
+
:password => "secret",
|
28
|
+
:project_id => "project_id"
|
29
|
+
}
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
31
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
32
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
|
33
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
41
34
|
|
42
|
-
|
43
|
-
|
35
|
+
Misty::AuthV3.new(auth, http)
|
36
|
+
end
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
it "authenticates using a project name and a project domain id" do
|
39
|
+
auth = {
|
40
|
+
:url => "http://localhost:5000",
|
41
|
+
:user_id => "user_id",
|
42
|
+
:password => "secret",
|
43
|
+
:project => "project",
|
44
|
+
:project_domain_id => "domain_id"
|
45
|
+
}
|
51
46
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
48
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
|
49
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
50
|
+
|
51
|
+
Misty::AuthV3.new(auth, http)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "with a domain scope" do
|
56
|
+
it "authenticates using a domain id" do
|
57
|
+
auth = {
|
58
|
+
:url => "http://localhost:5000",
|
59
|
+
:user_id => "user_id",
|
60
|
+
:password => "secret",
|
61
|
+
:domain_id => "domain_id"
|
62
|
+
}
|
63
|
+
|
64
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
65
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
|
66
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
56
67
|
|
57
|
-
|
68
|
+
Misty::AuthV3.new(auth, http)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "authenticates using a domain name" do
|
72
|
+
auth = {
|
73
|
+
:url => "http://localhost:5000",
|
74
|
+
:user_id => "user_id",
|
75
|
+
:password => "secret",
|
76
|
+
:domain => "domain"
|
77
|
+
}
|
78
|
+
|
79
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
80
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
|
81
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
82
|
+
|
83
|
+
Misty::AuthV3.new(auth, http)
|
84
|
+
end
|
85
|
+
end
|
58
86
|
end
|
59
87
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
88
|
+
describe "using the token method" do
|
89
|
+
describe "with a project scope" do
|
90
|
+
it "authenticates using a project id" do
|
91
|
+
auth = {
|
92
|
+
:url => "http://localhost:5000",
|
93
|
+
:token => "token",
|
94
|
+
:project_id => "project_id"
|
95
|
+
}
|
65
96
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
97
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
98
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
|
99
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
100
|
+
|
101
|
+
Misty::AuthV3.new(auth, http)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "authenticates using a project name and a project domain id" do
|
105
|
+
auth = {
|
106
|
+
:url => "http://localhost:5000",
|
107
|
+
:token => "token",
|
108
|
+
:project => "project",
|
109
|
+
:project_domain_id => "domain_id"
|
110
|
+
}
|
111
|
+
|
112
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
113
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
|
114
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
115
|
+
|
116
|
+
Misty::AuthV3.new(auth, http)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "with a domain scope" do
|
121
|
+
it "authenticates using a domain id" do
|
122
|
+
auth = {
|
123
|
+
:url => "http://localhost:5000",
|
124
|
+
:token => "token",
|
125
|
+
:domain_id => "domain_id"
|
126
|
+
}
|
127
|
+
|
128
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
129
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
|
130
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
70
131
|
|
71
|
-
|
132
|
+
Misty::AuthV3.new(auth, http)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "authenticates using a domain name" do
|
136
|
+
auth = {
|
137
|
+
:url => "http://localhost:5000",
|
138
|
+
:token => "token",
|
139
|
+
:domain => "domain"
|
140
|
+
}
|
141
|
+
|
142
|
+
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
143
|
+
with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
|
144
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
145
|
+
|
146
|
+
Misty::AuthV3.new(auth, http)
|
147
|
+
end
|
148
|
+
end
|
72
149
|
end
|
73
150
|
end
|
74
151
|
|
75
|
-
describe "
|
152
|
+
describe "when authenticated" do
|
76
153
|
let(:authv3_creds) do
|
77
154
|
{
|
78
155
|
:url => "http://localhost:5000",
|
@@ -82,20 +159,11 @@ describe Misty::Auth do
|
|
82
159
|
}
|
83
160
|
end
|
84
161
|
|
85
|
-
it "fails when missing credentials" do
|
86
|
-
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
87
|
-
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {"x-subject-token"=>"token_data"})
|
88
|
-
|
89
|
-
proc do
|
90
|
-
Misty::AuthV3.new({}, config)
|
91
|
-
end.must_raise Misty::Auth::URLError
|
92
|
-
end
|
93
|
-
|
94
162
|
it "#get_token" do
|
95
163
|
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
96
164
|
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
|
97
165
|
|
98
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
166
|
+
auth = Misty::AuthV3.new(authv3_creds, http)
|
99
167
|
auth.stub :expired?, false do
|
100
168
|
auth.get_token.must_equal "token_data"
|
101
169
|
end
|
@@ -105,7 +173,7 @@ describe Misty::Auth do
|
|
105
173
|
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
106
174
|
to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
|
107
175
|
|
108
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
176
|
+
auth = Misty::AuthV3.new(authv3_creds, http)
|
109
177
|
auth.catalog.must_equal ["catalog_data"]
|
110
178
|
end
|
111
179
|
|
@@ -113,7 +181,7 @@ describe Misty::Auth do
|
|
113
181
|
stub_request(:post, "http://localhost:5000/v3/auth/tokens").
|
114
182
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
115
183
|
|
116
|
-
auth = Misty::AuthV3.new(authv3_creds,
|
184
|
+
auth = Misty::AuthV3.new(authv3_creds, http)
|
117
185
|
auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
|
118
186
|
end
|
119
187
|
end
|
@@ -126,12 +194,74 @@ describe Misty::Auth do
|
|
126
194
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
|
127
195
|
|
128
196
|
proc do
|
129
|
-
Misty::AuthV2.new({},
|
130
|
-
end.must_raise Misty::Auth::
|
197
|
+
Misty::AuthV2.new({}, http)
|
198
|
+
end.must_raise Misty::Auth::CredentialsError
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "using the password method" do
|
202
|
+
it "authenticates using the tenant name" do
|
203
|
+
auth = {
|
204
|
+
:url => "http://localhost:5000",
|
205
|
+
:user => "user",
|
206
|
+
:password => "secret",
|
207
|
+
:tenant => "tenant",
|
208
|
+
}
|
209
|
+
|
210
|
+
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
211
|
+
with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantName\":\"tenant\"}}").
|
212
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
|
213
|
+
|
214
|
+
Misty::AuthV2.new(auth, http)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "authenticates using the tenant id" do
|
218
|
+
auth = {
|
219
|
+
:url => "http://localhost:5000",
|
220
|
+
:user => "user",
|
221
|
+
:password => "secret",
|
222
|
+
:tenant_id => "tenant_id",
|
223
|
+
}
|
224
|
+
|
225
|
+
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
226
|
+
with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantId\":\"tenant_id\"}}").
|
227
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
|
228
|
+
|
229
|
+
Misty::AuthV2.new(auth, http)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "using the token method" do
|
234
|
+
it "authenticates using the tenant name" do
|
235
|
+
auth = {
|
236
|
+
:url => "http://localhost:5000",
|
237
|
+
:token => "token_id",
|
238
|
+
:tenant => "tenant",
|
239
|
+
}
|
240
|
+
|
241
|
+
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
242
|
+
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
|
243
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
|
244
|
+
|
245
|
+
Misty::AuthV2.new(auth, http)
|
246
|
+
end
|
247
|
+
|
248
|
+
it "authenticates using the tenant id" do
|
249
|
+
auth = {
|
250
|
+
:url => "http://localhost:5000",
|
251
|
+
:token => "token_id",
|
252
|
+
:tenant_id => "tenant_id",
|
253
|
+
}
|
254
|
+
|
255
|
+
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
256
|
+
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
|
257
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
|
258
|
+
|
259
|
+
Misty::AuthV2.new(auth, http)
|
260
|
+
end
|
131
261
|
end
|
132
262
|
end
|
133
263
|
|
134
|
-
describe "
|
264
|
+
describe "when authenticated" do
|
135
265
|
let(:authv2_creds) do
|
136
266
|
{
|
137
267
|
:url => "http://localhost:5000",
|
@@ -145,7 +275,7 @@ describe Misty::Auth do
|
|
145
275
|
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
146
276
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
|
147
277
|
|
148
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
278
|
+
auth = Misty::AuthV2.new(authv2_creds, http)
|
149
279
|
auth.stub :expired?, false do
|
150
280
|
auth.get_token.must_equal "token_data"
|
151
281
|
end
|
@@ -155,7 +285,7 @@ describe Misty::Auth do
|
|
155
285
|
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
156
286
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
|
157
287
|
|
158
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
288
|
+
auth = Misty::AuthV2.new(authv2_creds, http)
|
159
289
|
auth.catalog.must_equal ["catalog_data"]
|
160
290
|
end
|
161
291
|
|
@@ -163,7 +293,7 @@ describe Misty::Auth do
|
|
163
293
|
stub_request(:post, "http://localhost:5000/v2.0/tokens").
|
164
294
|
to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
|
165
295
|
|
166
|
-
auth = Misty::AuthV2.new(authv2_creds,
|
296
|
+
auth = Misty::AuthV2.new(authv2_creds, http)
|
167
297
|
auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
|
168
298
|
end
|
169
299
|
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
|
endpoint = URI.parse("http://localhost")
|
45
|
-
|
45
|
+
Misty::HTTP::NetHTTP.net_http(endpoint, false, Logger.new("/dev/null")).must_be_instance_of Net::HTTP
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/test/unit/services_test.rb
CHANGED
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.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-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|