misty 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -23
  3. data/lib/misty/auth.rb +24 -19
  4. data/lib/misty/auth/auth_v2.rb +12 -12
  5. data/lib/misty/auth/auth_v3.rb +15 -15
  6. data/lib/misty/autoload.rb +27 -27
  7. data/lib/misty/cloud.rb +2 -1
  8. data/lib/misty/http/client.rb +17 -15
  9. data/lib/misty/http/method_builder.rb +1 -1
  10. data/lib/misty/http/net_http.rb +12 -7
  11. data/lib/misty/http/request.rb +13 -7
  12. data/lib/misty/misty.rb +30 -30
  13. data/lib/misty/openstack/aodh/v2.rb +1 -1
  14. data/lib/misty/openstack/ceilometer/v2.rb +1 -1
  15. data/lib/misty/openstack/cinder/v1.rb +2 -2
  16. data/lib/misty/openstack/cinder/v2.rb +2 -2
  17. data/lib/misty/openstack/cinder/v3.rb +2 -2
  18. data/lib/misty/openstack/designate/v2.rb +1 -1
  19. data/lib/misty/openstack/freezer/v1.rb +1 -1
  20. data/lib/misty/openstack/glance/v1.rb +1 -1
  21. data/lib/misty/openstack/glance/v2.rb +1 -1
  22. data/lib/misty/openstack/heat/v1.rb +2 -2
  23. data/lib/misty/openstack/ironic/v1.rb +2 -2
  24. data/lib/misty/openstack/karbor/v1.rb +1 -1
  25. data/lib/misty/openstack/keystone/v2_0.rb +2 -2
  26. data/lib/misty/openstack/keystone/v3.rb +2 -2
  27. data/lib/misty/openstack/magnum/v1.rb +2 -2
  28. data/lib/misty/openstack/manila/v2.rb +2 -2
  29. data/lib/misty/openstack/microversion.rb +9 -9
  30. data/lib/misty/openstack/murano/v1.rb +1 -1
  31. data/lib/misty/openstack/neutron/v2_0.rb +1 -1
  32. data/lib/misty/openstack/nova/v2_1.rb +4 -4
  33. data/lib/misty/openstack/octavia/v2_0.rb +1 -1
  34. data/lib/misty/openstack/sahara/v1_1.rb +1 -1
  35. data/lib/misty/openstack/searchlight/v1.rb +1 -1
  36. data/lib/misty/openstack/senlin/v1.rb +1 -1
  37. data/lib/misty/openstack/swift/v1.rb +1 -1
  38. data/lib/misty/openstack/tacker/v1_0.rb +1 -1
  39. data/lib/misty/openstack/trove/v1_0.rb +1 -1
  40. data/lib/misty/openstack/zaqar/v2.rb +1 -1
  41. data/lib/misty/services.rb +1 -1
  42. data/lib/misty/version.rb +1 -1
  43. data/test/integration/compute_test.rb +17 -17
  44. data/test/integration/network_test.rb +16 -16
  45. data/test/integration/orchestration_test.rb +51 -51
  46. data/test/integration/test_helper.rb +7 -7
  47. data/test/unit/auth/name_test.rb +53 -53
  48. data/test/unit/auth_test.rb +151 -152
  49. data/test/unit/cloud/requests_test.rb +58 -58
  50. data/test/unit/cloud/services_test.rb +62 -62
  51. data/test/unit/cloud_test.rb +48 -48
  52. data/test/unit/http/client_test.rb +21 -28
  53. data/test/unit/http/direct_test.rb +31 -31
  54. data/test/unit/http/method_builder_test.rb +42 -42
  55. data/test/unit/http/request_test.rb +33 -33
  56. data/test/unit/misty_test.rb +28 -28
  57. data/test/unit/openstack/APIs_test.rb +3 -3
  58. data/test/unit/openstack/microversion_test.rb +14 -14
  59. data/test/unit/service_helper.rb +4 -4
  60. data/test/unit/services_test.rb +5 -5
  61. data/test/unit/test_helper.rb +1 -1
  62. metadata +4 -4
@@ -2,300 +2,299 @@ require 'test_helper'
2
2
  require 'auth_helper'
3
3
 
4
4
  describe Misty::Auth do
5
- let(:http) do
6
- endpoint = URI.parse("http://localhost:5000")
7
- Net::HTTP.new(endpoint.host, endpoint.port)
5
+ let(:config) do
6
+ Misty::Cloud::Config.new
8
7
  end
9
8
 
10
9
  describe Misty::AuthV3 do
11
- describe "#new" do
12
- it "fails when missing credentials" do
13
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
14
- to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {"x-subject-token"=>"token_data"})
10
+ describe '#new' do
11
+ it 'fails when missing credentials' do
12
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
13
+ to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {'x-subject-token'=>'token_data'})
15
14
 
16
15
  proc do
17
- Misty::AuthV3.new({}, http)
18
- end.must_raise Misty::Auth::CredentialsError
16
+ Misty::AuthV3.new({}, config)
17
+ end.must_raise Misty::Auth::URLError
19
18
  end
20
19
 
21
- describe "using the password method" do
22
- describe "with a project scope" do
23
- it "authenticates using a project id" do
20
+ describe 'using the password method' do
21
+ describe 'with a project scope' do
22
+ it 'authenticates using a project id' do
24
23
  auth = {
25
- :url => "http://localhost:5000",
26
- :user_id => "user_id",
27
- :password => "secret",
28
- :project_id => "project_id"
24
+ :url => 'http://localhost:5000',
25
+ :user_id => 'user_id',
26
+ :password => 'secret',
27
+ :project_id => 'project_id'
29
28
  }
30
29
 
31
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
30
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
32
31
  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"})
32
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
34
33
 
35
- Misty::AuthV3.new(auth, http)
34
+ Misty::AuthV3.new(auth, config)
36
35
  end
37
36
 
38
- it "authenticates using a project name and a project domain id" do
37
+ it 'authenticates using a project name and a project domain id' do
39
38
  auth = {
40
- :url => "http://localhost:5000",
41
- :user_id => "user_id",
42
- :password => "secret",
43
- :project => "project",
44
- :project_domain_id => "domain_id"
39
+ :url => 'http://localhost:5000',
40
+ :user_id => 'user_id',
41
+ :password => 'secret',
42
+ :project => 'project',
43
+ :project_domain_id => 'domain_id'
45
44
  }
46
45
 
47
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
46
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
48
47
  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"})
48
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
50
49
 
51
- Misty::AuthV3.new(auth, http)
50
+ Misty::AuthV3.new(auth, config)
52
51
  end
53
52
  end
54
53
 
55
- describe "with a domain scope" do
56
- it "authenticates using a domain id" do
54
+ describe 'with a domain scope' do
55
+ it 'authenticates using a domain id' do
57
56
  auth = {
58
- :url => "http://localhost:5000",
59
- :user_id => "user_id",
60
- :password => "secret",
61
- :domain_id => "domain_id"
57
+ :url => 'http://localhost:5000',
58
+ :user_id => 'user_id',
59
+ :password => 'secret',
60
+ :domain_id => 'domain_id'
62
61
  }
63
62
 
64
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
63
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
65
64
  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"})
65
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
67
66
 
68
- Misty::AuthV3.new(auth, http)
67
+ Misty::AuthV3.new(auth, config)
69
68
  end
70
69
 
71
- it "authenticates using a domain name" do
70
+ it 'authenticates using a domain name' do
72
71
  auth = {
73
- :url => "http://localhost:5000",
74
- :user_id => "user_id",
75
- :password => "secret",
76
- :domain => "domain"
72
+ :url => 'http://localhost:5000',
73
+ :user_id => 'user_id',
74
+ :password => 'secret',
75
+ :domain => 'domain'
77
76
  }
78
77
 
79
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
78
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
80
79
  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"})
80
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
82
81
 
83
- Misty::AuthV3.new(auth, http)
82
+ Misty::AuthV3.new(auth, config)
84
83
  end
85
84
  end
86
85
  end
87
86
 
88
- describe "using the token method" do
89
- describe "with a project scope" do
90
- it "authenticates using a project id" do
87
+ describe 'using the token method' do
88
+ describe 'with a project scope' do
89
+ it 'authenticates using a project id' do
91
90
  auth = {
92
- :url => "http://localhost:5000",
93
- :token => "token",
94
- :project_id => "project_id"
91
+ :url => 'http://localhost:5000',
92
+ :token => 'token',
93
+ :project_id => 'project_id'
95
94
  }
96
95
 
97
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
96
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
98
97
  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"})
98
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
100
99
 
101
- Misty::AuthV3.new(auth, http)
100
+ Misty::AuthV3.new(auth, config)
102
101
  end
103
102
 
104
- it "authenticates using a project name and a project domain id" do
103
+ it 'authenticates using a project name and a project domain id' do
105
104
  auth = {
106
- :url => "http://localhost:5000",
107
- :token => "token",
108
- :project => "project",
109
- :project_domain_id => "domain_id"
105
+ :url => 'http://localhost:5000',
106
+ :token => 'token',
107
+ :project => 'project',
108
+ :project_domain_id => 'domain_id'
110
109
  }
111
110
 
112
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
111
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
113
112
  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"})
113
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
115
114
 
116
- Misty::AuthV3.new(auth, http)
115
+ Misty::AuthV3.new(auth, config)
117
116
  end
118
117
  end
119
118
 
120
- describe "with a domain scope" do
121
- it "authenticates using a domain id" do
119
+ describe 'with a domain scope' do
120
+ it 'authenticates using a domain id' do
122
121
  auth = {
123
- :url => "http://localhost:5000",
124
- :token => "token",
125
- :domain_id => "domain_id"
122
+ :url => 'http://localhost:5000',
123
+ :token => 'token',
124
+ :domain_id => 'domain_id'
126
125
  }
127
126
 
128
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
127
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
129
128
  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"})
129
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
131
130
 
132
- Misty::AuthV3.new(auth, http)
131
+ Misty::AuthV3.new(auth, config)
133
132
  end
134
133
 
135
- it "authenticates using a domain name" do
134
+ it 'authenticates using a domain name' do
136
135
  auth = {
137
- :url => "http://localhost:5000",
138
- :token => "token",
139
- :domain => "domain"
136
+ :url => 'http://localhost:5000',
137
+ :token => 'token',
138
+ :domain => 'domain'
140
139
  }
141
140
 
142
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
141
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
143
142
  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"})
143
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
145
144
 
146
- Misty::AuthV3.new(auth, http)
145
+ Misty::AuthV3.new(auth, config)
147
146
  end
148
147
  end
149
148
  end
150
149
  end
151
150
 
152
- describe "when authenticated" do
151
+ describe 'when authenticated' do
153
152
  let(:authv3_creds) do
154
153
  {
155
- :url => "http://localhost:5000",
156
- :user => "admin",
157
- :password => "secret",
158
- :project => "admin",
154
+ :url => 'http://localhost:5000',
155
+ :user => 'admin',
156
+ :password => 'secret',
157
+ :project => 'admin',
159
158
  :project_domain_id=> 'default'
160
159
  }
161
160
  end
162
161
 
163
- it "#get_token" do
164
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
165
- to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
162
+ it '#get_token' do
163
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
164
+ to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
166
165
 
167
- auth = Misty::AuthV3.new(authv3_creds, http)
166
+ auth = Misty::AuthV3.new(authv3_creds, config)
168
167
  auth.stub :expired?, false do
169
- auth.get_token.must_equal "token_data"
168
+ auth.get_token.must_equal 'token_data'
170
169
  end
171
170
  end
172
171
 
173
- it "#catalog" do
174
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
175
- to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {"x-subject-token"=>"token_data"})
172
+ it '#catalog' do
173
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
174
+ to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
176
175
 
177
- auth = Misty::AuthV3.new(authv3_creds, http)
178
- auth.catalog.must_equal ["catalog_data"]
176
+ auth = Misty::AuthV3.new(authv3_creds, config)
177
+ auth.catalog.must_equal ['catalog_data']
179
178
  end
180
179
 
181
- it "#get_endpoint" do
182
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
183
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
180
+ it '#get_endpoint' do
181
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
182
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {'x-subject-token'=>'token_data'})
184
183
 
185
- auth = Misty::AuthV3.new(authv3_creds, http)
186
- auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
184
+ auth = Misty::AuthV3.new(authv3_creds, config)
185
+ auth.get_endpoint(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
187
186
  end
188
187
  end
189
188
  end
190
189
 
191
190
  describe Misty::AuthV2 do
192
- describe "#new" do
193
- it "fails when missing credentials" do
194
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
191
+ describe '#new' do
192
+ it 'fails when missing credentials' do
193
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
195
194
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
196
195
 
197
196
  proc do
198
- Misty::AuthV2.new({}, http)
199
- end.must_raise Misty::Auth::CredentialsError
197
+ Misty::AuthV2.new({}, config)
198
+ end.must_raise Misty::Auth::URLError
200
199
  end
201
200
 
202
- describe "using the password method" do
203
- it "authenticates using the tenant name" do
201
+ describe 'using the password method' do
202
+ it 'authenticates using the tenant name' do
204
203
  auth = {
205
- :url => "http://localhost:5000",
206
- :user => "user",
207
- :password => "secret",
208
- :tenant => "tenant",
204
+ :url => 'http://localhost:5000',
205
+ :user => 'user',
206
+ :password => 'secret',
207
+ :tenant => 'tenant',
209
208
  }
210
209
 
211
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
210
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
212
211
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantName\":\"tenant\"}}").
213
- to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
212
+ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
214
213
 
215
- Misty::AuthV2.new(auth, http)
214
+ Misty::AuthV2.new(auth, config)
216
215
  end
217
216
 
218
- it "authenticates using the tenant id" do
217
+ it 'authenticates using the tenant id' do
219
218
  auth = {
220
- :url => "http://localhost:5000",
221
- :user => "user",
222
- :password => "secret",
223
- :tenant_id => "tenant_id",
219
+ :url => 'http://localhost:5000',
220
+ :user => 'user',
221
+ :password => 'secret',
222
+ :tenant_id => 'tenant_id',
224
223
  }
225
224
 
226
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
225
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
227
226
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantId\":\"tenant_id\"}}").
228
- to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
227
+ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
229
228
 
230
- Misty::AuthV2.new(auth, http)
229
+ Misty::AuthV2.new(auth, config)
231
230
  end
232
231
  end
233
232
 
234
- describe "using the token method" do
235
- it "authenticates using the tenant name" do
233
+ describe 'using the token method' do
234
+ it 'authenticates using the tenant name' do
236
235
  auth = {
237
- :url => "http://localhost:5000",
238
- :token => "token_id",
239
- :tenant => "tenant",
236
+ :url => 'http://localhost:5000',
237
+ :token => 'token_id',
238
+ :tenant => 'tenant',
240
239
  }
241
240
 
242
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
241
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
243
242
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
244
- to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
243
+ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
245
244
 
246
- Misty::AuthV2.new(auth, http)
245
+ Misty::AuthV2.new(auth, config)
247
246
  end
248
247
 
249
- it "authenticates using the tenant id" do
248
+ it 'authenticates using the tenant id' do
250
249
  auth = {
251
- :url => "http://localhost:5000",
252
- :token => "token_id",
253
- :tenant_id => "tenant_id",
250
+ :url => 'http://localhost:5000',
251
+ :token => 'token_id',
252
+ :tenant_id => 'tenant_id',
254
253
  }
255
254
 
256
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
255
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
257
256
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
258
- to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {})
257
+ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
259
258
 
260
- Misty::AuthV2.new(auth, http)
259
+ Misty::AuthV2.new(auth, config)
261
260
  end
262
261
  end
263
262
  end
264
263
 
265
- describe "when authenticated" do
264
+ describe 'when authenticated' do
266
265
  let(:authv2_creds) do
267
266
  {
268
- :url => "http://localhost:5000",
269
- :user => "admin",
270
- :password => "secret",
271
- :tenant => "admin"
267
+ :url => 'http://localhost:5000',
268
+ :user => 'admin',
269
+ :password => 'secret',
270
+ :tenant => 'admin'
272
271
  }
273
272
  end
274
273
 
275
- it "#get_token" do
276
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
274
+ it '#get_token' do
275
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
277
276
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
278
277
 
279
- auth = Misty::AuthV2.new(authv2_creds, http)
278
+ auth = Misty::AuthV2.new(authv2_creds, config)
280
279
  auth.stub :expired?, false do
281
- auth.get_token.must_equal "token_data"
280
+ auth.get_token.must_equal 'token_data'
282
281
  end
283
282
  end
284
283
 
285
- it "#catalog" do
286
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
284
+ it '#catalog' do
285
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
287
286
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
288
287
 
289
- auth = Misty::AuthV2.new(authv2_creds, http)
290
- auth.catalog.must_equal ["catalog_data"]
288
+ auth = Misty::AuthV2.new(authv2_creds, config)
289
+ auth.catalog.must_equal ['catalog_data']
291
290
  end
292
291
 
293
- it "#get_endpoint" do
294
- stub_request(:post, "http://localhost:5000/v2.0/tokens").
295
- to_return(:status => 200, :body => JSON.dump(auth_response_v2("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
292
+ it '#get_endpoint' do
293
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
294
+ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
296
295
 
297
- auth = Misty::AuthV2.new(authv2_creds, http)
298
- auth.get_endpoint(%w{identity}, "regionOne", "public").must_equal "http://localhost"
296
+ auth = Misty::AuthV2.new(authv2_creds, config)
297
+ auth.get_endpoint(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
299
298
  end
300
299
  end
301
300
  end
@@ -4,111 +4,111 @@ 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",
7
+ :url => 'http://localhost:5000',
8
+ :user => 'admin',
9
+ :password => 'secret',
10
+ :project => 'admin',
11
11
  :project_domain_id => 'default',
12
- :domain => "default"
12
+ :domain => 'default'
13
13
  }
14
14
 
15
15
  Misty::Cloud.new(:auth => auth)
16
16
  end
17
17
 
18
- describe "GET request" do
19
- it "success without elements in path" do
20
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
21
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("network", "neutron")), :headers => {"x-subject-token"=>"token_data"})
18
+ describe 'GET request' do
19
+ it 'success without elements in path' do
20
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
21
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => {'x-subject-token'=>'token_data'})
22
22
 
23
- stub_request(:get, "http://localhost/v2.0/networks").
24
- to_return(:status => 200, :body => "list of networks", :headers => {})
23
+ stub_request(:get, 'http://localhost/v2.0/networks').
24
+ to_return(:status => 200, :body => 'list of networks', :headers => {})
25
25
 
26
26
  cloud.network.list_networks.response.must_be_kind_of Net::HTTPOK
27
27
  end
28
28
 
29
- it "success adds the query option in path" do
30
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
31
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("network", "neutron")), :headers => {"x-subject-token"=>"token_data"})
29
+ it 'success adds the query option in path' do
30
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
31
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => {'x-subject-token'=>'token_data'})
32
32
 
33
- stub_request(:get, "http://localhost/v2.0/networks?name=value").
34
- to_return(:status => 200, :body => "list of networks", :headers => {})
33
+ stub_request(:get, 'http://localhost/v2.0/networks?name=value').
34
+ to_return(:status => 200, :body => 'list of networks', :headers => {})
35
35
 
36
- cloud.network.list_networks("name=value").response.must_be_kind_of Net::HTTPOK
36
+ cloud.network.list_networks('name=value').response.must_be_kind_of Net::HTTPOK
37
37
  end
38
38
 
39
- it "successful whith elements in path" do
40
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
41
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("image", "glance")), :headers => {"x-subject-token"=>"token_data"})
39
+ it 'successful whith elements in path' do
40
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
41
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('image', 'glance')), :headers => {'x-subject-token'=>'token_data'})
42
42
 
43
- stub_request(:get, "http://localhost/v2/images/id1/members/id2").
44
- to_return(:status => 200, :body => "list of images", :headers => {})
43
+ stub_request(:get, 'http://localhost/v2/images/id1/members/id2').
44
+ to_return(:status => 200, :body => 'list of images', :headers => {})
45
45
 
46
- cloud.image.show_image_member_details("id1", "id2").response.must_be_kind_of Net::HTTPOK
46
+ cloud.image.show_image_member_details('id1', 'id2').response.must_be_kind_of Net::HTTPOK
47
47
  end
48
48
 
49
- it "fails when not enough arguments" do
49
+ it 'fails when not enough arguments' do
50
50
  proc do
51
- # "/v2/images/{image_id}/members/{member_id}"
52
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
53
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("image", "glance")), :headers => {"x-subject-token"=>"token_data"})
51
+ # '/v2/images/{image_id}/members/{member_id}'
52
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
53
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('image', 'glance')), :headers => {'x-subject-token'=>'token_data'})
54
54
 
55
- cloud.image.show_image_member_details("id1")
55
+ cloud.image.show_image_member_details('id1')
56
56
  end.must_raise ArgumentError
57
57
  end
58
58
  end
59
59
 
60
- describe "POST request" do
61
- it "successful without elements in path" do
62
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
63
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
60
+ describe 'POST request' do
61
+ it 'successful without elements in path' do
62
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
63
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
64
64
 
65
- stub_request(:post, "http://localhost/v3/projects").
66
- to_return(:status => 201, :body => "list of projects", :headers => {})
65
+ stub_request(:post, 'http://localhost/v3/projects').
66
+ to_return(:status => 201, :body => 'list of projects', :headers => {})
67
67
 
68
68
  cloud.identity.create_project("{\"project\":{\"name\":\"value\"}}").response.must_be_kind_of Net::HTTPCreated
69
69
  end
70
70
 
71
- it "sucessful whith elements in pathwhith elements in path" do
72
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
73
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("orchestration", "heat")), :headers => {"x-subject-token"=>"token_data"})
71
+ it 'sucessful whith elements in pathwhith elements in path' do
72
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
73
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('orchestration', 'heat')), :headers => {'x-subject-token'=>'token_data'})
74
74
 
75
- stub_request(:post, "http://localhost/stacks/id1/id2/snapshots").
76
- to_return(:status => 201, :body => "snapshots", :headers => {})
75
+ stub_request(:post, 'http://localhost/stacks/id1/id2/snapshots').
76
+ to_return(:status => 201, :body => 'snapshots', :headers => {})
77
77
 
78
- cloud.orchestration.snapshot_a_stack("id1", "id2", "{\"key\": \"value\"}").response.must_be_kind_of Net::HTTPCreated
78
+ cloud.orchestration.snapshot_a_stack('id1', 'id2', "{\"key\": \"value\"}").response.must_be_kind_of Net::HTTPCreated
79
79
  end
80
80
 
81
- it "fails when not enough arguments" do
81
+ it 'fails when not enough arguments' do
82
82
  proc do
83
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
84
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("orchestration", "heat")), :headers => {"x-subject-token"=>"token_data"})
83
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
84
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('orchestration', 'heat')), :headers => {'x-subject-token'=>'token_data'})
85
85
 
86
- cloud.orchestration.snapshot_a_stack("id1")
86
+ cloud.orchestration.snapshot_a_stack('id1')
87
87
  end.must_raise ArgumentError
88
88
  end
89
89
  end
90
90
 
91
- describe "DELETE request" do
92
- it "success" do
93
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
94
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
91
+ describe 'DELETE request' do
92
+ it 'success' do
93
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
94
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
95
95
 
96
- stub_request(:delete, "http://localhost/v3/projects/project_id").
97
- to_return(:status => 204, :body => "list of projects", :headers => {})
96
+ stub_request(:delete, 'http://localhost/v3/projects/project_id').
97
+ to_return(:status => 204, :body => 'list of projects', :headers => {})
98
98
 
99
- cloud.identity.delete_project("project_id").response.must_be_kind_of Net::HTTPNoContent
99
+ cloud.identity.delete_project('project_id').response.must_be_kind_of Net::HTTPNoContent
100
100
  end
101
101
  end
102
102
 
103
- describe "PUT request" do
104
- it "success" do
105
- stub_request(:post, "http://localhost:5000/v3/auth/tokens").
106
- to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {"x-subject-token"=>"token_data"})
103
+ describe 'PUT request' do
104
+ it 'success' do
105
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
106
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
107
107
 
108
- stub_request(:put, "http://localhost/v3/domains/domain_id/groups/group_id/roles/roles_id").
109
- to_return(:status => 200, :body => "list of group/role for a domain", :headers => {})
108
+ stub_request(:put, 'http://localhost/v3/domains/domain_id/groups/group_id/roles/roles_id').
109
+ to_return(:status => 200, :body => 'list of group/role for a domain', :headers => {})
110
110
 
111
- cloud.identity.assign_role_to_group_on_domain("domain_id", "group_id", "roles_id").response.must_be_kind_of Net::HTTPOK
111
+ cloud.identity.assign_role_to_group_on_domain('domain_id', 'group_id', 'roles_id').response.must_be_kind_of Net::HTTPOK
112
112
  end
113
113
  end
114
114
  end