fog-openstack 1.0.0 → 1.0.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 +4 -4
- data/lib/fog/openstack/auth/token.rb +8 -9
- data/lib/fog/openstack/core.rb +1 -1
- data/lib/fog/openstack/image/v1.rb +1 -1
- data/lib/fog/openstack/image/v2.rb +1 -1
- data/lib/fog/openstack/version.rb +1 -1
- data/unit/auth/token_test.rb +25 -25
- 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: abb817399bc80ba516784a9a377b5deaec69a7c3
|
4
|
+
data.tar.gz: a56c91075e1400e259cb38841e3eed0246469718
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f94ba6d952af85df598963158c16e2623ff8ad081e7d4198198f58e0496fa13583603b189683f7ec1ff6480b24ac4197ee38dca044ae0dee6e0fee8bc77f24
|
7
|
+
data.tar.gz: a581bdc68d1785c65f10139839688fad5b69e1d352a84df8e8836a2e50525278bf034531ad2854d111fcdd1a55693e1b01bef46d58e80e1c6c1cb2955b1fab0a
|
@@ -13,35 +13,34 @@ module Fog
|
|
13
13
|
class StandardError < RuntimeError; end
|
14
14
|
class URLError < RuntimeError; end
|
15
15
|
|
16
|
-
def self.build(auth)
|
16
|
+
def self.build(auth, options)
|
17
17
|
if auth[:openstack_identity_api_version] =~ /(v)*2(\.0)*/i ||
|
18
18
|
auth[:openstack_tenant_id] || auth[:openstack_tenant]
|
19
|
-
Fog::OpenStack::Auth::Token::V2.new(auth)
|
19
|
+
Fog::OpenStack::Auth::Token::V2.new(auth, options)
|
20
20
|
else
|
21
|
-
Fog::OpenStack::Auth::Token::V3.new(auth)
|
21
|
+
Fog::OpenStack::Auth::Token::V3.new(auth, options)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def initialize(auth)
|
25
|
+
def initialize(auth, options)
|
26
26
|
raise URLError, 'No URL provided' if auth[:openstack_auth_url].nil? || auth[:openstack_auth_url].empty?
|
27
27
|
@creds = {
|
28
28
|
:data => build_credentials(auth),
|
29
29
|
:uri => URI.parse(auth[:openstack_auth_url])
|
30
30
|
}
|
31
|
-
response = authenticate(@creds)
|
31
|
+
response = authenticate(@creds, options)
|
32
32
|
set(response)
|
33
33
|
end
|
34
34
|
|
35
35
|
def get
|
36
|
-
set(authenticate(@creds)) if expired?
|
36
|
+
set(authenticate(@creds, {})) if expired?
|
37
37
|
@token
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def authenticate(creds)
|
43
|
-
|
44
|
-
connection = Fog::Core::Connection.new(creds[:uri].to_s, false, connection_options)
|
42
|
+
def authenticate(creds, options)
|
43
|
+
connection = Fog::Core::Connection.new(creds[:uri].to_s, false, options)
|
45
44
|
|
46
45
|
request = {
|
47
46
|
:expects => [200, 201],
|
data/lib/fog/openstack/core.rb
CHANGED
@@ -206,7 +206,7 @@ module Fog
|
|
206
206
|
if !@openstack_management_url || @openstack_must_reauthenticate
|
207
207
|
@openstack_auth_token = nil if @openstack_must_reauthenticate
|
208
208
|
|
209
|
-
token = Fog::OpenStack::Auth::Token.build(openstack_options)
|
209
|
+
token = Fog::OpenStack::Auth::Token.build(openstack_options, @connection_options)
|
210
210
|
|
211
211
|
@openstack_management_url = if token.catalog
|
212
212
|
token.catalog.get_endpoint_url(
|
data/unit/auth/token_test.rb
CHANGED
@@ -13,7 +13,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
13
13
|
)
|
14
14
|
|
15
15
|
proc do
|
16
|
-
Fog::OpenStack::Auth::Token.build({})
|
16
|
+
Fog::OpenStack::Auth::Token.build({}, {})
|
17
17
|
end.must_raise Fog::OpenStack::Auth::Token::URLError
|
18
18
|
end
|
19
19
|
|
@@ -36,7 +36,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
36
36
|
:headers => {'x-subject-token'=>'token_data_v3'}
|
37
37
|
)
|
38
38
|
|
39
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
39
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
40
40
|
token.get.must_equal 'token_data_v3'
|
41
41
|
end
|
42
42
|
|
@@ -59,7 +59,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
59
59
|
:headers => {'x-subject-token'=>'token_data'}
|
60
60
|
)
|
61
61
|
|
62
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
62
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
63
63
|
token.get.must_equal 'token_data'
|
64
64
|
end
|
65
65
|
|
@@ -83,7 +83,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
83
83
|
:headers => {'x-subject-token'=>'token_data'}
|
84
84
|
)
|
85
85
|
|
86
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
86
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
87
87
|
token.get.must_equal 'token_data'
|
88
88
|
end
|
89
89
|
end
|
@@ -106,7 +106,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
106
106
|
:headers => {'x-subject-token'=>'token_data'}
|
107
107
|
)
|
108
108
|
|
109
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
109
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
110
110
|
token.get.must_equal 'token_data'
|
111
111
|
end
|
112
112
|
|
@@ -127,7 +127,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
127
127
|
:headers => {'x-subject-token'=>'token_data'}
|
128
128
|
)
|
129
129
|
|
130
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
130
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
131
131
|
token.get.must_equal 'token_data'
|
132
132
|
end
|
133
133
|
end
|
@@ -149,7 +149,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
149
149
|
:headers => {'x-subject-token'=>'token_data'}
|
150
150
|
)
|
151
151
|
|
152
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
152
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
153
153
|
token.get.must_equal 'token_data'
|
154
154
|
end
|
155
155
|
end
|
@@ -171,7 +171,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
171
171
|
:headers => {'x-subject-token'=>'token_data'}
|
172
172
|
)
|
173
173
|
|
174
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
174
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
175
175
|
token.get.must_equal 'token_data'
|
176
176
|
end
|
177
177
|
end
|
@@ -193,7 +193,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
193
193
|
:headers => {'x-subject-token'=>'token_data'}
|
194
194
|
)
|
195
195
|
|
196
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
196
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
197
197
|
token.get.must_equal 'token_data'
|
198
198
|
end
|
199
199
|
|
@@ -214,7 +214,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
214
214
|
:headers => {'x-subject-token'=>'token_data'}
|
215
215
|
)
|
216
216
|
|
217
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
217
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
218
218
|
token.get.must_equal 'token_data'
|
219
219
|
end
|
220
220
|
end
|
@@ -236,7 +236,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
236
236
|
:headers => {'x-subject-token'=>'token_data'}
|
237
237
|
)
|
238
238
|
|
239
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
239
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
240
240
|
token.get.must_equal 'token_data'
|
241
241
|
end
|
242
242
|
|
@@ -256,7 +256,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
256
256
|
:headers => {'x-subject-token'=>'token_data'}
|
257
257
|
)
|
258
258
|
|
259
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
259
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
260
260
|
token.get.must_equal 'token_data'
|
261
261
|
end
|
262
262
|
end
|
@@ -283,7 +283,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
283
283
|
:headers => {'x-subject-token'=>'token_data'}
|
284
284
|
)
|
285
285
|
|
286
|
-
token = Fog::OpenStack::Auth::Token.build(authv3_creds)
|
286
|
+
token = Fog::OpenStack::Auth::Token.build(authv3_creds, {})
|
287
287
|
token.stub :expired?, false do
|
288
288
|
token.get.must_equal 'token_data'
|
289
289
|
end
|
@@ -297,7 +297,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
297
297
|
:headers => {'x-subject-token'=>'token_data'}
|
298
298
|
)
|
299
299
|
|
300
|
-
token = Fog::OpenStack::Auth::Token.build(authv3_creds)
|
300
|
+
token = Fog::OpenStack::Auth::Token.build(authv3_creds, {})
|
301
301
|
token.stub :expired?, true do
|
302
302
|
token.get.must_equal 'token_data'
|
303
303
|
end
|
@@ -312,7 +312,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
312
312
|
:headers => {'x-subject-token'=>'token_data'}
|
313
313
|
)
|
314
314
|
|
315
|
-
token = Fog::OpenStack::Auth::Token.build(authv3_creds)
|
315
|
+
token = Fog::OpenStack::Auth::Token.build(authv3_creds, {})
|
316
316
|
token.catalog.payload.must_equal ['catalog_data']
|
317
317
|
end
|
318
318
|
|
@@ -324,7 +324,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
324
324
|
:headers => {'x-subject-token'=>'token_data'}
|
325
325
|
)
|
326
326
|
|
327
|
-
token = Fog::OpenStack::Auth::Token.build(authv3_creds)
|
327
|
+
token = Fog::OpenStack::Auth::Token.build(authv3_creds, {})
|
328
328
|
token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne').must_equal 'http://localhost'
|
329
329
|
end
|
330
330
|
end
|
@@ -337,7 +337,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
337
337
|
to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
|
338
338
|
|
339
339
|
proc do
|
340
|
-
Fog::OpenStack::Auth::Token.build({})
|
340
|
+
Fog::OpenStack::Auth::Token.build({}, {})
|
341
341
|
end.must_raise Fog::OpenStack::Auth::Token::URLError
|
342
342
|
end
|
343
343
|
|
@@ -355,7 +355,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
355
355
|
\"tenantName\":\"tenant\"}}").
|
356
356
|
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
357
357
|
|
358
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
358
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
359
359
|
token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
|
360
360
|
end
|
361
361
|
|
@@ -372,7 +372,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
372
372
|
\"tenantId\":\"tenant_id\"}}").
|
373
373
|
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
374
374
|
|
375
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
375
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
376
376
|
token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
|
377
377
|
end
|
378
378
|
end
|
@@ -389,7 +389,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
389
389
|
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
|
390
390
|
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
391
391
|
|
392
|
-
token = Fog::OpenStack::Auth::Token.build(auth)
|
392
|
+
token = Fog::OpenStack::Auth::Token.build(auth, {})
|
393
393
|
token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
|
394
394
|
end
|
395
395
|
|
@@ -404,7 +404,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
404
404
|
with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
|
405
405
|
to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
|
406
406
|
|
407
|
-
Fog::OpenStack::Auth::Token.build(auth)
|
407
|
+
Fog::OpenStack::Auth::Token.build(auth, {})
|
408
408
|
end
|
409
409
|
end
|
410
410
|
end
|
@@ -429,7 +429,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
429
429
|
:headers => {}
|
430
430
|
)
|
431
431
|
|
432
|
-
token = Fog::OpenStack::Auth::Token.build(authv2_creds)
|
432
|
+
token = Fog::OpenStack::Auth::Token.build(authv2_creds, {})
|
433
433
|
token.stub :expired?, false do
|
434
434
|
token.get.must_equal 'token_not_expired'
|
435
435
|
end
|
@@ -443,7 +443,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
443
443
|
:headers => {}
|
444
444
|
)
|
445
445
|
|
446
|
-
token = Fog::OpenStack::Auth::Token.build(authv2_creds)
|
446
|
+
token = Fog::OpenStack::Auth::Token.build(authv2_creds, {})
|
447
447
|
token.stub :expired?, true do
|
448
448
|
token.get.must_equal 'token_expired'
|
449
449
|
end
|
@@ -458,7 +458,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
458
458
|
:headers => {}
|
459
459
|
)
|
460
460
|
|
461
|
-
token = Fog::OpenStack::Auth::Token.build(authv2_creds)
|
461
|
+
token = Fog::OpenStack::Auth::Token.build(authv2_creds, {})
|
462
462
|
token.catalog.payload.must_equal ['catalog_data']
|
463
463
|
end
|
464
464
|
|
@@ -470,7 +470,7 @@ describe Fog::OpenStack::Auth::Token do
|
|
470
470
|
:headers => {'x-subject-token'=>'token_data'}
|
471
471
|
)
|
472
472
|
|
473
|
-
token = Fog::OpenStack::Auth::Token.build(authv2_creds)
|
473
|
+
token = Fog::OpenStack::Auth::Token.build(authv2_creds, {})
|
474
474
|
token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne').must_equal 'http://localhost'
|
475
475
|
end
|
476
476
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Darby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|