deltacloud-core 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTICE +1 -1
- data/Rakefile +63 -21
- data/bin/deltacloudd +10 -6
- data/config.ru +62 -6
- data/config/drivers/ec2.yaml +8 -0
- data/config/drivers/fgcp.yaml +13 -0
- data/deltacloud-core.gemspec +10 -2
- data/lib/cimi/collections.rb +58 -0
- data/lib/cimi/collections/address_templates.rb +49 -0
- data/lib/cimi/collections/addresses.rb +74 -0
- data/lib/cimi/collections/cloud_entry_point.rb +37 -0
- data/lib/{deltacloud/helpers/conversion_helper.rb → cimi/collections/entity_metadata.rb} +24 -16
- data/lib/cimi/collections/machine_admins.rb +74 -0
- data/lib/cimi/collections/machine_configurations.rb +49 -0
- data/lib/cimi/collections/machine_images.rb +50 -0
- data/lib/cimi/collections/machines.rb +157 -0
- data/lib/cimi/collections/network_configurations.rb +47 -0
- data/lib/cimi/collections/network_templates.rb +48 -0
- data/lib/cimi/collections/networks.rb +125 -0
- data/lib/cimi/collections/routing_group_templates.rb +47 -0
- data/lib/cimi/collections/routing_groups.rb +48 -0
- data/lib/cimi/collections/volume_configurations.rb +48 -0
- data/lib/cimi/collections/volume_images.rb +50 -0
- data/lib/cimi/collections/volumes.rb +80 -0
- data/lib/cimi/collections/vsp_configurations.rb +48 -0
- data/lib/cimi/collections/vsp_templates.rb +50 -0
- data/lib/cimi/collections/vsps.rb +108 -0
- data/lib/cimi/dependencies.rb +1 -0
- data/lib/cimi/helpers.rb +116 -0
- data/lib/cimi/helpers/cimi_helper.rb +6 -2
- data/lib/cimi/models.rb +72 -0
- data/lib/cimi/{model → models}/action.rb +1 -1
- data/lib/cimi/models/address.rb +72 -0
- data/lib/cimi/models/address_collection.rb +34 -0
- data/lib/cimi/models/address_template.rb +54 -0
- data/lib/cimi/models/address_template_collection.rb +34 -0
- data/lib/cimi/{model → models}/base.rb +2 -2
- data/lib/cimi/{model → models}/cloud_entry_point.rb +3 -5
- data/lib/cimi/{model → models}/entity_metadata.rb +7 -6
- data/lib/cimi/{model → models}/entity_metadata_collection.rb +2 -2
- data/lib/cimi/{model → models}/errors.rb +8 -0
- data/lib/cimi/{model → models}/machine.rb +10 -10
- data/lib/cimi/{model → models}/machine_admin.rb +1 -1
- data/lib/cimi/{model → models}/machine_admin_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_configuration.rb +9 -6
- data/lib/cimi/{model → models}/machine_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_image.rb +1 -1
- data/lib/cimi/{model → models}/machine_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_template.rb +0 -0
- data/lib/cimi/{model → models}/machine_template_collection.rb +2 -2
- data/lib/cimi/models/network.rb +109 -0
- data/lib/cimi/{model → models}/network_collection.rb +2 -2
- data/lib/cimi/{model → models}/network_configuration.rb +3 -4
- data/lib/cimi/{model → models}/network_configuration_collection.rb +2 -2
- data/lib/cimi/models/network_template.rb +36 -0
- data/lib/cimi/models/network_template_collection.rb +35 -0
- data/lib/cimi/models/routing_group.rb +34 -0
- data/lib/cimi/models/routing_group_collection.rb +34 -0
- data/lib/cimi/models/routing_group_template.rb +34 -0
- data/lib/cimi/models/routing_group_template_collection.rb +35 -0
- data/lib/cimi/{model → models}/schema.rb +0 -0
- data/lib/cimi/{model → models}/volume.rb +4 -4
- data/lib/cimi/{model → models}/volume_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_configuration.rb +1 -1
- data/lib/cimi/{model → models}/volume_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_image.rb +1 -1
- data/lib/cimi/{model → models}/volume_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_template.rb +0 -0
- data/lib/cimi/{model → models}/volume_template_collection.rb +2 -2
- data/lib/cimi/models/vsp.rb +102 -0
- data/lib/cimi/models/vsp_collection.rb +34 -0
- data/lib/cimi/models/vsp_configuration.rb +40 -0
- data/lib/cimi/models/vsp_configuration_collection.rb +34 -0
- data/lib/cimi/models/vsp_template.rb +34 -0
- data/lib/cimi/models/vsp_template_collection.rb +34 -0
- data/lib/cimi/server.rb +27 -549
- data/lib/deltacloud/api.rb +79 -0
- data/lib/deltacloud/collections.rb +54 -0
- data/lib/deltacloud/collections/addresses.rb +91 -0
- data/lib/deltacloud/collections/buckets.rb +273 -0
- data/lib/deltacloud/collections/drivers.rb +51 -0
- data/lib/deltacloud/collections/firewalls.rb +116 -0
- data/lib/deltacloud/collections/hardware_profiles.rb +29 -0
- data/lib/deltacloud/collections/images.rb +73 -0
- data/lib/deltacloud/collections/instance_states.rb +59 -0
- data/lib/deltacloud/collections/instances.rb +113 -0
- data/lib/deltacloud/collections/keys.rb +61 -0
- data/lib/deltacloud/collections/load_balancers.rb +102 -0
- data/lib/deltacloud/collections/metrics.rb +28 -0
- data/lib/deltacloud/collections/realms.rb +28 -0
- data/lib/deltacloud/collections/storage_snapshots.rb +51 -0
- data/lib/deltacloud/collections/storage_volumes.rb +99 -0
- data/lib/deltacloud/core_ext.rb +14 -6
- data/lib/deltacloud/core_ext/string.rb +17 -5
- data/lib/deltacloud/drivers.rb +6 -42
- data/lib/deltacloud/drivers/azure/azure_driver.rb +0 -4
- data/lib/deltacloud/{base_driver → drivers}/base_driver.rb +56 -18
- data/lib/deltacloud/drivers/condor/condor_driver.rb +1 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +142 -33
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +2 -6
- data/lib/deltacloud/{base_driver → drivers}/exceptions.rb +25 -2
- data/lib/deltacloud/drivers/features.rb +154 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +387 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1435 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +8 -11
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -5
- data/lib/deltacloud/drivers/mock/data/keys/test-key.yml +28 -0
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver.rb +58 -40
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +145 -0
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +107 -73
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +285 -145
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +189 -126
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +427 -8
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +7 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +48 -66
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +44 -51
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +7 -8
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -3
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +8 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +39 -13
- data/lib/deltacloud/drivers/vsphere/vsphere_filemanager.rb +1 -0
- data/lib/deltacloud/helpers.rb +79 -7
- data/lib/{sinatra/lazy_auth.rb → deltacloud/helpers/auth_helper.rb} +5 -9
- data/lib/deltacloud/helpers/{blob_stream.rb → blob_stream_helper.rb} +7 -7
- data/lib/deltacloud/helpers/deltacloud_helper.rb +286 -0
- data/lib/deltacloud/helpers/driver_helper.rb +58 -0
- data/lib/deltacloud/helpers/rabbit_helper.rb +34 -0
- data/lib/{sinatra/url_for.rb → deltacloud/helpers/url_helper.rb} +31 -9
- data/lib/deltacloud/models.rb +19 -17
- data/lib/deltacloud/models/bucket.rb +4 -0
- data/lib/deltacloud/{hardware_profile.rb → models/hardware_profile.rb} +4 -2
- data/lib/deltacloud/models/image.rb +1 -0
- data/lib/deltacloud/models/instance.rb +4 -2
- data/lib/deltacloud/models/instance_address.rb +4 -0
- data/lib/deltacloud/models/key.rb +4 -0
- data/lib/deltacloud/models/metric.rb +40 -0
- data/lib/deltacloud/{state_machine.rb → models/state_machine.rb} +18 -1
- data/lib/deltacloud/server.rb +41 -1222
- data/lib/deltacloud_rack.rb +79 -0
- data/lib/{cimi/model/network_template.rb → ec2/helpers.rb} +7 -10
- data/lib/{deltacloud/backend_capability.rb → ec2/helpers/errors.rb} +24 -29
- data/lib/ec2/helpers/result.rb +31 -0
- data/lib/ec2/query_parser.rb +152 -0
- data/lib/ec2/server.rb +70 -0
- data/lib/{deltacloud.rb → sinatra.rb} +7 -12
- data/lib/sinatra/rack_accept.rb +13 -7
- data/lib/sinatra/rack_driver_select.rb +1 -1
- data/lib/sinatra/rack_matrix_params.rb +1 -3
- data/public/images/metric.png +0 -0
- data/public/javascripts/jquery.mobile-1.0.1.min.js +177 -0
- data/public/stylesheets/jquery.mobile-1.0.1.min.css +2 -0
- data/public/stylesheets/new.css +10 -0
- data/support/fedora/deltacloud-core.spec +1 -1
- data/tests/api/common.rb +1 -0
- data/tests/api/driver_test.rb +79 -0
- data/tests/api/library_test.rb +48 -0
- data/tests/cimi/features/step_definitions/common_steps.rb +2 -2
- data/tests/cimi/features/step_definitions/machines_steps.rb +5 -4
- data/tests/cimi/features/step_definitions/volumes_steps.rb +8 -8
- data/tests/cimi/features/support/env.rb +33 -11
- data/tests/common.rb +7 -8
- data/tests/drivers/ec2/api_test.rb +19 -0
- data/tests/drivers/ec2/common.rb +23 -0
- data/tests/drivers/ec2/drivers_test.rb +120 -0
- data/tests/drivers/ec2/hardware_profiles_test.rb +224 -0
- data/tests/drivers/ec2/images_test.rb +230 -0
- data/tests/drivers/ec2/instances_test.rb +356 -0
- data/tests/drivers/ec2/keys_test.rb +181 -0
- data/tests/drivers/ec2/realms_test.rb +146 -0
- data/tests/drivers/fgcp/api_test.rb +47 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +54 -0
- data/tests/drivers/fgcp/realms_test.rb +42 -0
- data/tests/drivers/{rackspace → fgcp}/setup.rb +5 -6
- data/tests/drivers/google/api_test.rb +10 -26
- data/tests/drivers/google/buckets_test.rb +79 -95
- data/tests/drivers/google/common.rb +54 -0
- data/tests/drivers/mock/api_test.rb +4 -127
- data/tests/drivers/mock/buckets_test.rb +195 -0
- data/tests/drivers/mock/common.rb +7 -0
- data/tests/drivers/mock/drivers_test.rb +123 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +190 -100
- data/tests/drivers/mock/images_test.rb +162 -103
- data/tests/drivers/mock/instances_test.rb +310 -220
- data/tests/drivers/mock/keys_test.rb +161 -0
- data/tests/drivers/mock/realms_test.rb +109 -70
- data/tests/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/drivers/openstack/api_test.rb +8 -3
- data/tests/drivers/openstack/common.rb +21 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +20 -9
- data/tests/drivers/openstack/images_test.rb +11 -5
- data/tests/drivers/openstack/instances_test.rb +61 -16
- data/tests/drivers/openstack/realms_test.rb +11 -7
- data/tests/drivers/rackspace/api_test.rb +7 -2
- data/tests/drivers/rackspace/buckets_test.rb +7 -2
- data/tests/drivers/rackspace/common.rb +16 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rackspace/images_test.rb +7 -2
- data/tests/drivers/rackspace/instances_test.rb +10 -5
- data/tests/drivers/rackspace/realms_test.rb +7 -2
- data/tests/drivers/rhevm/api_test.rb +12 -6
- data/tests/drivers/rhevm/{setup.rb → common.rb} +8 -1
- data/tests/drivers/rhevm/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rhevm/images_test.rb +8 -2
- data/tests/drivers/rhevm/instances_test.rb +7 -2
- data/tests/drivers/rhevm/realms_test.rb +7 -2
- data/tests/minitest_common.rb +58 -0
- data/tests/minitest_common_api_test.rb +115 -0
- data/views/addresses/associate.html.haml +1 -1
- data/views/addresses/index.html.haml +1 -1
- data/views/addresses/show.html.haml +2 -3
- data/views/api/show.html.haml +22 -9
- data/views/api/show.xml.haml +8 -7
- data/views/blobs/show.xml.haml +7 -4
- data/views/buckets/new.html.haml +2 -2
- data/views/cimi/errors/401.xml.haml +1 -1
- data/views/error.html.haml +3 -3
- data/views/errors/400.html.haml +1 -1
- data/views/errors/400.xml.haml +1 -2
- data/views/errors/401.html.haml +8 -7
- data/views/errors/401.xml.haml +1 -1
- data/views/errors/404.xml.haml +1 -0
- data/views/errors/500.xml.haml +4 -2
- data/views/{cimi/errors/403.html.haml → errors/501.html.haml} +4 -2
- data/views/errors/501.xml.haml +1 -0
- data/views/errors/502.xml.haml +1 -7
- data/views/{cimi/errors/500.html.haml → errors/504.html.haml} +0 -0
- data/views/errors/504.xml.haml +1 -0
- data/views/firewalls/new.html.haml +2 -2
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +1 -1
- data/views/hardware_profiles/index.html.haml +3 -1
- data/views/hardware_profiles/index.xml.haml +2 -2
- data/views/hardware_profiles/show.html.haml +3 -3
- data/views/hardware_profiles/show.xml.haml +3 -3
- data/views/images/show.html.haml +5 -0
- data/views/images/show.xml.haml +6 -1
- data/views/instance_states/show.html.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +54 -39
- data/views/instances/run_command.html.haml +24 -15
- data/views/instances/show.html.haml +7 -3
- data/views/instances/show.xml.haml +2 -2
- data/views/keys/show.xml.haml +1 -0
- data/views/layout.html.haml +5 -9
- data/views/load_balancers/show.html.haml +12 -6
- data/views/metrics/index.html.haml +13 -0
- data/views/metrics/index.xml.haml +5 -0
- data/views/metrics/show.html.haml +23 -0
- data/views/metrics/show.xml.haml +9 -0
- data/views/realms/show.xml.haml +2 -1
- data/views/root/index.html.haml +1 -1
- data/views/storage_snapshots/show.html.haml +1 -1
- data/views/storage_snapshots/show.xml.haml +1 -0
- data/views/storage_volumes/attach.html.haml +1 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +22 -16
- data/views/storage_volumes/show.html.haml +10 -4
- data/views/storage_volumes/show.xml.haml +3 -4
- metadata +547 -519
- data/DISCLAIMER +0 -8
- data/lib/cimi/model.rb +0 -52
- data/lib/cimi/model/network.rb +0 -69
- data/lib/deltacloud/base_driver.rb +0 -18
- data/lib/deltacloud/base_driver/features.rb +0 -262
- data/lib/deltacloud/base_driver/mock_driver.rb +0 -78
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -186
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +0 -521
- data/lib/deltacloud/helpers/application_helper.rb +0 -267
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -50
- data/lib/deltacloud/helpers/json_helper.rb +0 -31
- data/lib/deltacloud/method_serializer.rb +0 -83
- data/lib/deltacloud/validation.rb +0 -107
- data/lib/sinatra/rabbit.rb +0 -441
- data/lib/sinatra/rack_runtime.rb +0 -47
- data/lib/sinatra/rack_syslog.rb +0 -86
- data/lib/sinatra/sinatra_verbose.rb +0 -73
- data/lib/sinatra/static_assets.rb +0 -99
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +0 -170
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +0 -12
- data/tests/drivers/google/setup.rb +0 -38
- data/tests/drivers/mock/instance_states_test.rb +0 -71
- data/tests/drivers/mock/setup.rb +0 -3
- data/tests/drivers/mock/url_for_test.rb +0 -67
- data/tests/drivers/openstack/setup.rb +0 -20
- data/views/cimi/errors/400.html.haml +0 -41
- data/views/cimi/errors/401.html.haml +0 -41
- data/views/cimi/errors/404.html.haml +0 -29
- data/views/cimi/errors/405.html.haml +0 -29
- data/views/cimi/errors/502.html.haml +0 -43
- data/views/cimi/errors/backend_capability_failure.html.haml +0 -29
@@ -0,0 +1,195 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/drivers/mock/common'
|
3
|
+
|
4
|
+
describe 'Deltacloud API buckets' do
|
5
|
+
include Deltacloud::Test
|
6
|
+
|
7
|
+
it 'must advertise have the buckets collection in API entrypoint' do
|
8
|
+
get root_url
|
9
|
+
(xml_response/'api/link[@rel=buckets]').wont_be_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'must require authentication to access the "bucket" collection' do
|
13
|
+
get collection_url(:buckets)
|
14
|
+
last_response.status.must_equal 401
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should respond with HTTP_OK when accessing the :buckets collection with authentication' do
|
18
|
+
authenticate
|
19
|
+
get collection_url(:buckets)
|
20
|
+
last_response.status.must_equal 200
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should support the JSON media type' do
|
24
|
+
authenticate
|
25
|
+
header 'Accept', 'application/json'
|
26
|
+
get collection_url(:buckets)
|
27
|
+
last_response.status.must_equal 200
|
28
|
+
last_response.headers['Content-Type'].must_equal 'application/json'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'must include the ETag in HTTP headers' do
|
32
|
+
authenticate
|
33
|
+
get collection_url(:buckets)
|
34
|
+
last_response.headers['ETag'].wont_be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'must have the "buckets" element on top level' do
|
38
|
+
authenticate
|
39
|
+
get collection_url(:buckets)
|
40
|
+
xml_response.root.name.must_equal 'buckets'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'must have some "bucket" elements inside "buckets"' do
|
44
|
+
authenticate
|
45
|
+
get collection_url(:buckets)
|
46
|
+
(xml_response/'buckets/bucket').wont_be_empty
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'must provide the :id attribute for each bucket in collection' do
|
50
|
+
authenticate
|
51
|
+
get collection_url(:buckets)
|
52
|
+
(xml_response/'buckets/bucket').each do |r|
|
53
|
+
r[:id].wont_be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'must include the :href attribute for each "bucket" element in collection' do
|
58
|
+
authenticate
|
59
|
+
get collection_url(:buckets)
|
60
|
+
(xml_response/'buckets/bucket').each do |r|
|
61
|
+
r[:href].wont_be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'must use the absolute URL in each :href attribute' do
|
66
|
+
authenticate
|
67
|
+
get collection_url(:buckets)
|
68
|
+
(xml_response/'buckets/bucket').each do |r|
|
69
|
+
r[:href].must_match /^http/
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'must have the URL ending with the :id of the bucket' do
|
74
|
+
authenticate
|
75
|
+
get collection_url(:buckets)
|
76
|
+
(xml_response/'buckets/bucket').each do |r|
|
77
|
+
r[:href].must_match /#{r[:id]}$/
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'must return the list of valid parameters for the :index action' do
|
82
|
+
authenticate
|
83
|
+
options collection_url(:buckets) + '/index'
|
84
|
+
last_response.headers['Allow'].wont_be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'must have the "name" element defined for each bucket in collection' do
|
88
|
+
authenticate
|
89
|
+
get collection_url(:buckets)
|
90
|
+
(xml_response/'buckets/bucket').each do |r|
|
91
|
+
(r/'name').wont_be_nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'must have the "state" element defined for each bucket in collection' do
|
96
|
+
authenticate
|
97
|
+
get collection_url(:buckets)
|
98
|
+
(xml_response/'buckets/bucket').each do |r|
|
99
|
+
(r/'state').wont_be_nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'must return the full "bucket" when following the URL in bucket element' do
|
104
|
+
authenticate
|
105
|
+
get collection_url(:buckets)
|
106
|
+
(xml_response/'buckets/bucket').each do |r|
|
107
|
+
get collection_url(:buckets) + '/' + r[:id]
|
108
|
+
last_response.status.must_equal 200
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'must have the "name" element for the bucket and it should match with the one in collection' do
|
113
|
+
authenticate
|
114
|
+
get collection_url(:buckets)
|
115
|
+
(xml_response/'buckets/bucket').each do |r|
|
116
|
+
get collection_url(:buckets) + '/' + r[:id]
|
117
|
+
(xml_response/'name').wont_be_empty
|
118
|
+
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'must have the "size" element for the bucket and it should match with the one in collection' do
|
123
|
+
authenticate
|
124
|
+
get collection_url(:buckets)
|
125
|
+
(xml_response/'buckets/bucket').each do |r|
|
126
|
+
get collection_url(:buckets) + '/' + r[:id]
|
127
|
+
(xml_response/'size').wont_be_empty
|
128
|
+
(xml_response/'size').first.text.must_equal((r/'size').first.text)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'must have the "blob" elements for the bucket and it should match with the ones in collection' do
|
133
|
+
authenticate
|
134
|
+
get collection_url(:buckets)
|
135
|
+
(xml_response/'buckets/bucket').each do |r|
|
136
|
+
get collection_url(:buckets) + '/' + r[:id]
|
137
|
+
(xml_response/'bucket/blob').wont_be_empty
|
138
|
+
(xml_response/'bucket/blob').each do |b|
|
139
|
+
b[:id].wont_be_nil
|
140
|
+
b[:href].wont_be_nil
|
141
|
+
b[:href].must_match /^http/
|
142
|
+
b[:href].must_match /#{r[:id]}\/#{b[:id]}$/
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'must have the "blob" elements for the bucket and it should match with the ones in collection' do
|
148
|
+
authenticate
|
149
|
+
get collection_url(:buckets)
|
150
|
+
(xml_response/'buckets/bucket').each do |r|
|
151
|
+
get collection_url(:buckets) + '/' + r[:id]
|
152
|
+
(xml_response/'bucket/blob').wont_be_empty
|
153
|
+
(xml_response/'bucket/blob').each do |b|
|
154
|
+
b[:id].wont_be_nil
|
155
|
+
b[:href].wont_be_nil
|
156
|
+
b[:href].must_match /^http/
|
157
|
+
b[:href].must_match /#{r[:id]}\/#{b[:id]}$/
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'must allow to get all blobs details and the details should be set correctly' do
|
163
|
+
authenticate
|
164
|
+
get collection_url(:buckets)
|
165
|
+
(xml_response/'buckets/bucket').each do |r|
|
166
|
+
get collection_url(:buckets) + '/' + r[:id]
|
167
|
+
(xml_response/'bucket/blob').each do |b|
|
168
|
+
get collection_url(:buckets) + '/' + r[:id] + '/' + b[:id]
|
169
|
+
xml_response.root.name.must_equal 'blob'
|
170
|
+
xml_response.root[:id].must_equal b[:id]
|
171
|
+
(xml_response/'bucket').wont_be_empty
|
172
|
+
(xml_response/'bucket').size.must_equal 1
|
173
|
+
(xml_response/'bucket').first.text.wont_be_nil
|
174
|
+
(xml_response/'bucket').first.text.must_equal r[:id]
|
175
|
+
(xml_response/'content_length').wont_be_empty
|
176
|
+
(xml_response/'content_length').size.must_equal 1
|
177
|
+
(xml_response/'content_length').first.text.must_match /^(\d+)$/
|
178
|
+
(xml_response/'content_type').wont_be_empty
|
179
|
+
(xml_response/'content_type').size.must_equal 1
|
180
|
+
(xml_response/'content_type').first.text.wont_be_empty
|
181
|
+
(xml_response/'last_modified').wont_be_empty
|
182
|
+
(xml_response/'last_modified').size.must_equal 1
|
183
|
+
(xml_response/'last_modified').first.text.wont_be_empty
|
184
|
+
(xml_response/'content').wont_be_empty
|
185
|
+
(xml_response/'content').size.must_equal 1
|
186
|
+
(xml_response/'content').first[:rel].wont_be_nil
|
187
|
+
(xml_response/'content').first[:rel].must_equal 'blob_content'
|
188
|
+
(xml_response/'content').first[:href].wont_be_nil
|
189
|
+
(xml_response/'content').first[:href].must_match /^http/
|
190
|
+
(xml_response/'content').first[:href].must_match /\/content$/
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
2
|
+
require 'tests/drivers/mock/common'
|
3
|
+
|
4
|
+
describe 'Deltacloud API drivers' do
|
5
|
+
include Deltacloud::Test
|
6
|
+
|
7
|
+
it 'must advertise have the drivers collection in API entrypoint' do
|
8
|
+
get root_url
|
9
|
+
(xml_response/'api/link[@rel=drivers]').wont_be_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'must not require authentication to access the "driver" collection' do
|
13
|
+
get collection_url(:drivers)
|
14
|
+
last_response.status.must_equal 200
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should respond with HTTP_OK when accessing the :drivers collection with authentication' do
|
18
|
+
get collection_url(:drivers)
|
19
|
+
last_response.status.must_equal 200
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should support the JSON media type' do
|
23
|
+
header 'Accept', 'application/json'
|
24
|
+
get collection_url(:drivers)
|
25
|
+
last_response.status.must_equal 200
|
26
|
+
last_response.headers['Content-Type'].must_equal 'application/json'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'must include the ETag in HTTP headers' do
|
30
|
+
get collection_url(:drivers)
|
31
|
+
last_response.headers['ETag'].wont_be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'must have the "drivers" element on top level' do
|
35
|
+
get collection_url(:drivers)
|
36
|
+
xml_response.root.name.must_equal 'drivers'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'must have some "driver" elements inside "drivers"' do
|
40
|
+
get collection_url(:drivers)
|
41
|
+
(xml_response/'drivers/driver').wont_be_empty
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'must provide the :id attribute for each driver in collection' do
|
45
|
+
get collection_url(:drivers)
|
46
|
+
(xml_response/'drivers/driver').each do |r|
|
47
|
+
r[:id].wont_be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'must include the :href attribute for each "driver" element in collection' do
|
52
|
+
get collection_url(:drivers)
|
53
|
+
(xml_response/'drivers/driver').each do |r|
|
54
|
+
r[:href].wont_be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'must use the absolute URL in each :href attribute' do
|
59
|
+
get collection_url(:drivers)
|
60
|
+
(xml_response/'drivers/driver').each do |r|
|
61
|
+
r[:href].must_match /^http/
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'must have the URL ending with the :id of the driver' do
|
66
|
+
get collection_url(:drivers)
|
67
|
+
(xml_response/'drivers/driver').each do |r|
|
68
|
+
r[:href].must_match /#{r[:id]}$/
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'must return the list of valid parameters for the :index action' do
|
73
|
+
options collection_url(:drivers) + '/index'
|
74
|
+
last_response.headers['Allow'].wont_be_nil
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'must have the "name" element defined for each driver in collection' do
|
78
|
+
get collection_url(:drivers)
|
79
|
+
(xml_response/'drivers/driver').each do |r|
|
80
|
+
(r/'name').wont_be_nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
it 'must return the full "driver" when following the URL in driver element' do
|
86
|
+
get collection_url(:drivers)
|
87
|
+
(xml_response/'drivers/driver').each do |r|
|
88
|
+
get collection_url(:drivers) + '/' + r[:id]
|
89
|
+
last_response.status.must_equal 200
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'must have the "name" element for the driver and it should match with the one in collection' do
|
94
|
+
get collection_url(:drivers)
|
95
|
+
(xml_response/'drivers/driver').each do |r|
|
96
|
+
get collection_url(:drivers) + '/' + r[:id]
|
97
|
+
(xml_response/'name').wont_be_empty
|
98
|
+
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should advertise available providers for some drivers' do
|
103
|
+
get collection_url(:drivers)
|
104
|
+
(xml_response/'drivers/driver/provider').each do |p|
|
105
|
+
p[:id].wont_be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should expose entrypoints for each provider if driver has providers defined' do
|
110
|
+
get collection_url(:drivers)
|
111
|
+
(xml_response/'drivers/driver/provider').each do |p|
|
112
|
+
get collection_url(:drivers) + '/' + p.parent[:id]
|
113
|
+
(xml_response/"driver/provider[@id=#{p[:id]}]").wont_be_empty
|
114
|
+
(xml_response/"driver/provider[@id=#{p[:id]}]").size.must_equal 1
|
115
|
+
(xml_response/"driver/provider[@id=#{p[:id]}]/entrypoint").wont_be_empty
|
116
|
+
(xml_response/"driver/provider[@id=#{p[:id]}]/entrypoint").each do |e|
|
117
|
+
e[:kind].wont_be_nil
|
118
|
+
e.text.wont_be_empty
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -1,134 +1,224 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with
|
3
|
-
# this work for additional information regarding copyright ownership. The
|
4
|
-
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the
|
6
|
-
# License. You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations
|
14
|
-
# under the License.
|
15
|
-
#
|
16
|
-
|
17
1
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
|
18
|
-
require 'tests/common'
|
2
|
+
require 'tests/drivers/mock/common'
|
19
3
|
|
20
|
-
|
21
|
-
|
22
|
-
include Rack::Test::Methods
|
4
|
+
describe 'Deltacloud API Hardware Profiles' do
|
5
|
+
include Deltacloud::Test
|
23
6
|
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
it 'must advertise have the hardware_profiles collection in API entrypoint' do
|
8
|
+
get root_url
|
9
|
+
(xml_response/'api/link[@rel=hardware_profiles]').wont_be_empty
|
10
|
+
end
|
27
11
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
it 'should respond with HTTP_OK when accessing the :hardware_profiles collection with authentication' do
|
13
|
+
authenticate
|
14
|
+
get collection_url(:hardware_profiles)
|
15
|
+
last_response.status.must_equal 200
|
16
|
+
end
|
32
17
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
it 'should support the JSON media type' do
|
19
|
+
authenticate
|
20
|
+
header 'Accept', 'application/json'
|
21
|
+
get collection_url(:hardware_profiles)
|
22
|
+
last_response.status.must_equal 200
|
23
|
+
last_response.headers['Content-Type'].must_equal 'application/json'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'must include the ETag in HTTP headers' do
|
27
|
+
authenticate
|
28
|
+
get collection_url(:hardware_profiles)
|
29
|
+
last_response.headers['ETag'].wont_be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'must have the "hardware_profiles" element on top level' do
|
33
|
+
authenticate
|
34
|
+
get collection_url(:hardware_profiles)
|
35
|
+
xml_response.root.name.must_equal 'hardware_profiles'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'must have some "hardware_profile" elements inside "hardware_profiles"' do
|
39
|
+
authenticate
|
40
|
+
get collection_url(:hardware_profiles)
|
41
|
+
(xml_response/'hardware_profiles/hardware_profile').wont_be_empty
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'must provide the :id attribute for each hardware_profile in collection' do
|
45
|
+
authenticate
|
46
|
+
get collection_url(:hardware_profiles)
|
47
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
48
|
+
r[:id].wont_be_nil
|
38
49
|
end
|
50
|
+
end
|
39
51
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
it 'must include the :href attribute for each "hardware_profile" element in collection' do
|
53
|
+
authenticate
|
54
|
+
get collection_url(:hardware_profiles)
|
55
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
56
|
+
r[:href].wont_be_nil
|
45
57
|
end
|
58
|
+
end
|
46
59
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
names.should == names.uniq
|
60
|
+
it 'must use the absolute URL in each :href attribute' do
|
61
|
+
authenticate
|
62
|
+
get collection_url(:hardware_profiles)
|
63
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
64
|
+
r[:href].must_match /^http/
|
54
65
|
end
|
66
|
+
end
|
55
67
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
ids.should == ids.uniq
|
68
|
+
it 'must have the URL ending with the :id of the hardware_profile' do
|
69
|
+
authenticate
|
70
|
+
get collection_url(:hardware_profiles)
|
71
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
72
|
+
r[:href].must_match /#{r[:id]}$/
|
63
73
|
end
|
74
|
+
end
|
64
75
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
76
|
+
it 'must return the list of valid parameters for the :index action' do
|
77
|
+
authenticate
|
78
|
+
options collection_url(:hardware_profiles) + '/index'
|
79
|
+
last_response.headers['Allow'].wont_be_nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'must have the "name" element defined for each hardware_profile in collection' do
|
83
|
+
authenticate
|
84
|
+
get collection_url(:hardware_profiles)
|
85
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
86
|
+
(r/'name').wont_be_empty
|
69
87
|
end
|
88
|
+
end
|
70
89
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
90
|
+
it 'should have the "property" element defined if not the opaque hardware_profile' do
|
91
|
+
authenticate
|
92
|
+
get collection_url(:hardware_profiles)
|
93
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
94
|
+
next if r[:id] == 'opaque'
|
95
|
+
(r/'property').wont_be_empty
|
75
96
|
end
|
97
|
+
end
|
76
98
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
JSON::parse(last_response.body).class.should == Hash
|
84
|
-
JSON::parse(last_response.body)['hardware_profile'].class.should == Hash
|
99
|
+
it 'must define the :kind attribute for each "property" ' do
|
100
|
+
authenticate
|
101
|
+
get collection_url(:hardware_profiles)
|
102
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
103
|
+
next if r[:id] == 'opaque'
|
104
|
+
(r/'property').each { |p| p[:kind].wont_be_nil }
|
85
105
|
end
|
106
|
+
end
|
86
107
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
|
108
|
+
it 'must define the :name attribute for each "property" ' do
|
109
|
+
authenticate
|
110
|
+
get collection_url(:hardware_profiles)
|
111
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
112
|
+
next if r[:id] == 'opaque'
|
113
|
+
(r/'property').each { |p| p[:name].wont_be_nil }
|
94
114
|
end
|
115
|
+
end
|
95
116
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
last_response.status.should == 404
|
117
|
+
it 'must define the :unit attribute for each "property" ' do
|
118
|
+
authenticate
|
119
|
+
get collection_url(:hardware_profiles)
|
120
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
121
|
+
next if r[:id] == 'opaque'
|
122
|
+
(r/'property').each { |p| p[:unit].wont_be_nil }
|
103
123
|
end
|
124
|
+
end
|
104
125
|
|
105
|
-
|
126
|
+
it 'must define the :value attribute for each "property" ' do
|
127
|
+
authenticate
|
128
|
+
get collection_url(:hardware_profiles)
|
129
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
130
|
+
next if r[:id] == 'opaque'
|
131
|
+
(r/'property').each { |p| p[:value].wont_be_nil }
|
132
|
+
end
|
133
|
+
end
|
106
134
|
|
107
|
-
|
108
|
-
|
109
|
-
|
135
|
+
it 'must define the "param" element if property kind is not "fixed"' do
|
136
|
+
authenticate
|
137
|
+
get collection_url(:hardware_profiles)
|
138
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
139
|
+
next if r[:id] == 'opaque'
|
140
|
+
(r/'property').each do |p|
|
141
|
+
next if p[:kind] == 'fixed'
|
142
|
+
(p/'param').wont_be_empty
|
143
|
+
(p/'param').size.must_equal 1
|
144
|
+
(p/'param').first[:href].wont_be_nil
|
145
|
+
(p/'param').first[:href].must_match /^http/
|
146
|
+
(p/'param').first[:method].wont_be_nil
|
147
|
+
(p/'param').first[:name].wont_be_nil
|
148
|
+
(p/'param').first[:operation].wont_be_nil
|
110
149
|
end
|
150
|
+
end
|
151
|
+
end
|
111
152
|
|
112
|
-
|
113
|
-
|
153
|
+
it 'must provide the list of valid values when the property is defined as "enum"' do
|
154
|
+
authenticate
|
155
|
+
get collection_url(:hardware_profiles)
|
156
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
157
|
+
next if r[:id] == 'opaque'
|
158
|
+
(r/'property').each do |p|
|
159
|
+
next if p[:kind] != 'enum'
|
160
|
+
(p/'enum/entry').wont_be_empty
|
161
|
+
(p/'enum/entry').each { |e| e[:value].wont_be_nil }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
114
165
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
166
|
+
it 'must provide the range of valid values when the property is defined as "range"' do
|
167
|
+
authenticate
|
168
|
+
get collection_url(:hardware_profiles)
|
169
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
170
|
+
next if r[:id] == 'opaque'
|
171
|
+
(r/'property').each do |p|
|
172
|
+
next if p[:kind] != 'range'
|
173
|
+
(p/'range').wont_be_empty
|
174
|
+
(p/'range').size.must_equal 1
|
175
|
+
(p/'range').first[:first].wont_be_nil
|
176
|
+
(p/'range').first[:last].wont_be_nil
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
119
180
|
|
120
|
-
|
121
|
-
|
181
|
+
it 'must provide the default value within the range if property defined as "range"' do
|
182
|
+
authenticate
|
183
|
+
get collection_url(:hardware_profiles)
|
184
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
185
|
+
next if r[:id] == 'opaque'
|
186
|
+
(r/'property').each do |p|
|
187
|
+
next if p[:kind] != 'range'
|
188
|
+
((p/'range').first[:first].to_i..(p/'range').first[:last].to_i).include?(p[:value].to_i).must_equal true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
122
192
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
193
|
+
it 'must provide the default value that is included in enum list if property defined as "enum"' do
|
194
|
+
authenticate
|
195
|
+
get collection_url(:hardware_profiles)
|
196
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
197
|
+
next if r[:id] == 'opaque'
|
198
|
+
(r/'property').each do |p|
|
199
|
+
next if p[:kind] != 'enum'
|
200
|
+
(p/'enum/entry').map { |e| e[:value] }.include?(p[:value]).must_equal true
|
130
201
|
end
|
131
202
|
end
|
203
|
+
end
|
132
204
|
|
205
|
+
it 'must return the full "hardware_profile" when following the URL in hardware_profile element' do
|
206
|
+
authenticate
|
207
|
+
get collection_url(:hardware_profiles)
|
208
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
209
|
+
get collection_url(:hardware_profiles) + '/' + r[:id]
|
210
|
+
last_response.status.must_equal 200
|
211
|
+
end
|
133
212
|
end
|
213
|
+
|
214
|
+
it 'must have the "name" element for the hardware_profile and it should match with the one in collection' do
|
215
|
+
authenticate
|
216
|
+
get collection_url(:hardware_profiles)
|
217
|
+
(xml_response/'hardware_profiles/hardware_profile').each do |r|
|
218
|
+
get collection_url(:hardware_profiles) + '/' + r[:id]
|
219
|
+
(xml_response/'name').wont_be_empty
|
220
|
+
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
134
224
|
end
|