misty 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +87 -88
- data/lib/misty.rb +115 -1
- data/lib/misty/auth/catalog.rb +38 -0
- data/lib/misty/auth/catalog/v2.rb +15 -0
- data/lib/misty/auth/catalog/v3.rb +15 -0
- data/lib/misty/auth/token.rb +70 -0
- data/lib/misty/auth/token/v2.rb +63 -0
- data/lib/misty/auth/token/v3.rb +90 -0
- data/lib/misty/cloud.rb +74 -15
- data/lib/misty/config.rb +37 -43
- data/lib/misty/errors.rb +25 -5
- data/lib/misty/helper.rb +26 -0
- data/lib/misty/http/header.rb +3 -6
- data/lib/misty/http/method_builder.rb +2 -2
- data/lib/misty/http/request.rb +3 -3
- data/lib/misty/microversion.rb +12 -1
- data/lib/misty/misty.rb +7 -62
- data/lib/misty/openstack.rb +39 -0
- data/lib/misty/openstack/{aodh → api/aodh}/aodh_v2.rb +1 -1
- data/lib/misty/openstack/api/aodh/v2.rb +19 -0
- data/lib/misty/openstack/api/barbican/barbican_v1.rb +42 -0
- data/lib/misty/openstack/api/barbican/v1.rb +19 -0
- data/lib/misty/openstack/api/blazar/blazar_v1.rb +16 -0
- data/lib/misty/openstack/api/blazar/v1.rb +19 -0
- data/lib/misty/openstack/{ceilometer → api/ceilometer}/ceilometer_v2.rb +1 -1
- data/lib/misty/openstack/api/ceilometer/v2.rb +19 -0
- data/lib/misty/openstack/{cinder → api/cinder}/cinder_v1.rb +1 -1
- data/lib/misty/openstack/{cinder → api/cinder}/cinder_v2.rb +3 -3
- data/lib/misty/openstack/{cinder → api/cinder}/cinder_v3.rb +7 -4
- data/lib/misty/openstack/api/cinder/v1.rb +23 -0
- data/lib/misty/openstack/api/cinder/v2.rb +24 -0
- data/lib/misty/openstack/api/cinder/v3.rb +29 -0
- data/lib/misty/openstack/{designate → api/designate}/designate_v2.rb +2 -2
- data/lib/misty/openstack/api/designate/v2.rb +19 -0
- data/lib/misty/openstack/{freezer → api/freezer}/freezer_v1.rb +2 -2
- data/lib/misty/openstack/api/freezer/v1.rb +19 -0
- data/lib/misty/openstack/{glance → api/glance}/glance_v1.rb +1 -1
- data/lib/misty/openstack/{glance → api/glance}/glance_v2.rb +1 -1
- data/lib/misty/openstack/api/glance/v1.rb +19 -0
- data/lib/misty/openstack/api/glance/v2.rb +24 -0
- data/lib/misty/openstack/api/gnocchi/gnocchi_v1.rb +39 -0
- data/lib/misty/openstack/api/gnocchi/v1.rb +19 -0
- data/lib/misty/openstack/{heat → api/heat}/heat_v1.rb +1 -1
- data/lib/misty/openstack/api/heat/v1.rb +23 -0
- data/lib/misty/openstack/{ironic → api/ironic}/ironic_v1.rb +8 -2
- data/lib/misty/openstack/api/ironic/v1.rb +25 -0
- data/lib/misty/openstack/{karbor → api/karbor}/karbor_v1.rb +2 -2
- data/lib/misty/openstack/api/karbor/v1.rb +19 -0
- data/lib/misty/openstack/{keystone → api/keystone}/keystone_v2_0.rb +1 -1
- data/lib/misty/openstack/api/keystone/keystone_v2_0_ext.rb +14 -0
- data/lib/misty/openstack/{keystone → api/keystone}/keystone_v3.rb +35 -3
- data/lib/misty/openstack/{keystone → api/keystone}/keystone_v3_ext.rb +7 -9
- data/lib/misty/openstack/api/keystone/v2_0.rb +23 -0
- data/lib/misty/openstack/api/keystone/v3.rb +23 -0
- data/lib/misty/openstack/{magnum → api/magnum}/magnum_v1.rb +2 -2
- data/lib/misty/openstack/api/magnum/v1.rb +21 -0
- data/lib/misty/openstack/{manila → api/manila}/manila_v2.rb +7 -3
- data/lib/misty/openstack/api/manila/v2.rb +25 -0
- data/lib/misty/openstack/api/masakari/masakari_v1_0.rb +22 -0
- data/lib/misty/openstack/api/masakari/v1_0.rb +19 -0
- data/lib/misty/openstack/api/mistral/mistral_v2.rb +44 -0
- data/lib/misty/openstack/api/mistral/v2.rb +19 -0
- data/lib/misty/openstack/api/monasca/monasca_v2_0.rb +28 -0
- data/lib/misty/openstack/api/monasca/v2_0.rb +19 -0
- data/lib/misty/openstack/{murano → api/murano}/murano_v1.rb +1 -1
- data/lib/misty/openstack/api/murano/v1.rb +19 -0
- data/lib/misty/openstack/{neutron → api/neutron}/neutron_v2_0.rb +11 -12
- data/lib/misty/openstack/api/neutron/v2_0.rb +19 -0
- data/lib/misty/openstack/{nova → api/nova}/nova_v2_1.rb +1 -2
- data/lib/misty/openstack/api/nova/v2_1.rb +33 -0
- data/lib/misty/openstack/{octavia → api/octavia}/octavia_v2_0.rb +4 -3
- data/lib/misty/openstack/api/octavia/v2_0.rb +19 -0
- data/lib/misty/openstack/api/panko/panko_v2.rb +14 -0
- data/lib/misty/openstack/api/panko/v2.rb +19 -0
- data/lib/misty/openstack/api/placement/placement_v2_1.rb +50 -0
- data/lib/misty/openstack/api/placement/v2_1.rb +21 -0
- data/lib/misty/openstack/{sahara → api/sahara}/sahara_v1_1.rb +2 -2
- data/lib/misty/openstack/api/sahara/v1_1.rb +19 -0
- data/lib/misty/openstack/{searchlight → api/searchlight}/searchlight_v1.rb +2 -2
- data/lib/misty/openstack/api/searchlight/v1.rb +19 -0
- data/lib/misty/openstack/{senlin → api/senlin}/senlin_v1.rb +2 -2
- data/lib/misty/openstack/api/senlin/v1.rb +19 -0
- data/lib/misty/openstack/{swift → api/swift}/swift_v1.rb +2 -2
- data/lib/misty/openstack/api/swift/v1.rb +34 -0
- data/lib/misty/openstack/{tacker → api/tacker}/tacker_v1_0.rb +2 -2
- data/lib/misty/openstack/api/tacker/v1_0.rb +19 -0
- data/lib/misty/openstack/{trove → api/trove}/trove_v1_0.rb +23 -8
- data/lib/misty/openstack/api/trove/v1_0.rb +19 -0
- data/lib/misty/openstack/api/watcher/v1.rb +19 -0
- data/lib/misty/openstack/api/watcher/watcher_v1.rb +38 -0
- data/lib/misty/openstack/api/zaqar/v2.rb +19 -0
- data/lib/misty/openstack/{zaqar → api/zaqar}/zaqar_v2.rb +2 -2
- data/lib/misty/openstack/api/zun/v1.rb +19 -0
- data/lib/misty/openstack/api/zun/zun_v1.rb +55 -0
- data/lib/misty/openstack/service.rb +18 -15
- data/lib/misty/openstack/service_pack.rb +18 -0
- data/lib/misty/service.rb +4 -6
- data/lib/misty/services.rb +11 -10
- data/lib/misty/version.rb +1 -1
- data/test/integration/compute_test.rb +2 -2
- data/test/integration/{networking_test.rb → network_test.rb} +10 -10
- data/test/integration/orchestration_test.rb +4 -4
- data/test/integration/vcr/{networking_using_neutron_v2_0.yml → network_using_neutron_v2_0.yml} +0 -0
- data/test/unit/auth/catalog_test.rb +99 -0
- data/test/unit/{auth_test.rb → auth/token_test.rb} +79 -45
- data/test/unit/cloud/config_test.rb +79 -41
- data/test/unit/cloud/requests_test.rb +6 -6
- data/test/unit/cloud/services_test.rb +23 -23
- data/test/unit/cloud_test.rb +10 -10
- data/test/unit/http/method_builder_test.rb +13 -23
- data/test/unit/http/request_test.rb +1 -1
- data/test/unit/microversion_test.rb +13 -16
- data/test/unit/misty_test.rb +51 -49
- data/test/unit/openstack/APIs_test.rb +5 -9
- data/test/unit/openstack/extension_test.rb +6 -6
- data/test/unit/openstack/service_test.rb +2 -10
- data/test/unit/service_helper.rb +3 -8
- data/test/unit/services_test.rb +5 -5
- metadata +91 -66
- data/lib/misty/auth.rb +0 -91
- data/lib/misty/auth/auth_v2.rb +0 -65
- data/lib/misty/auth/auth_v3.rb +0 -89
- data/lib/misty/autoload.rb +0 -99
- data/lib/misty/client_pack.rb +0 -16
- data/lib/misty/openstack/aodh/v2.rb +0 -17
- data/lib/misty/openstack/ceilometer/v2.rb +0 -17
- data/lib/misty/openstack/cinder/v1.rb +0 -21
- data/lib/misty/openstack/cinder/v2.rb +0 -22
- data/lib/misty/openstack/cinder/v3.rb +0 -31
- data/lib/misty/openstack/designate/v2.rb +0 -17
- data/lib/misty/openstack/freezer/v1.rb +0 -17
- data/lib/misty/openstack/glance/v1.rb +0 -17
- data/lib/misty/openstack/glance/v2.rb +0 -17
- data/lib/misty/openstack/heat/v1.rb +0 -21
- data/lib/misty/openstack/ironic/v1.rb +0 -27
- data/lib/misty/openstack/karbor/v1.rb +0 -17
- data/lib/misty/openstack/keystone/keystone_v2_0_ext.rb +0 -18
- data/lib/misty/openstack/keystone/v2_0.rb +0 -21
- data/lib/misty/openstack/keystone/v3.rb +0 -21
- data/lib/misty/openstack/magnum/v1.rb +0 -23
- data/lib/misty/openstack/manila/v2.rb +0 -27
- data/lib/misty/openstack/murano/v1.rb +0 -17
- data/lib/misty/openstack/neutron/v2_0.rb +0 -17
- data/lib/misty/openstack/nova/v2_1.rb +0 -42
- data/lib/misty/openstack/octavia/v2_0.rb +0 -17
- data/lib/misty/openstack/sahara/v1_1.rb +0 -17
- data/lib/misty/openstack/searchlight/v1.rb +0 -17
- data/lib/misty/openstack/senlin/v1.rb +0 -17
- data/lib/misty/openstack/swift/v1.rb +0 -32
- data/lib/misty/openstack/tacker/v1_0.rb +0 -17
- data/lib/misty/openstack/trove/v1_0.rb +0 -17
- data/lib/misty/openstack/zaqar/v2.rb +0 -17
@@ -75,7 +75,7 @@ describe 'Misty::Cloud' do
|
|
75
75
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
76
76
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('backup', 'freezer')), :headers => token_header)
|
77
77
|
|
78
|
-
cloud.backup.must_be_kind_of Misty::Openstack::Freezer::V1
|
78
|
+
cloud.backup.must_be_kind_of Misty::Openstack::API::Freezer::V1
|
79
79
|
end
|
80
80
|
|
81
81
|
it '#baremetal' do
|
@@ -87,19 +87,19 @@ describe 'Misty::Cloud' do
|
|
87
87
|
with(:headers => auth_headers).
|
88
88
|
to_return(:status => 200, :body => JSON.dump(versions), :headers => {})
|
89
89
|
|
90
|
-
cloud.baremetal.must_be_kind_of Misty::Openstack::Ironic::V1
|
90
|
+
cloud.baremetal.must_be_kind_of Misty::Openstack::API::Ironic::V1
|
91
91
|
end
|
92
92
|
|
93
93
|
it '#blockStorage' do
|
94
94
|
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
95
95
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
96
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3('
|
96
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('volumev3', 'cinder')), :headers => token_header)
|
97
97
|
|
98
98
|
stub_request(:get, 'http://localhost/').
|
99
99
|
with(:headers => auth_headers).
|
100
100
|
to_return(:status => 200, :body => JSON.dump(versions), :headers => {})
|
101
101
|
|
102
|
-
cloud.block_storage.must_be_kind_of Misty::Openstack::Cinder::V3
|
102
|
+
cloud.block_storage.must_be_kind_of Misty::Openstack::API::Cinder::V3
|
103
103
|
end
|
104
104
|
|
105
105
|
describe '#compute' do
|
@@ -112,7 +112,7 @@ describe 'Misty::Cloud' do
|
|
112
112
|
with(:headers => auth_headers).
|
113
113
|
to_return(:status => 200, :body => JSON.dump(versions), :headers => {})
|
114
114
|
|
115
|
-
cloud.compute.must_be_kind_of Misty::Openstack::Nova::V2_1
|
115
|
+
cloud.compute.must_be_kind_of Misty::Openstack::API::Nova::V2_1
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'with microversion provided' do
|
@@ -126,7 +126,7 @@ describe 'Misty::Cloud' do
|
|
126
126
|
|
127
127
|
compute_cloud = Misty::Cloud.new(:auth => auth, :compute => {:version => '2.17'})
|
128
128
|
|
129
|
-
compute_cloud.compute.must_be_kind_of Misty::Openstack::Nova::V2_1
|
129
|
+
compute_cloud.compute.must_be_kind_of Misty::Openstack::API::Nova::V2_1
|
130
130
|
|
131
131
|
stub_request(:get, "http://localhost/servers").
|
132
132
|
with(:headers => {'Accept'=>'application/json; q=1.0', 'X-Auth-Token'=>'token_data', 'X-Openstack-Nova-Api-Version'=>'2.17'})
|
@@ -145,7 +145,7 @@ describe 'Misty::Cloud' do
|
|
145
145
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
146
146
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('data-processing', 'sahara')), :headers => token_header)
|
147
147
|
|
148
|
-
cloud.data_processing.must_be_kind_of Misty::Openstack::Sahara::V1_1
|
148
|
+
cloud.data_processing.must_be_kind_of Misty::Openstack::API::Sahara::V1_1
|
149
149
|
end
|
150
150
|
|
151
151
|
it '#identity' do
|
@@ -153,7 +153,7 @@ describe 'Misty::Cloud' do
|
|
153
153
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
154
154
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => token_header)
|
155
155
|
|
156
|
-
cloud.identity.must_be_kind_of Misty::Openstack::Keystone::V3
|
156
|
+
cloud.identity.must_be_kind_of Misty::Openstack::API::Keystone::V3
|
157
157
|
end
|
158
158
|
|
159
159
|
it '#image' do
|
@@ -161,7 +161,7 @@ describe 'Misty::Cloud' do
|
|
161
161
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
162
162
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('image', 'glance')), :headers => token_header)
|
163
163
|
|
164
|
-
cloud.image.must_be_kind_of Misty::Openstack::Glance::V2
|
164
|
+
cloud.image.must_be_kind_of Misty::Openstack::API::Glance::V2
|
165
165
|
end
|
166
166
|
|
167
167
|
it '#load_balancer' do
|
@@ -169,15 +169,15 @@ describe 'Misty::Cloud' do
|
|
169
169
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
170
170
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('load-balancer', 'octavia')), :headers => token_header)
|
171
171
|
|
172
|
-
cloud.load_balancer.must_be_kind_of Misty::Openstack::Octavia::V2_0
|
172
|
+
cloud.load_balancer.must_be_kind_of Misty::Openstack::API::Octavia::V2_0
|
173
173
|
end
|
174
174
|
|
175
|
-
it '#
|
175
|
+
it '#network' do
|
176
176
|
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
177
177
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
178
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3('
|
178
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => token_header)
|
179
179
|
|
180
|
-
cloud.
|
180
|
+
cloud.network.must_be_kind_of Misty::Openstack::API::Neutron::V2_0
|
181
181
|
end
|
182
182
|
|
183
183
|
it '#nfv_orchestration' do
|
@@ -185,7 +185,7 @@ describe 'Misty::Cloud' do
|
|
185
185
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
186
186
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('nfv-orchestration', 'tacker')), :headers => token_header)
|
187
187
|
|
188
|
-
cloud.nfv_orchestration.must_be_kind_of Misty::Openstack::Tacker::V1_0
|
188
|
+
cloud.nfv_orchestration.must_be_kind_of Misty::Openstack::API::Tacker::V1_0
|
189
189
|
end
|
190
190
|
|
191
191
|
describe '#objectStorage' do
|
@@ -194,7 +194,7 @@ describe 'Misty::Cloud' do
|
|
194
194
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
195
195
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('object-store', 'swift')), :headers => token_header)
|
196
196
|
|
197
|
-
cloud.object_storage.must_be_kind_of Misty::Openstack::Swift::V1
|
197
|
+
cloud.object_storage.must_be_kind_of Misty::Openstack::API::Swift::V1
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'execute bulk_delete' do
|
@@ -216,7 +216,7 @@ describe 'Misty::Cloud' do
|
|
216
216
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
217
217
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('orchestration', 'heat')), :headers => token_header)
|
218
218
|
|
219
|
-
cloud.orchestration.must_be_kind_of Misty::Openstack::Heat::V1
|
219
|
+
cloud.orchestration.must_be_kind_of Misty::Openstack::API::Heat::V1
|
220
220
|
end
|
221
221
|
|
222
222
|
it '#search' do
|
@@ -224,34 +224,34 @@ describe 'Misty::Cloud' do
|
|
224
224
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
225
225
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('search', 'searchlight')), :headers => token_header)
|
226
226
|
|
227
|
-
cloud.search.must_be_kind_of Misty::Openstack::Searchlight::V1
|
227
|
+
cloud.search.must_be_kind_of Misty::Openstack::API::Searchlight::V1
|
228
228
|
end
|
229
229
|
|
230
230
|
it '#sharedFileSystems' do
|
231
231
|
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
232
232
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
233
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3('shared-file-
|
233
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('shared-file-system', 'manila')), :headers => token_header)
|
234
234
|
|
235
235
|
stub_request(:get, 'http://localhost/').
|
236
236
|
with(:headers => auth_headers).
|
237
237
|
to_return(:status => 200, :body => JSON.dump(versions), :headers => {})
|
238
238
|
|
239
|
-
cloud.shared_file_systems.must_be_kind_of Misty::Openstack::Manila::V2
|
239
|
+
cloud.shared_file_systems.must_be_kind_of Misty::Openstack::API::Manila::V2
|
240
240
|
end
|
241
241
|
|
242
242
|
describe 'prefixed service name' do
|
243
|
-
it '#network match
|
243
|
+
it '#network match network' do
|
244
244
|
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
245
245
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
246
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3('
|
246
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('network', 'neutron')), :headers => token_header)
|
247
247
|
|
248
|
-
cloud.network.must_be_kind_of Misty::Openstack::Neutron::V2_0
|
248
|
+
cloud.network.must_be_kind_of Misty::Openstack::API::Neutron::V2_0
|
249
249
|
end
|
250
250
|
|
251
251
|
it '#data is ambiguous' do
|
252
252
|
stub_request(:post, 'http://localhost:5000/v3/auth/tokens').
|
253
253
|
with(:body => JSON.dump(auth_body), :headers => auth_headers).
|
254
|
-
to_return(:status => 200, :body => JSON.dump(auth_response_v3('
|
254
|
+
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => token_header)
|
255
255
|
|
256
256
|
proc do
|
257
257
|
cloud.data
|
data/test/unit/cloud_test.rb
CHANGED
@@ -32,28 +32,28 @@ describe Misty::Cloud do
|
|
32
32
|
it 'uses default version' do
|
33
33
|
auth_request
|
34
34
|
cloud = Misty::Cloud.new(arg)
|
35
|
-
cloud.identity.must_be_kind_of Misty::Openstack::Keystone::V3
|
35
|
+
cloud.identity.must_be_kind_of Misty::Openstack::API::Keystone::V3
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'uses default version when provided version is out of range' do
|
39
39
|
auth_request
|
40
40
|
arg.merge!(:identity => {:api_version => 'v1'})
|
41
41
|
cloud = Misty::Cloud.new(arg)
|
42
|
-
cloud.identity.must_be_kind_of Misty::Openstack::Keystone::V3
|
42
|
+
cloud.identity.must_be_kind_of Misty::Openstack::API::Keystone::V3
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'uses provided version' do
|
46
46
|
auth_request
|
47
47
|
arg.merge!(:identity => {:api_version => 'v2.0'})
|
48
48
|
cloud = Misty::Cloud.new(arg)
|
49
|
-
cloud.identity.must_be_kind_of Misty::Openstack::Keystone::V2_0
|
49
|
+
cloud.identity.must_be_kind_of Misty::Openstack::API::Keystone::V2_0
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe 'Each service' do
|
54
54
|
it 'has a method defined' do
|
55
55
|
Misty::services.each do |service|
|
56
|
-
method = Misty::Cloud.method_defined?(service.
|
56
|
+
method = Misty::Cloud.method_defined?(service.type)
|
57
57
|
method.must_equal true
|
58
58
|
end
|
59
59
|
end
|
@@ -88,7 +88,7 @@ describe Misty::Cloud do
|
|
88
88
|
|
89
89
|
proc do
|
90
90
|
Misty::Cloud.new(:auth => authv3_data)
|
91
|
-
end.must_raise Misty::Auth::URLError
|
91
|
+
end.must_raise Misty::Auth::Token::URLError
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'with empty url' do
|
@@ -101,7 +101,7 @@ describe Misty::Cloud do
|
|
101
101
|
|
102
102
|
proc do
|
103
103
|
Misty::Cloud.new(:auth => authv3_data)
|
104
|
-
end.must_raise Misty::Auth::URLError
|
104
|
+
end.must_raise Misty::Auth::Token::URLError
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -116,10 +116,10 @@ describe Misty::Cloud do
|
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
119
|
-
it 'uses
|
119
|
+
it 'uses Misty::Auth::Token::V3' do
|
120
120
|
authv2 = Minitest::Mock.new
|
121
121
|
|
122
|
-
|
122
|
+
Misty::Auth::Token::V2.stub :new, authv2 do
|
123
123
|
cloud = Misty::Cloud.new(:auth => authv2_data)
|
124
124
|
assert_mock authv2
|
125
125
|
end
|
@@ -136,10 +136,10 @@ describe Misty::Cloud do
|
|
136
136
|
}
|
137
137
|
end
|
138
138
|
|
139
|
-
it 'uses
|
139
|
+
it 'uses Misty::Auth::Token::V3' do
|
140
140
|
authv3 = Minitest::Mock.new
|
141
141
|
|
142
|
-
Misty::
|
142
|
+
Misty::Auth::Token::V3.stub :new, authv3 do
|
143
143
|
cloud = Misty::Cloud.new(:auth => authv3_data)
|
144
144
|
assert_mock authv3
|
145
145
|
end
|
@@ -3,15 +3,14 @@ require 'misty/http/method_builder'
|
|
3
3
|
|
4
4
|
describe Misty::HTTP::MethodBuilder do
|
5
5
|
let(:service) do
|
6
|
-
|
7
|
-
|
6
|
+
service = Object.new
|
7
|
+
service.extend(Misty::HTTP::MethodBuilder)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
def service.base_path=(val)
|
10
|
+
@base_path = val
|
12
11
|
end
|
13
12
|
|
14
|
-
|
13
|
+
service
|
15
14
|
end
|
16
15
|
|
17
16
|
describe '#base_filter' do
|
@@ -37,8 +36,8 @@ describe Misty::HTTP::MethodBuilder do
|
|
37
36
|
end
|
38
37
|
|
39
38
|
describe '#get_method' do
|
40
|
-
|
41
|
-
def api
|
39
|
+
before do
|
40
|
+
def service.api
|
42
41
|
{
|
43
42
|
'/' => { GET: [:list_api_versions] },
|
44
43
|
'/v2.0/' => { GET: [:show_api_v2_details] },
|
@@ -78,10 +77,8 @@ describe Misty::HTTP::MethodBuilder do
|
|
78
77
|
|
79
78
|
describe '#prefixed_path' do
|
80
79
|
it 'returns true and same path with empty prefix' do
|
81
|
-
|
82
|
-
|
83
|
-
''
|
84
|
-
end
|
80
|
+
def service.prefix_path_to_ignore
|
81
|
+
''
|
85
82
|
end
|
86
83
|
|
87
84
|
path = '/v3/resources/type'
|
@@ -91,10 +88,8 @@ describe Misty::HTTP::MethodBuilder do
|
|
91
88
|
end
|
92
89
|
|
93
90
|
it 'returns false and same path when unmatched prefix' do
|
94
|
-
|
95
|
-
|
96
|
-
'/v3/{project_id}'
|
97
|
-
end
|
91
|
+
def service.prefix_path_to_ignore
|
92
|
+
'/v3/{project_id}'
|
98
93
|
end
|
99
94
|
|
100
95
|
path = '/v2/schemas/tasks'
|
@@ -104,10 +99,8 @@ describe Misty::HTTP::MethodBuilder do
|
|
104
99
|
end
|
105
100
|
|
106
101
|
it 'returns true and filtered path when matched prefix' do
|
107
|
-
|
108
|
-
|
109
|
-
'/v3/{project_id}'
|
110
|
-
end
|
102
|
+
def service.prefix_path_to_ignore
|
103
|
+
'/v3/{project_id}'
|
111
104
|
end
|
112
105
|
|
113
106
|
path = '/v3/{project_id}/backups/detail'
|
@@ -128,12 +121,9 @@ describe Misty::HTTP::MethodBuilder do
|
|
128
121
|
|
129
122
|
it 'returns a query string when passing in a Hash' do
|
130
123
|
service.send(:query_param, {}).must_equal ''
|
131
|
-
|
132
124
|
service.send(:query_param, {:foo => 'bar'}).must_equal '?foo=bar'
|
133
125
|
service.send(:query_param, {'foo' => 'bar'}).must_equal '?foo=bar'
|
134
|
-
|
135
126
|
service.send(:query_param, {:foo => ['bar', 'baz'], :value => 42, :flag => nil }).must_equal '?foo=bar&foo=baz&value=42&flag'
|
136
|
-
|
137
127
|
service.send(:query_param, {'===' => 'Ëncøding is hárd!'}).must_equal '?%3D%3D%3D=%C3%8Bnc%C3%B8ding+is+h%C3%A1rd%21'
|
138
128
|
end
|
139
129
|
|
@@ -126,7 +126,7 @@ describe Misty::HTTP::Request do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it '#http_to_s' do
|
129
|
-
service.http_to_s('VERB', '
|
129
|
+
service.http_to_s('VERB', 'resource', 'headers', 'data' => 'value').must_equal "HTTP VERB 'localhost:80/resource', header=headers, data='{\"data\"=>\"value\"}'"
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -41,9 +41,9 @@ describe Misty::Microversion do
|
|
41
41
|
to_return(:status => 200, :body => JSON.dump(auth_response_v3('identity', 'keystone')), :headers => {'x-subject-token'=>'token_data'})
|
42
42
|
|
43
43
|
def service.setup
|
44
|
-
@
|
44
|
+
@endpoint = URI.parse('http://localhost/')
|
45
45
|
@log = Logger.new('/dev/null')
|
46
|
-
@
|
46
|
+
@token = Misty::Auth::Token::V3.new(
|
47
47
|
:url => 'http://localhost:5000',
|
48
48
|
:user_id => 'user_id',
|
49
49
|
:password => 'secret',
|
@@ -51,27 +51,22 @@ describe Misty::Microversion do
|
|
51
51
|
)
|
52
52
|
end
|
53
53
|
service.setup
|
54
|
-
end
|
55
54
|
|
56
|
-
let(:fetch_request) do
|
57
55
|
stub_request(:get, "http://localhost/").
|
58
|
-
|
59
|
-
|
56
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby', 'X-Auth-Token'=>'token_data'}).
|
57
|
+
to_return(:status => 200, :body => JSON.dump(versions_data), :headers => {})
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'set microversion when number within min/max range' do
|
63
|
-
|
64
|
-
|
65
|
-
def service.service_names
|
66
|
-
%w{service_name1}
|
61
|
+
def service.service_types
|
62
|
+
%w(service_type1)
|
67
63
|
end
|
68
64
|
|
69
|
-
service.
|
65
|
+
service.set_version('2.60')
|
66
|
+
service.microversion_header('2.60').must_equal({"X-Openstack-API-Version" => "service_type1 2.60"})
|
70
67
|
end
|
71
68
|
|
72
69
|
it 'fails when asked version is not within min-max range' do
|
73
|
-
fetch_request
|
74
|
-
|
75
70
|
proc do
|
76
71
|
service.set_version('3.20')
|
77
72
|
end.must_raise Misty::Microversion::VersionError
|
@@ -79,10 +74,12 @@ describe Misty::Microversion do
|
|
79
74
|
end
|
80
75
|
|
81
76
|
it "set microversion to 'latest'" do
|
82
|
-
def service.
|
83
|
-
%w
|
77
|
+
def service.service_types
|
78
|
+
%w(service_type2)
|
84
79
|
end
|
85
|
-
|
80
|
+
|
81
|
+
service.set_version('latest')
|
82
|
+
service.microversion_header('latest').must_equal({"X-Openstack-API-Version" => "service_type2 latest"})
|
86
83
|
end
|
87
84
|
|
88
85
|
it 'fails when version is a wrong word' do
|
data/test/unit/misty_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
def validate_service(service)
|
4
4
|
service.must_be_kind_of Misty::Service
|
5
|
-
service.
|
5
|
+
service.type.must_be_kind_of Symbol
|
6
6
|
service.project.must_be_kind_of Symbol
|
7
7
|
end
|
8
8
|
|
@@ -20,116 +20,116 @@ end
|
|
20
20
|
describe Misty do
|
21
21
|
describe '#set_services' do
|
22
22
|
it 'has alarming service' do
|
23
|
-
service = Misty::services.find { |s| s.
|
23
|
+
service = Misty::services.find { |s| s.type == :alarming}
|
24
24
|
validate_service(service)
|
25
25
|
validate_versions(service)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'has baremetal service' do
|
29
|
-
service = Misty::services.find { |s| s.
|
29
|
+
service = Misty::services.find { |s| s.type == :baremetal}
|
30
30
|
validate_service(service)
|
31
31
|
validate_microversion(service)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'has block_storage service' do
|
35
|
-
service = Misty::services.find { |s| s.
|
35
|
+
service = Misty::services.find { |s| s.type == :block_storage}
|
36
36
|
validate_service(service)
|
37
37
|
validate_versions(service)
|
38
38
|
validate_microversion(service)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'has clustering service' do
|
42
|
-
service = Misty::services.find { |s| s.
|
42
|
+
service = Misty::services.find { |s| s.type == :clustering}
|
43
43
|
validate_service(service)
|
44
44
|
validate_versions(service)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'has compute service' do
|
48
|
-
service = Misty::services.find { |s| s.
|
48
|
+
service = Misty::services.find { |s| s.type == :compute}
|
49
49
|
validate_service(service)
|
50
50
|
validate_microversion(service)
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'has container_infrastructure_management service' do
|
54
|
-
service = Misty::services.find { |s| s.
|
54
|
+
service = Misty::services.find { |s| s.type == :container_infrastructure_management}
|
55
55
|
validate_service(service)
|
56
56
|
validate_microversion(service)
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'has data_processing service' do
|
60
|
-
service = Misty::services.find { |s| s.
|
60
|
+
service = Misty::services.find { |s| s.type == :data_processing}
|
61
61
|
validate_service(service)
|
62
62
|
validate_versions(service)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'has data_protection service' do
|
66
|
-
service = Misty::services.find { |s| s.
|
66
|
+
service = Misty::services.find { |s| s.type == :data_protection_orchestration}
|
67
67
|
validate_service(service)
|
68
68
|
validate_versions(service)
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'has database service' do
|
72
|
-
service = Misty::services.find { |s| s.
|
72
|
+
service = Misty::services.find { |s| s.type == :database}
|
73
73
|
validate_service(service)
|
74
74
|
validate_versions(service)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'has dns service' do
|
78
|
-
service = Misty::services.find { |s| s.
|
78
|
+
service = Misty::services.find { |s| s.type == :dns}
|
79
79
|
validate_service(service)
|
80
80
|
validate_versions(service)
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'has identity service' do
|
84
|
-
service = Misty::services.find { |s| s.
|
84
|
+
service = Misty::services.find { |s| s.type == :identity}
|
85
85
|
validate_service(service)
|
86
86
|
validate_versions(service)
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'has image service' do
|
90
|
-
service = Misty::services.find { |s| s.
|
90
|
+
service = Misty::services.find { |s| s.type == :image}
|
91
91
|
validate_service(service)
|
92
92
|
validate_versions(service)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'has messaging service' do
|
96
|
-
service = Misty::services.find { |s| s.
|
96
|
+
service = Misty::services.find { |s| s.type == :messaging}
|
97
97
|
validate_service(service)
|
98
98
|
validate_versions(service)
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'has metering service' do
|
102
|
-
service = Misty::services.find { |s| s.
|
102
|
+
service = Misty::services.find { |s| s.type == :metering}
|
103
103
|
validate_service(service)
|
104
104
|
validate_versions(service)
|
105
105
|
end
|
106
106
|
|
107
|
-
it 'has
|
108
|
-
service = Misty::services.find { |s| s.
|
107
|
+
it 'has network service' do
|
108
|
+
service = Misty::services.find { |s| s.type == :network}
|
109
109
|
validate_service(service)
|
110
110
|
validate_versions(service)
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'has object_storage service' do
|
114
|
-
service = Misty::services.find { |s| s.
|
114
|
+
service = Misty::services.find { |s| s.type == :object_storage}
|
115
115
|
validate_service(service)
|
116
116
|
validate_versions(service)
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'has orchestration service' do
|
120
|
-
service = Misty::services.find { |s| s.
|
120
|
+
service = Misty::services.find { |s| s.type == :orchestration}
|
121
121
|
validate_service(service)
|
122
122
|
validate_versions(service)
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'has search service' do
|
126
|
-
service = Misty::services.find { |s| s.
|
126
|
+
service = Misty::services.find { |s| s.type == :search}
|
127
127
|
validate_service(service)
|
128
128
|
validate_versions(service)
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'has shared_file_systems service' do
|
132
|
-
service = Misty::services.find { |s| s.
|
132
|
+
service = Misty::services.find { |s| s.type == :shared_file_systems}
|
133
133
|
validate_service(service)
|
134
134
|
validate_microversion(service)
|
135
135
|
end
|
@@ -142,41 +142,43 @@ describe Misty do
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
describe '
|
146
|
-
|
147
|
-
|
148
|
-
|
145
|
+
describe 'Misty::Helper' do
|
146
|
+
describe '#json_encode?' do
|
147
|
+
it 'true with a Array type' do
|
148
|
+
Misty::Helper.json_encode?([]).must_equal true
|
149
|
+
end
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
it 'true with a Hash type' do
|
152
|
+
Misty::Helper.json_encode?({}).must_equal true
|
153
|
+
end
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
|
155
|
+
it 'true with a JSON String type' do
|
156
|
+
Misty::Helper.json_encode?('{"JSON_Key": "JSON_Value"}').must_equal true
|
157
|
+
end
|
157
158
|
|
158
|
-
|
159
|
-
|
159
|
+
it 'false with a non JSON String type' do
|
160
|
+
Misty::Helper.json_encode?("Just a string").must_equal false
|
161
|
+
end
|
160
162
|
end
|
161
|
-
end
|
162
163
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
164
|
+
describe '#to_json' do
|
165
|
+
it 'returns a JSON string when using a Ruby hash' do
|
166
|
+
Misty::Helper.to_json({'key' => 'val'}).must_be_kind_of String
|
167
|
+
end
|
167
168
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
169
|
+
it 'returns same string when using a string' do
|
170
|
+
data = "{\"key\": \"val\"}"
|
171
|
+
response = Misty::Helper.to_json(data)
|
172
|
+
response.must_be_kind_of String
|
173
|
+
response.must_equal data
|
174
|
+
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
176
|
+
it 'fails when using a string with non JSON data' do
|
177
|
+
data = 'key;val'
|
178
|
+
proc do
|
179
|
+
response = Misty::Helper.to_json(data)
|
180
|
+
end.must_raise JSON::ParserError
|
181
|
+
end
|
180
182
|
end
|
181
183
|
end
|
182
184
|
end
|