misty 1.4.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +87 -88
  3. data/lib/misty.rb +115 -1
  4. data/lib/misty/auth/catalog.rb +38 -0
  5. data/lib/misty/auth/catalog/v2.rb +15 -0
  6. data/lib/misty/auth/catalog/v3.rb +15 -0
  7. data/lib/misty/auth/token.rb +70 -0
  8. data/lib/misty/auth/token/v2.rb +63 -0
  9. data/lib/misty/auth/token/v3.rb +90 -0
  10. data/lib/misty/cloud.rb +74 -15
  11. data/lib/misty/config.rb +37 -43
  12. data/lib/misty/errors.rb +25 -5
  13. data/lib/misty/helper.rb +26 -0
  14. data/lib/misty/http/header.rb +3 -6
  15. data/lib/misty/http/method_builder.rb +2 -2
  16. data/lib/misty/http/request.rb +3 -3
  17. data/lib/misty/microversion.rb +12 -1
  18. data/lib/misty/misty.rb +7 -62
  19. data/lib/misty/openstack.rb +39 -0
  20. data/lib/misty/openstack/{aodh → api/aodh}/aodh_v2.rb +1 -1
  21. data/lib/misty/openstack/api/aodh/v2.rb +19 -0
  22. data/lib/misty/openstack/api/barbican/barbican_v1.rb +42 -0
  23. data/lib/misty/openstack/api/barbican/v1.rb +19 -0
  24. data/lib/misty/openstack/api/blazar/blazar_v1.rb +16 -0
  25. data/lib/misty/openstack/api/blazar/v1.rb +19 -0
  26. data/lib/misty/openstack/{ceilometer → api/ceilometer}/ceilometer_v2.rb +1 -1
  27. data/lib/misty/openstack/api/ceilometer/v2.rb +19 -0
  28. data/lib/misty/openstack/{cinder → api/cinder}/cinder_v1.rb +1 -1
  29. data/lib/misty/openstack/{cinder → api/cinder}/cinder_v2.rb +3 -3
  30. data/lib/misty/openstack/{cinder → api/cinder}/cinder_v3.rb +7 -4
  31. data/lib/misty/openstack/api/cinder/v1.rb +23 -0
  32. data/lib/misty/openstack/api/cinder/v2.rb +24 -0
  33. data/lib/misty/openstack/api/cinder/v3.rb +29 -0
  34. data/lib/misty/openstack/{designate → api/designate}/designate_v2.rb +2 -2
  35. data/lib/misty/openstack/api/designate/v2.rb +19 -0
  36. data/lib/misty/openstack/{freezer → api/freezer}/freezer_v1.rb +2 -2
  37. data/lib/misty/openstack/api/freezer/v1.rb +19 -0
  38. data/lib/misty/openstack/{glance → api/glance}/glance_v1.rb +1 -1
  39. data/lib/misty/openstack/{glance → api/glance}/glance_v2.rb +1 -1
  40. data/lib/misty/openstack/api/glance/v1.rb +19 -0
  41. data/lib/misty/openstack/api/glance/v2.rb +24 -0
  42. data/lib/misty/openstack/api/gnocchi/gnocchi_v1.rb +39 -0
  43. data/lib/misty/openstack/api/gnocchi/v1.rb +19 -0
  44. data/lib/misty/openstack/{heat → api/heat}/heat_v1.rb +1 -1
  45. data/lib/misty/openstack/api/heat/v1.rb +23 -0
  46. data/lib/misty/openstack/{ironic → api/ironic}/ironic_v1.rb +8 -2
  47. data/lib/misty/openstack/api/ironic/v1.rb +25 -0
  48. data/lib/misty/openstack/{karbor → api/karbor}/karbor_v1.rb +2 -2
  49. data/lib/misty/openstack/api/karbor/v1.rb +19 -0
  50. data/lib/misty/openstack/{keystone → api/keystone}/keystone_v2_0.rb +1 -1
  51. data/lib/misty/openstack/api/keystone/keystone_v2_0_ext.rb +14 -0
  52. data/lib/misty/openstack/{keystone → api/keystone}/keystone_v3.rb +35 -3
  53. data/lib/misty/openstack/{keystone → api/keystone}/keystone_v3_ext.rb +7 -9
  54. data/lib/misty/openstack/api/keystone/v2_0.rb +23 -0
  55. data/lib/misty/openstack/api/keystone/v3.rb +23 -0
  56. data/lib/misty/openstack/{magnum → api/magnum}/magnum_v1.rb +2 -2
  57. data/lib/misty/openstack/api/magnum/v1.rb +21 -0
  58. data/lib/misty/openstack/{manila → api/manila}/manila_v2.rb +7 -3
  59. data/lib/misty/openstack/api/manila/v2.rb +25 -0
  60. data/lib/misty/openstack/api/masakari/masakari_v1_0.rb +22 -0
  61. data/lib/misty/openstack/api/masakari/v1_0.rb +19 -0
  62. data/lib/misty/openstack/api/mistral/mistral_v2.rb +44 -0
  63. data/lib/misty/openstack/api/mistral/v2.rb +19 -0
  64. data/lib/misty/openstack/api/monasca/monasca_v2_0.rb +28 -0
  65. data/lib/misty/openstack/api/monasca/v2_0.rb +19 -0
  66. data/lib/misty/openstack/{murano → api/murano}/murano_v1.rb +1 -1
  67. data/lib/misty/openstack/api/murano/v1.rb +19 -0
  68. data/lib/misty/openstack/{neutron → api/neutron}/neutron_v2_0.rb +11 -12
  69. data/lib/misty/openstack/api/neutron/v2_0.rb +19 -0
  70. data/lib/misty/openstack/{nova → api/nova}/nova_v2_1.rb +1 -2
  71. data/lib/misty/openstack/api/nova/v2_1.rb +33 -0
  72. data/lib/misty/openstack/{octavia → api/octavia}/octavia_v2_0.rb +4 -3
  73. data/lib/misty/openstack/api/octavia/v2_0.rb +19 -0
  74. data/lib/misty/openstack/api/panko/panko_v2.rb +14 -0
  75. data/lib/misty/openstack/api/panko/v2.rb +19 -0
  76. data/lib/misty/openstack/api/placement/placement_v2_1.rb +50 -0
  77. data/lib/misty/openstack/api/placement/v2_1.rb +21 -0
  78. data/lib/misty/openstack/{sahara → api/sahara}/sahara_v1_1.rb +2 -2
  79. data/lib/misty/openstack/api/sahara/v1_1.rb +19 -0
  80. data/lib/misty/openstack/{searchlight → api/searchlight}/searchlight_v1.rb +2 -2
  81. data/lib/misty/openstack/api/searchlight/v1.rb +19 -0
  82. data/lib/misty/openstack/{senlin → api/senlin}/senlin_v1.rb +2 -2
  83. data/lib/misty/openstack/api/senlin/v1.rb +19 -0
  84. data/lib/misty/openstack/{swift → api/swift}/swift_v1.rb +2 -2
  85. data/lib/misty/openstack/api/swift/v1.rb +34 -0
  86. data/lib/misty/openstack/{tacker → api/tacker}/tacker_v1_0.rb +2 -2
  87. data/lib/misty/openstack/api/tacker/v1_0.rb +19 -0
  88. data/lib/misty/openstack/{trove → api/trove}/trove_v1_0.rb +23 -8
  89. data/lib/misty/openstack/api/trove/v1_0.rb +19 -0
  90. data/lib/misty/openstack/api/watcher/v1.rb +19 -0
  91. data/lib/misty/openstack/api/watcher/watcher_v1.rb +38 -0
  92. data/lib/misty/openstack/api/zaqar/v2.rb +19 -0
  93. data/lib/misty/openstack/{zaqar → api/zaqar}/zaqar_v2.rb +2 -2
  94. data/lib/misty/openstack/api/zun/v1.rb +19 -0
  95. data/lib/misty/openstack/api/zun/zun_v1.rb +55 -0
  96. data/lib/misty/openstack/service.rb +18 -15
  97. data/lib/misty/openstack/service_pack.rb +18 -0
  98. data/lib/misty/service.rb +4 -6
  99. data/lib/misty/services.rb +11 -10
  100. data/lib/misty/version.rb +1 -1
  101. data/test/integration/compute_test.rb +2 -2
  102. data/test/integration/{networking_test.rb → network_test.rb} +10 -10
  103. data/test/integration/orchestration_test.rb +4 -4
  104. data/test/integration/vcr/{networking_using_neutron_v2_0.yml → network_using_neutron_v2_0.yml} +0 -0
  105. data/test/unit/auth/catalog_test.rb +99 -0
  106. data/test/unit/{auth_test.rb → auth/token_test.rb} +79 -45
  107. data/test/unit/cloud/config_test.rb +79 -41
  108. data/test/unit/cloud/requests_test.rb +6 -6
  109. data/test/unit/cloud/services_test.rb +23 -23
  110. data/test/unit/cloud_test.rb +10 -10
  111. data/test/unit/http/method_builder_test.rb +13 -23
  112. data/test/unit/http/request_test.rb +1 -1
  113. data/test/unit/microversion_test.rb +13 -16
  114. data/test/unit/misty_test.rb +51 -49
  115. data/test/unit/openstack/APIs_test.rb +5 -9
  116. data/test/unit/openstack/extension_test.rb +6 -6
  117. data/test/unit/openstack/service_test.rb +2 -10
  118. data/test/unit/service_helper.rb +3 -8
  119. data/test/unit/services_test.rb +5 -5
  120. metadata +91 -66
  121. data/lib/misty/auth.rb +0 -91
  122. data/lib/misty/auth/auth_v2.rb +0 -65
  123. data/lib/misty/auth/auth_v3.rb +0 -89
  124. data/lib/misty/autoload.rb +0 -99
  125. data/lib/misty/client_pack.rb +0 -16
  126. data/lib/misty/openstack/aodh/v2.rb +0 -17
  127. data/lib/misty/openstack/ceilometer/v2.rb +0 -17
  128. data/lib/misty/openstack/cinder/v1.rb +0 -21
  129. data/lib/misty/openstack/cinder/v2.rb +0 -22
  130. data/lib/misty/openstack/cinder/v3.rb +0 -31
  131. data/lib/misty/openstack/designate/v2.rb +0 -17
  132. data/lib/misty/openstack/freezer/v1.rb +0 -17
  133. data/lib/misty/openstack/glance/v1.rb +0 -17
  134. data/lib/misty/openstack/glance/v2.rb +0 -17
  135. data/lib/misty/openstack/heat/v1.rb +0 -21
  136. data/lib/misty/openstack/ironic/v1.rb +0 -27
  137. data/lib/misty/openstack/karbor/v1.rb +0 -17
  138. data/lib/misty/openstack/keystone/keystone_v2_0_ext.rb +0 -18
  139. data/lib/misty/openstack/keystone/v2_0.rb +0 -21
  140. data/lib/misty/openstack/keystone/v3.rb +0 -21
  141. data/lib/misty/openstack/magnum/v1.rb +0 -23
  142. data/lib/misty/openstack/manila/v2.rb +0 -27
  143. data/lib/misty/openstack/murano/v1.rb +0 -17
  144. data/lib/misty/openstack/neutron/v2_0.rb +0 -17
  145. data/lib/misty/openstack/nova/v2_1.rb +0 -42
  146. data/lib/misty/openstack/octavia/v2_0.rb +0 -17
  147. data/lib/misty/openstack/sahara/v1_1.rb +0 -17
  148. data/lib/misty/openstack/searchlight/v1.rb +0 -17
  149. data/lib/misty/openstack/senlin/v1.rb +0 -17
  150. data/lib/misty/openstack/swift/v1.rb +0 -32
  151. data/lib/misty/openstack/tacker/v1_0.rb +0 -17
  152. data/lib/misty/openstack/trove/v1_0.rb +0 -17
  153. data/lib/misty/openstack/zaqar/v2.rb +0 -17
@@ -1,16 +1,15 @@
1
1
  require 'test_helper'
2
2
  require 'auth_helper'
3
3
 
4
- describe Misty::Auth do
5
- describe Misty::AuthV3 do
4
+ describe Misty::Auth::Token do
5
+ describe 'V3' do
6
6
  describe '#new' do
7
7
  it 'fails when missing credentials' do
8
8
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
9
9
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[]}}", :headers => {'x-subject-token'=>'token_data'})
10
-
11
10
  proc do
12
- Misty::AuthV3.new({})
13
- end.must_raise Misty::Auth::URLError
11
+ token = Misty::Auth::Token.build({})
12
+ end.must_raise Misty::Auth::Token::URLError
14
13
  end
15
14
 
16
15
  describe 'using the password method' do
@@ -26,9 +25,10 @@ describe Misty::Auth do
26
25
 
27
26
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
28
27
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
29
- to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
28
+ to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data_v3'})
30
29
 
31
- Misty::AuthV3.new(auth)
30
+ token = Misty::Auth::Token.build(auth)
31
+ token.get.must_equal 'token_data_v3'
32
32
  end
33
33
 
34
34
  it 'authenticates using a project name and a project domain id' do
@@ -43,8 +43,8 @@ describe Misty::Auth do
43
43
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
44
44
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"project_domain_id\"}}}}}").
45
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)
46
+ token = Misty::Auth::Token.build(auth)
47
+ token.get.must_equal 'token_data'
48
48
  end
49
49
 
50
50
  it 'authenticates using a project name and a project domain name' do
@@ -61,7 +61,8 @@ describe Misty::Auth do
61
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\"}}}}}").
62
62
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
63
63
 
64
- Misty::AuthV3.new(auth)
64
+ token = Misty::Auth::Token.build(auth)
65
+ token.get.must_equal 'token_data'
65
66
  end
66
67
  end
67
68
 
@@ -78,7 +79,8 @@ describe Misty::Auth do
78
79
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
79
80
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
80
81
 
81
- Misty::AuthV3.new(auth)
82
+ token = Misty::Auth::Token.build(auth)
83
+ token.get.must_equal 'token_data'
82
84
  end
83
85
 
84
86
  it 'authenticates using a domain name' do
@@ -93,7 +95,8 @@ describe Misty::Auth do
93
95
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\":{\"id\":\"user_id\",\"password\":\"secret\"}}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
94
96
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
95
97
 
96
- Misty::AuthV3.new(auth)
98
+ token = Misty::Auth::Token.build(auth)
99
+ token.get.must_equal 'token_data'
97
100
  end
98
101
  end
99
102
  end
@@ -111,7 +114,8 @@ describe Misty::Auth do
111
114
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"id\":\"project_id\"}}}}").
112
115
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
113
116
 
114
- Misty::AuthV3.new(auth)
117
+ token = Misty::Auth::Token.build(auth)
118
+ token.get.must_equal 'token_data'
115
119
  end
116
120
 
117
121
  it 'authenticates using a project name and a project domain id' do
@@ -126,7 +130,8 @@ describe Misty::Auth do
126
130
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"project\":{\"name\":\"project\",\"domain\":{\"id\":\"domain_id\"}}}}}").
127
131
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
128
132
 
129
- Misty::AuthV3.new(auth)
133
+ token = Misty::Auth::Token.build(auth)
134
+ token.get.must_equal 'token_data'
130
135
  end
131
136
  end
132
137
 
@@ -142,7 +147,8 @@ describe Misty::Auth do
142
147
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"id\":\"domain_id\"}}}}").
143
148
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
144
149
 
145
- Misty::AuthV3.new(auth)
150
+ token = Misty::Auth::Token.build(auth)
151
+ token.get.must_equal 'token_data'
146
152
  end
147
153
 
148
154
  it 'authenticates using a domain name' do
@@ -156,7 +162,8 @@ describe Misty::Auth do
156
162
  with(:body => "{\"auth\":{\"identity\":{\"methods\":[\"token\"],\"token\":{\"id\":\"token\"}},\"scope\":{\"domain\":{\"name\":\"domain\"}}}}").
157
163
  to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
158
164
 
159
- Misty::AuthV3.new(auth)
165
+ token = Misty::Auth::Token.build(auth)
166
+ token.get.must_equal 'token_data'
160
167
  end
161
168
  end
162
169
  end
@@ -173,13 +180,25 @@ describe Misty::Auth do
173
180
  }
174
181
  end
175
182
 
176
- it '#get_token' do
177
- stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
178
- to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
183
+ describe '#get' do
184
+ it 'when token has not expired' do
185
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
186
+ to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
179
187
 
180
- auth = Misty::AuthV3.new(authv3_creds)
181
- auth.stub :expired?, false do
182
- auth.get_token.must_equal 'token_data'
188
+ token = Misty::Auth::Token.build(authv3_creds)
189
+ token.stub :expired?, false do
190
+ token.get.must_equal 'token_data'
191
+ end
192
+ end
193
+
194
+ it 'when token has expired' do
195
+ stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
196
+ to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
197
+
198
+ token = Misty::Auth::Token.build(authv3_creds)
199
+ token.stub :expired?, true do
200
+ token.get.must_equal 'token_data'
201
+ end
183
202
  end
184
203
  end
185
204
 
@@ -187,29 +206,29 @@ describe Misty::Auth do
187
206
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
188
207
  to_return(:status => 200, :body => "{\"token\":{\"catalog\":[\"catalog_data\"]}}", :headers => {'x-subject-token'=>'token_data'})
189
208
 
190
- auth = Misty::AuthV3.new(authv3_creds)
191
- auth.catalog.must_equal ['catalog_data']
209
+ token = Misty::Auth::Token.build(authv3_creds)
210
+ token.catalog.payload.must_equal ['catalog_data']
192
211
  end
193
212
 
194
- it '#get_url' do
213
+ it '#get_endpoint_url' do
195
214
  stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
196
215
  to_return(:status => 200, :body => JSON.dump(auth_response_v3("identity", "keystone")), :headers => {'x-subject-token'=>'token_data'})
197
216
 
198
- auth = Misty::AuthV3.new(authv3_creds)
199
- auth.get_url(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
217
+ token = Misty::Auth::Token.build(authv3_creds)
218
+ token.catalog.get_endpoint_url(%w(identity), 'regionOne', 'public').must_equal 'http://localhost'
200
219
  end
201
220
  end
202
221
  end
203
222
 
204
- describe Misty::AuthV2 do
223
+ describe 'V2' do
205
224
  describe '#new' do
206
225
  it 'fails when missing credentials' do
207
226
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
208
227
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {})
209
228
 
210
229
  proc do
211
- Misty::AuthV2.new({})
212
- end.must_raise Misty::Auth::URLError
230
+ Misty::Auth::Token.build({})
231
+ end.must_raise Misty::Auth::Token::URLError
213
232
  end
214
233
 
215
234
  describe 'using the password method' do
@@ -225,7 +244,8 @@ describe Misty::Auth do
225
244
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantName\":\"tenant\"}}").
226
245
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
227
246
 
228
- Misty::AuthV2.new(auth)
247
+ token = Misty::Auth::Token.build(auth)
248
+ token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
229
249
  end
230
250
 
231
251
  it 'authenticates using the tenant id' do
@@ -240,7 +260,8 @@ describe Misty::Auth do
240
260
  with(:body => "{\"auth\":{\"passwordCredentials\":{\"username\":\"user\",\"password\":\"secret\"},\"tenantId\":\"tenant_id\"}}").
241
261
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
242
262
 
243
- Misty::AuthV2.new(auth)
263
+ token = Misty::Auth::Token.build(auth)
264
+ token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
244
265
  end
245
266
  end
246
267
 
@@ -256,7 +277,8 @@ describe Misty::Auth do
256
277
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantName\":\"tenant\"}}").
257
278
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
258
279
 
259
- Misty::AuthV2.new(auth)
280
+ token = Misty::Auth::Token.build(auth)
281
+ token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26'
260
282
  end
261
283
 
262
284
  it 'authenticates using the tenant id' do
@@ -270,7 +292,7 @@ describe Misty::Auth do
270
292
  with(:body => "{\"auth\":{\"token\":{\"id\":\"token_id\"},\"tenantId\":\"tenant_id\"}}").
271
293
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {})
272
294
 
273
- Misty::AuthV2.new(auth)
295
+ token = Misty::Auth::Token.build(auth)
274
296
  end
275
297
  end
276
298
  end
@@ -285,13 +307,25 @@ describe Misty::Auth do
285
307
  }
286
308
  end
287
309
 
288
- it '#get_token' do
289
- stub_request(:post, 'http://localhost:5000/v2.0/tokens').
290
- to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
310
+ describe '#get' do
311
+ it 'when token has not expired' do
312
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
313
+ to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_not_expired\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
291
314
 
292
- auth = Misty::AuthV2.new(authv2_creds)
293
- auth.stub :expired?, false do
294
- auth.get_token.must_equal 'token_data'
315
+ token = Misty::Auth::Token.build(authv2_creds)
316
+ token.stub :expired?, false do
317
+ token.get.must_equal 'token_not_expired'
318
+ end
319
+ end
320
+
321
+ it 'when token has expired' do
322
+ stub_request(:post, 'http://localhost:5000/v2.0/tokens').
323
+ to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_expired\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
324
+
325
+ token = Misty::Auth::Token.build(authv2_creds)
326
+ token.stub :expired?, true do
327
+ token.get.must_equal 'token_expired'
328
+ end
295
329
  end
296
330
  end
297
331
 
@@ -299,16 +333,16 @@ describe Misty::Auth do
299
333
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
300
334
  to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"},\"serviceCatalog\":[\"catalog_data\"]}}", :headers => {})
301
335
 
302
- auth = Misty::AuthV2.new(authv2_creds)
303
- auth.catalog.must_equal ['catalog_data']
336
+ token = Misty::Auth::Token.build(authv2_creds)
337
+ token.catalog.payload.must_equal ['catalog_data']
304
338
  end
305
339
 
306
- it '#get_url' do
340
+ it '#get_endpoint_url' do
307
341
  stub_request(:post, 'http://localhost:5000/v2.0/tokens').
308
342
  to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
309
343
 
310
- auth = Misty::AuthV2.new(authv2_creds)
311
- auth.get_url(%w{identity}, 'regionOne', 'public').must_equal 'http://localhost'
344
+ token = Misty::Auth::Token.build(authv2_creds)
345
+ token.catalog.get_endpoint_url(%w(identity), 'regionOne', 'public').must_equal 'http://localhost'
312
346
  end
313
347
  end
314
348
  end
@@ -43,10 +43,10 @@ describe Misty::Config do
43
43
  end.must_raise Misty::Config::InvalidDataError
44
44
  end
45
45
 
46
- it 'with region_id wrong type' do
46
+ it 'with region wrong type' do
47
47
  auth_request
48
48
  proc do
49
- Misty::Config.new(:auth => auth, :region_id => true)
49
+ Misty::Config.new(:auth => auth, :region => true)
50
50
  end.must_raise Misty::Config::InvalidDataError
51
51
  end
52
52
 
@@ -67,12 +67,12 @@ describe Misty::Config do
67
67
  end
68
68
 
69
69
  config.log.must_be_kind_of Logger
70
- config.auth.must_be_kind_of Misty::AuthV3
70
+ config.token.must_be_kind_of Misty::Auth::Token::V3
71
71
  config.globals[:content_type].must_equal Misty::Config::CONTENT_TYPE
72
72
  config.globals[:headers].must_be_kind_of Misty::HTTP::Header
73
73
  config.globals[:headers].get.must_equal("Accept"=>"application/json; q=1.0")
74
74
  config.globals[:interface].must_equal Misty::Config::INTERFACE
75
- config.globals[:region_id].must_equal Misty::Config::REGION_ID
75
+ config.globals[:region].must_equal Misty::Config::REGION
76
76
  config.globals[:ssl_verify_mode].must_equal Misty::Config::SSL_VERIFY_MODE
77
77
  end
78
78
 
@@ -85,10 +85,11 @@ describe Misty::Config do
85
85
  :content_type => :json,
86
86
  :headers => {'var' => 'value'},
87
87
  :interface => 'admin',
88
- :region_id => 'regionTest',
88
+ :region => 'regionTest',
89
89
  :ssl_verify_mode => false,
90
90
  :log_file => LOG_FILE_NAME
91
91
  )
92
+
92
93
  def config.globals
93
94
  @globals
94
95
  end
@@ -96,14 +97,14 @@ describe Misty::Config do
96
97
  config.globals[:content_type].must_equal :json
97
98
  config.globals[:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'var' => 'value')
98
99
  config.globals[:interface].must_equal 'admin'
99
- config.globals[:region_id].must_equal 'regionTest'
100
+ config.globals[:region].must_equal 'regionTest'
100
101
  config.globals[:ssl_verify_mode].must_equal false
101
102
  File.exist?(LOG_FILE_NAME).must_equal true
102
103
  File.delete(LOG_FILE_NAME) if File.exist?(LOG_FILE_NAME)
103
104
  end
104
105
 
105
- describe 'service level configurations' do
106
- it 'with globals defaults' do
106
+ describe 'with no global Cloud defined parameters' do
107
+ it 'set Service defined parameters' do
107
108
  auth_request
108
109
  config = Misty::Config.new(
109
110
  :auth => auth,
@@ -111,53 +112,90 @@ describe Misty::Config do
111
112
  :content_type => :json,
112
113
  :headers => {'Service Key' => 'Service Value'},
113
114
  :interface => 'internal',
114
- :region_id => 'region local',
115
+ :region => 'region local',
115
116
  :ssl_verify_mode => false,
116
117
 
117
118
  :base_path => 'base_path_test',
118
- :base_url => '/base.url.com',
119
+ :endpoint => 'https://service.example.com:8080',
120
+ :service_name => 'service1',
119
121
  :version => 'vtest'
120
122
  }
121
123
  )
122
124
 
123
- service_config = config.get_service(:compute)
124
- service_config[:config][:content_type].must_equal :json
125
- service_config[:config][:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Service Key' => 'Service Value')
126
- service_config[:config][:interface].must_equal 'internal'
127
- service_config[:config][:region_id].must_equal 'region local'
128
- service_config[:config][:ssl_verify_mode].must_equal false
129
- service_config[:config][:base_path].must_equal 'base_path_test'
130
- service_config[:config][:base_url].must_equal '/base.url.com'
131
- service_config[:config][:version].must_equal 'vtest'
125
+ service = config.get_service(:compute)
126
+ service[:config][:content_type].must_equal :json
127
+ service[:config][:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Service Key' => 'Service Value')
128
+ service[:config][:interface].must_equal 'internal'
129
+ service[:config][:region].must_equal 'region local'
130
+ service[:config][:ssl_verify_mode].must_equal false
131
+
132
+ service[:config][:base_path].must_equal 'base_path_test'
133
+ service[:config][:endpoint].must_equal 'https://service.example.com:8080'
134
+ service[:config][:service_name].must_equal 'service1'
135
+ service[:config][:version].must_equal 'vtest'
132
136
  end
137
+ end
133
138
 
134
- it 'with Cloud level parameters' do
139
+ describe 'with global Cloud defined parameters' do
140
+ let(:config) do
135
141
  auth_request
136
- config = Misty::Config.new(
137
- :auth => auth,
138
- :content_type => :json,
139
- :headers => {'Global Key' => 'Global Value'},
140
- :interface => 'internal',
141
- :region_id => 'region_global',
142
- :ssl_verify_mode => false,
143
- :networking => {
144
- :content_type => :hash,
145
- :headers => {'Local Key' => 'Local Value'},
146
- :interface => 'admin',
147
- :region_id => 'region_local',
148
- :ssl_verify_mode => true
149
- }
150
- )
142
+ Misty::Config.new(
143
+ :auth => auth,
144
+ :content_type => :json,
145
+ :headers => {'Global Key' => 'Global Value'},
146
+ :interface => 'internal',
147
+ :region => 'region_global',
148
+ :ssl_verify_mode => false,
149
+ :network => {
150
+ :content_type => :hash,
151
+ :headers => {'Local Key' => 'Local Value'},
152
+ :interface => 'admin',
153
+ :region => 'region_local',
154
+ :ssl_verify_mode => true,
155
+
156
+ :base_path => 'base_path_test',
157
+ :endpoint => 'https://service1.example.com:8888',
158
+ :service_name => 'service1',
159
+ :version => '2.10'
160
+ })
161
+ end
162
+
163
+ it 'set globals' do
151
164
  def config.globals
152
165
  @globals
153
166
  end
154
167
 
155
- service_config = config.get_service(:networking)
156
- service_config[:config][:content_type].must_equal :hash
157
- service_config[:config][:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Global Key' => 'Global Value', 'Local Key' => 'Local Value')
158
- service_config[:config][:interface].must_equal 'admin'
159
- service_config[:config][:region_id].must_equal 'region_local'
160
- service_config[:config][:ssl_verify_mode].must_equal true
168
+ config.globals[:content_type].must_equal :json
169
+ config.globals[:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Global Key' => 'Global Value')
170
+ config.globals[:interface].must_equal "internal"
171
+ config.globals[:region].must_equal "region_global"
172
+ config.globals[:ssl_verify_mode].must_equal false
173
+ end
174
+
175
+ it 'set Service defined parameters' do
176
+ network = config.get_service(:network)
177
+ network[:config][:content_type].must_equal :hash
178
+ network[:config][:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Global Key' => 'Global Value', 'Local Key' => 'Local Value')
179
+ network[:config][:interface].must_equal 'admin'
180
+ network[:config][:region].must_equal 'region_local'
181
+ network[:config][:ssl_verify_mode].must_equal true
182
+
183
+ network[:config][:endpoint].must_equal 'https://service1.example.com:8888'
184
+ network[:config][:service_name].must_equal 'service1'
185
+ network[:config][:version].must_equal '2.10'
186
+ end
187
+
188
+ it 'set no Service defined parameters' do
189
+ compute = config.get_service(:compute)
190
+ compute[:config][:content_type].must_equal :json
191
+ compute[:config][:headers].get.must_equal('Accept' => 'application/json; q=1.0', 'Global Key' => 'Global Value')
192
+ compute[:config][:interface].must_equal 'internal'
193
+ compute[:config][:region].must_equal 'region_global'
194
+ compute[:config][:ssl_verify_mode].must_equal false
195
+
196
+ compute[:config][:endpoint].must_equal nil
197
+ compute[:config][:service_name].must_equal nil
198
+ compute[:config][:version].must_equal nil
161
199
  end
162
200
  end
163
201
  end
@@ -87,7 +87,7 @@ describe Misty::Cloud do
87
87
  with(:headers => {'Content-Type'=>'application/json'}).
88
88
  to_return(:status => 201, :body => "", :headers => {})
89
89
 
90
- cloud.networking.create_network(['network', {'name' => 'network1'}]).response.must_be_kind_of Net::HTTPCreated
90
+ cloud.network.create_network(['network', {'name' => 'network1'}]).response.must_be_kind_of Net::HTTPCreated
91
91
  end
92
92
 
93
93
  it 'sucessful with Hash type data' do
@@ -99,7 +99,7 @@ describe Misty::Cloud do
99
99
  with(:headers => {'Content-Type'=>'application/json'}).
100
100
  to_return(:status => 201, :body => "", :headers => {})
101
101
 
102
- cloud.networking.create_network({'network' => {'name' => 'network1'}}).response.must_be_kind_of Net::HTTPCreated
102
+ cloud.network.create_network({'network' => {'name' => 'network1'}}).response.must_be_kind_of Net::HTTPCreated
103
103
  end
104
104
 
105
105
  it 'sucessful with JSON String data' do
@@ -111,7 +111,7 @@ describe Misty::Cloud do
111
111
  with(:headers => {'Content-Type'=>'application/json'}).
112
112
  to_return(:status => 201, :body => "", :headers => {})
113
113
 
114
- cloud.networking.create_network("{\"network\":{\"name\":\"network1\"}}").response.must_be_kind_of Net::HTTPCreated
114
+ cloud.network.create_network("{\"network\":{\"name\":\"network1\"}}").response.must_be_kind_of Net::HTTPCreated
115
115
  end
116
116
 
117
117
  it 'fails when not enough arguments' do
@@ -156,7 +156,7 @@ describe Misty::Cloud do
156
156
  with(:headers => {'Content-Type'=>'application/json'}).
157
157
  to_return(:status => 200, :body => "", :headers => {})
158
158
 
159
- cloud.networking.update_network('network_id', ['network', {'name' => 'network2'}]).response.must_be_kind_of Net::HTTPOK
159
+ cloud.network.update_network('network_id', ['network', {'name' => 'network2'}]).response.must_be_kind_of Net::HTTPOK
160
160
  end
161
161
 
162
162
  it 'sucessful with Hash type data' do
@@ -168,7 +168,7 @@ describe Misty::Cloud do
168
168
  with(:headers => {'Content-Type'=>'application/json'}).
169
169
  to_return(:status => 200, :body => "", :headers => {})
170
170
 
171
- cloud.networking.update_network('network_id', {'network' => {'name' => 'network2'}}).response.must_be_kind_of Net::HTTPOK
171
+ cloud.network.update_network('network_id', {'network' => {'name' => 'network2'}}).response.must_be_kind_of Net::HTTPOK
172
172
  end
173
173
 
174
174
  it 'sucessful with JSON String data' do
@@ -180,7 +180,7 @@ describe Misty::Cloud do
180
180
  with(:headers => {'Content-Type'=>'application/json'}).
181
181
  to_return(:status => 200, :body => "", :headers => {})
182
182
 
183
- cloud.networking.update_network('network_id', "{\"network\":{\"name\":\"network2\"}}").response.must_be_kind_of Net::HTTPOK
183
+ cloud.network.update_network('network_id', "{\"network\":{\"name\":\"network2\"}}").response.must_be_kind_of Net::HTTPOK
184
184
  end
185
185
  end
186
186
  end