misty 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +332 -267
  3. data/lib/misty.rb +1 -1
  4. data/lib/misty/auth.rb +17 -6
  5. data/lib/misty/auth/auth_v2.rb +3 -0
  6. data/lib/misty/auth/auth_v3.rb +13 -5
  7. data/lib/misty/auth/name.rb +3 -3
  8. data/lib/misty/client_pack.rb +2 -2
  9. data/lib/misty/cloud.rb +111 -76
  10. data/lib/misty/config.rb +138 -0
  11. data/lib/misty/{auth/errors.rb → errors.rb} +9 -1
  12. data/lib/misty/http/direct.rb +18 -1
  13. data/lib/misty/http/method_builder.rb +10 -17
  14. data/lib/misty/http/net_http.rb +1 -1
  15. data/lib/misty/http/request.rb +26 -14
  16. data/lib/misty/microversion.rb +22 -41
  17. data/lib/misty/misty.rb +14 -24
  18. data/lib/misty/openstack/cinder/v3.rb +8 -0
  19. data/lib/misty/openstack/ironic/v1.rb +8 -0
  20. data/lib/misty/openstack/magnum/v1.rb +5 -1
  21. data/lib/misty/openstack/manila/v2.rb +8 -0
  22. data/lib/misty/openstack/nova/v2_1.rb +13 -8
  23. data/lib/misty/openstack/service.rb +88 -0
  24. data/lib/misty/openstack/swift/v1.rb +2 -2
  25. data/lib/misty/service.rb +9 -12
  26. data/lib/misty/version.rb +1 -1
  27. data/test/integration/{network_test.rb → networking_test.rb} +8 -8
  28. data/test/integration/test_helper.rb +1 -0
  29. data/test/integration/vcr/{network_using_neutron_v2_0.yml → networking_using_neutron_v2_0.yml} +0 -0
  30. data/test/unit/auth/name_test.rb +31 -27
  31. data/test/unit/auth_helper.rb +4 -4
  32. data/test/unit/auth_test.rb +44 -30
  33. data/test/unit/cloud/config_test.rb +165 -0
  34. data/test/unit/cloud/requests_test.rb +0 -12
  35. data/test/unit/cloud/services_test.rb +41 -12
  36. data/test/unit/cloud_test.rb +35 -44
  37. data/test/unit/http/request_test.rb +1 -1
  38. data/test/unit/microversion_test.rb +59 -35
  39. data/test/unit/misty_test.rb +1 -1
  40. data/test/unit/openstack/service_test.rb +52 -0
  41. data/test/unit/service_helper.rb +23 -20
  42. data/test/unit/services_test.rb +1 -1
  43. data/test/unit/test_helper.rb +0 -4
  44. metadata +37 -22
  45. data/lib/misty/client.rb +0 -104
  46. data/test/unit/client_test.rb +0 -97
@@ -0,0 +1,88 @@
1
+ module Misty
2
+ module Openstack
3
+ module Service
4
+ attr_reader :headers, :microversion
5
+
6
+ # ==== Attributes
7
+ #
8
+ # * +arg+ - +Misty::Config+ instance
9
+ #
10
+ def initialize(arg)
11
+ @auth = arg[:auth]
12
+ @log = arg[:log]
13
+ @config = arg[:config]
14
+
15
+ @content_type = @config[:content_type]
16
+ @headers = Misty::HTTP::Header.new(@config[:headers].get.clone)
17
+ @ssl_verify_mode = @config[:ssl_verify_mode]
18
+
19
+ @uri = URI.parse(@auth.get_url(service_names, @config[:region_id], @config[:interface]))
20
+
21
+ @base_path = @config[:base_path] ? @config[:base_path] : @uri.path
22
+ @base_path = @base_path.chomp('/')
23
+ @base_url = @config[:base_url] ? @config[:base_url] : nil
24
+
25
+ if microversion
26
+ asked_version = @config[:version] ? @config[:version] : ''
27
+ @version = set_version(asked_version)
28
+ end
29
+ end
30
+
31
+ # When a catalog provides a base path and the Service API definition containts the generic equivalent as prefix
32
+ # then the preifx is redundant and must be removed from the path.
33
+ #
34
+ # To use Mixing classes must override
35
+ #
36
+ # For exampe, if a Catalog is defined with
37
+ # 'http://192.0.2.21:8004/v1/48985e6b8da145699d411f12a3459fc'
38
+ # and Service API resource has '/v1/{tenant_id}/stacks'
39
+ # then the path prefix is ignored and path is only +/stacks+
40
+ def prefix_path_to_ignore
41
+ ''
42
+ end
43
+
44
+ # Generate available requests available for current service
45
+ def requests
46
+ requests_api + requests_custom
47
+ end
48
+
49
+ # Each option is recreated to bear new value or the one propagated from defaults, globals or service levels
50
+ def request_config(arg = {})
51
+ @request_content_type = arg[:content_type] ? arg[:content_type] : @content_type
52
+ @request_headers = Misty::HTTP::Header.new(@headers.get.clone)
53
+ @request_headers.add(arg[:headers]) if arg[:headers]
54
+ if microversion
55
+ request_version = if arg[:version]
56
+ set_version(arg[:version])
57
+ else
58
+ @version
59
+ end
60
+ @request_headers.add(microversion_header(request_version)) if request_version
61
+ end
62
+ end
63
+
64
+ # TODO: remove
65
+ def baseclass
66
+ self.class.to_s.split('::')[-1]
67
+ end
68
+
69
+ private
70
+
71
+ def requests_api
72
+ @requests_api_list ||= begin
73
+ list = []
74
+ api.each do |_path, verbs|
75
+ verbs.each do |_verb, requests|
76
+ list << requests
77
+ end
78
+ end
79
+ list.flatten!
80
+ end
81
+ end
82
+
83
+ def requests_custom
84
+ []
85
+ end
86
+ end
87
+ end
88
+ end
@@ -23,8 +23,8 @@ module Misty
23
23
 
24
24
  def bulk_delete(data)
25
25
  param = 'bulk-delete=1'
26
- header = Misty::HTTP::Header.new('Content-Type' => 'text/plain')
27
- create_update_or_delete_account_metadata(param, data, header)
26
+ @request_headers.add('Content-Type' => 'text/plain')
27
+ create_update_or_delete_account_metadata(param, data)
28
28
  end
29
29
  end
30
30
  end
@@ -16,18 +16,15 @@ module Misty
16
16
  str
17
17
  end
18
18
 
19
- def version(api_version = nil)
20
- if api_version
21
- return api_version if (@versions && @versions.include?(api_version)) || @microversion == api_version
22
- end
23
- default_version
24
- end
25
-
26
- private
27
-
28
- def default_version
29
- return @microversion if @microversion
30
- return self.versions.sort[-1]
19
+ def default_version(api_version = nil)
20
+ res = if api_version && (@versions&.include?(api_version) || api_version == @microversion)
21
+ api_version
22
+ elsif @microversion
23
+ @microversion
24
+ else
25
+ self.versions.sort[-1]
26
+ end
27
+ res
31
28
  end
32
29
  end
33
30
  end
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = '1.3.3'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- describe 'Network Service Neutron v2.0 features' do
3
+ describe 'Networking Service Neutron v2.0 features' do
4
4
  let(:auth) do
5
5
  {
6
6
  :url => 'http://192.0.2.6:5000',
@@ -13,34 +13,34 @@ describe 'Network Service Neutron v2.0 features' do
13
13
  end
14
14
 
15
15
  it 'GET/POST/PUT/DELETE requests' do
16
- VCR.use_cassette 'network using neutron v2.0' do
17
- cloud = Misty::Cloud.new(:auth => auth, :network => {:api_version => 'v2.0'})
16
+ VCR.use_cassette 'networking using neutron v2.0' do
17
+ cloud = Misty::Cloud.new(:auth => auth, :networking => {:api_version => 'v2.0'})
18
18
 
19
19
  # POST with body data
20
20
  data = Misty.to_json('network' => { 'name': 'test_network' })
21
- response = cloud.network.create_network(data)
21
+ response = cloud.networking.create_network(data)
22
22
  response.code.must_equal '201'
23
23
  id = response.body['network']['id']
24
24
  id.wont_be_empty
25
25
 
26
26
  # GET
27
- response = cloud.network.list_networks
27
+ response = cloud.networking.list_networks
28
28
  response.code.must_equal '200'
29
29
  response.body['networks'].size.must_equal 2
30
30
 
31
31
  # GET with URI value
32
- response = cloud.network.show_network_details(id)
32
+ response = cloud.networking.show_network_details(id)
33
33
  response.code.must_equal '200'
34
34
  response.body['network']['name'].must_equal 'test_network'
35
35
 
36
36
  # PUT with URI value and body data
37
37
  data = Misty.to_json('network' => { 'name': 'test_updated_network' })
38
- response = cloud.network.update_network(id, data)
38
+ response = cloud.networking.update_network(id, data)
39
39
  response.code.must_equal '200'
40
40
  response.body['network']['name'].must_equal 'test_updated_network'
41
41
 
42
42
  # DELETE with URI value
43
- response = cloud.network.delete_network(id)
43
+ response = cloud.networking.delete_network(id)
44
44
  response.code.must_equal '204'
45
45
  end
46
46
  end
@@ -4,6 +4,7 @@ require 'misty'
4
4
  require 'minitest/autorun'
5
5
  require 'vcr'
6
6
  require 'webmock/minitest'
7
+ require 'pry-byebug'
7
8
 
8
9
  VCR.configure do |config|
9
10
  config.cassette_library_dir = 'test/integration/vcr'
@@ -47,38 +47,42 @@ describe Misty::Auth::User do
47
47
  end
48
48
 
49
49
  describe '#identity' do
50
- it 'raises an error when password is missing' do
51
- proc do
50
+ describe 'succesful' do
51
+ it "with user id and user name" do
52
52
  user = Misty::Auth::User.new('user_id', 'User')
53
- user.identity
54
- end.must_raise Misty::Auth::CredentialsError
55
- end
53
+ user.password = 'secret'
54
+ user.identity.must_equal ({:user=>{:id=>'user_id', :password=>'secret'}})
55
+ end
56
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
57
+ it 'with user name and user domain name' do
58
+ user = Misty::Auth::User.new(nil, 'User')
59
+ user.password = 'secret'
60
+ user.domain = Misty::Auth::Name.new('default', nil)
61
+ user.identity.must_equal ({:user=>{:name=>'User', :domain=>{:id=>'default'}, :password=>'secret'}})
62
+ end
62
63
 
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'}})
64
+ it 'with user name and domain name' do
65
+ user = Misty::Auth::User.new(nil, 'User')
66
+ user.password = 'secret'
67
+ user.domain = Misty::Auth::Name.new(nil, 'Default')
68
+ user.identity.must_equal ({:user=>{:name=>'User', :domain=>{:name=>'Default'}, :password=>'secret'}})
69
+ end
68
70
  end
69
71
 
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
72
+ describe 'raises an error' do
73
+ it 'raises an error when password is missing' do
74
+ proc do
75
+ user = Misty::Auth::User.new('user_id', 'User')
76
+ user.identity
77
+ end.must_raise Misty::Config::CredentialsError
78
+ end
76
79
 
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
80
+ it 'with only user name and no domain' do
81
+ proc do
82
+ user = Misty::Auth::User.new(nil, 'User')
83
+ user.identity
84
+ end.must_raise Misty::Config::CredentialsError
85
+ end
82
86
  end
83
87
  end
84
88
  end
@@ -106,7 +110,7 @@ describe Misty::Auth::ProjectScope do
106
110
  proc do
107
111
  project = Misty::Auth::ProjectScope.new(nil, 'Project')
108
112
  project.identity
109
- end.must_raise Misty::Auth::CredentialsError
113
+ end.must_raise Misty::Config::CredentialsError
110
114
  end
111
115
  end
112
116
  end
@@ -2,7 +2,7 @@ def auth_response_v3(type, name)
2
2
  { 'token' =>
3
3
  { 'methods' => ['password'],
4
4
  'roles' => [{ 'id' => 'id_roles', 'name' => 'admin' }],
5
- 'expires_at' => '2016-11-29T07:45:29.908554Z',
5
+ 'expires_at' => '2017-11-29T07:45:29.908554Z',
6
6
  'project' => { 'domain' => { 'id' => 'default', 'name' => 'Default' }, 'id' => 'project_id', 'name' => 'admin' },
7
7
  'catalog' =>
8
8
  [{ 'endpoints' =>
@@ -26,14 +26,14 @@ def auth_response_v3(type, name)
26
26
  'name' => name }],
27
27
  'user' => { 'domain' => { 'id' => 'default', 'name' => 'Default' }, 'id' => 'id_user', 'name' => 'admin' },
28
28
  'audit_ids' => ['id_audits'],
29
- 'issued_at' => '2016-11-29T06:45:29.908578Z' } }
29
+ 'issued_at' => '2017-11-29T06:45:29.908578Z' } }
30
30
  end
31
31
 
32
32
  def auth_response_v2(type, name)
33
33
  { 'access' =>
34
34
  { 'token' =>
35
- { 'issued_at' => '2016-12-05T10:44:31.454741Z',
36
- 'expires' => '2016-12-05T11:44:31Z',
35
+ { 'issued_at' => '2017-12-05T10:44:31.454741Z',
36
+ 'expires' => '2017-12-05T11:44:31Z',
37
37
  'id' => '4ae647d3a5294690a3c29bc658e17e26',
38
38
  'tenant' => { 'description' => 'admin tenant', 'enabled' => true, 'id' => 'tenant_id', 'name' => 'admin' },
39
39
  'audit_ids' => ['Ye0Rq1HzTk2ggUAg8nDGbQ'] },
@@ -2,10 +2,6 @@ require 'test_helper'
2
2
  require 'auth_helper'
3
3
 
4
4
  describe Misty::Auth do
5
- let(:config) do
6
- Misty::Cloud::Config.new
7
- end
8
-
9
5
  describe Misty::AuthV3 do
10
6
  describe '#new' do
11
7
  it 'fails when missing credentials' do
@@ -13,7 +9,7 @@ describe Misty::Auth do
13
9
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {'x-subject-token'=>'token_data'})
14
10
 
15
11
  proc do
16
- Misty::AuthV3.new({}, config)
12
+ Misty::AuthV3.new({})
17
13
  end.must_raise Misty::Auth::URLError
18
14
  end
19
15
 
@@ -21,17 +17,18 @@ describe Misty::Auth do
21
17
  describe 'with a project scope' do
22
18
  it 'authenticates using a project id' do
23
19
  auth = {
24
- :url => 'http://localhost:5000',
25
- :user_id => 'user_id',
26
- :password => 'secret',
27
- :project_id => 'project_id'
20
+ :url => 'http://localhost:5000',
21
+ :user_id => 'user_id',
22
+ :password => 'secret',
23
+ :project_id => 'project_id',
24
+ :ssl_verify_mode => false
28
25
  }
29
26
 
30
27
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
31
28
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
32
29
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
33
30
 
34
- Misty::AuthV3.new(auth, config)
31
+ Misty::AuthV3.new(auth)
35
32
  end
36
33
 
37
34
  it 'authenticates using a project name and a project domain id' do
@@ -40,14 +37,31 @@ describe Misty::Auth do
40
37
  :user_id => 'user_id',
41
38
  :password => 'secret',
42
39
  :project => 'project',
43
- :project_domain_id => 'domain_id'
40
+ :project_domain_id => 'project_domain_id'
44
41
  }
45
42
 
46
43
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
47
- with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
44
+ with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"project_domain_id\"}}}}}").
45
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
46
+
47
+ Misty::AuthV3.new(auth)
48
+ end
49
+
50
+ it 'authenticates using a project name and a project domain name' do
51
+ auth = {
52
+ :url => 'http://localhost:5000',
53
+ :user => 'user',
54
+ :user_domain => 'user_domain',
55
+ :password => 'secret',
56
+ :project => 'project',
57
+ :project_domain => 'project_domain'
58
+ }
59
+
60
+ stub_request(:post, "http://localhost:5000/v3/auth/tokens").
61
+ with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"name\":\"user\",\"domain\":{\"name\":\"user_domain\"},\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"name\":\"project_domain\"}}}}}").
48
62
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
49
63
 
50
- Misty::AuthV3.new(auth, config)
64
+ Misty::AuthV3.new(auth)
51
65
  end
52
66
  end
53
67
 
@@ -64,7 +78,7 @@ describe Misty::Auth do
64
78
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
65
79
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
66
80
 
67
- Misty::AuthV3.new(auth, config)
81
+ Misty::AuthV3.new(auth)
68
82
  end
69
83
 
70
84
  it 'authenticates using a domain name' do
@@ -79,7 +93,7 @@ describe Misty::Auth do
79
93
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
80
94
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
81
95
 
82
- Misty::AuthV3.new(auth, config)
96
+ Misty::AuthV3.new(auth)
83
97
  end
84
98
  end
85
99
  end
@@ -97,7 +111,7 @@ describe Misty::Auth do
97
111
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
98
112
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
99
113
 
100
- Misty::AuthV3.new(auth, config)
114
+ Misty::AuthV3.new(auth)
101
115
  end
102
116
 
103
117
  it 'authenticates using a project name and a project domain id' do
@@ -112,7 +126,7 @@ describe Misty::Auth do
112
126
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
113
127
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
114
128
 
115
- Misty::AuthV3.new(auth, config)
129
+ Misty::AuthV3.new(auth)
116
130
  end
117
131
  end
118
132
 
@@ -128,7 +142,7 @@ describe Misty::Auth do
128
142
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
129
143
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
130
144
 
131
- Misty::AuthV3.new(auth, config)
145
+ Misty::AuthV3.new(auth)
132
146
  end
133
147
 
134
148
  it 'authenticates using a domain name' do
@@ -142,7 +156,7 @@ describe Misty::Auth do
142
156
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
143
157
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
144
158
 
145
- Misty::AuthV3.new(auth, config)
159
+ Misty::AuthV3.new(auth)
146
160
  end
147
161
  end
148
162
  end
@@ -163,7 +177,7 @@ describe Misty::Auth do
163
177
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
164
178
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
165
179
 
166
- auth = Misty::AuthV3.new(authv3_creds, config)
180
+ auth = Misty::AuthV3.new(authv3_creds)
167
181
  auth.stub :expired?, false do
168
182
  auth.get_token.must_equal 'token_data'
169
183
  end
@@ -173,7 +187,7 @@ describe Misty::Auth do
173
187
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
174
188
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
175
189
 
176
- auth = Misty::AuthV3.new(authv3_creds, config)
190
+ auth = Misty::AuthV3.new(authv3_creds)
177
191
  auth.catalog.must_equal ['catalog_data']
178
192
  end
179
193
 
@@ -181,7 +195,7 @@ describe Misty::Auth do
181
195
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
182
196
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {'x-subject-token'=>'token_data'})
183
197
 
184
- auth = Misty::AuthV3.new(authv3_creds, config)
198
+ auth = Misty::AuthV3.new(authv3_creds)
185
199
  auth.get_url(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
186
200
  end
187
201
  end
@@ -194,7 +208,7 @@ describe Misty::Auth do
194
208
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
195
209
 
196
210
  proc do
197
- Misty::AuthV2.new({}, config)
211
+ Misty::AuthV2.new({})
198
212
  end.must_raise Misty::Auth::URLError
199
213
  end
200
214
 
@@ -211,7 +225,7 @@ describe Misty::Auth do
211
225
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantName\":\"tenant\"}}").
212
226
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
213
227
 
214
- Misty::AuthV2.new(auth, config)
228
+ Misty::AuthV2.new(auth)
215
229
  end
216
230
 
217
231
  it 'authenticates using the tenant id' do
@@ -226,7 +240,7 @@ describe Misty::Auth do
226
240
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantId\":\"tenant_id\"}}").
227
241
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
228
242
 
229
- Misty::AuthV2.new(auth, config)
243
+ Misty::AuthV2.new(auth)
230
244
  end
231
245
  end
232
246
 
@@ -242,7 +256,7 @@ describe Misty::Auth do
242
256
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
243
257
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
244
258
 
245
- Misty::AuthV2.new(auth, config)
259
+ Misty::AuthV2.new(auth)
246
260
  end
247
261
 
248
262
  it 'authenticates using the tenant id' do
@@ -256,7 +270,7 @@ describe Misty::Auth do
256
270
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
257
271
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
258
272
 
259
- Misty::AuthV2.new(auth, config)
273
+ Misty::AuthV2.new(auth)
260
274
  end
261
275
  end
262
276
  end
@@ -275,7 +289,7 @@ describe Misty::Auth do
275
289
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
276
290
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
277
291
 
278
- auth = Misty::AuthV2.new(authv2_creds, config)
292
+ auth = Misty::AuthV2.new(authv2_creds)
279
293
  auth.stub :expired?, false do
280
294
  auth.get_token.must_equal 'token_data'
281
295
  end
@@ -285,7 +299,7 @@ describe Misty::Auth do
285
299
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
286
300
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
287
301
 
288
- auth = Misty::AuthV2.new(authv2_creds, config)
302
+ auth = Misty::AuthV2.new(authv2_creds)
289
303
  auth.catalog.must_equal ['catalog_data']
290
304
  end
291
305
 
@@ -293,7 +307,7 @@ describe Misty::Auth do
293
307
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
294
308
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
295
309
 
296
- auth = Misty::AuthV2.new(authv2_creds, config)
310
+ auth = Misty::AuthV2.new(authv2_creds)
297
311
  auth.get_url(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
298
312
  end
299
313
  end