deltacloud-core 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +99 -141
- data/bin/deltacloudd +4 -1
- data/config.ru +13 -6
- data/config/drivers/aruba.yaml +8 -0
- data/config/drivers/fgcp.yaml +3 -2
- data/deltacloud-core.gemspec +13 -9
- data/lib/cimi/collections/cloud_entry_point.rb +1 -1
- data/lib/cimi/models.rb +1 -7
- data/lib/cimi/models/base.rb +1 -4
- data/lib/cimi/models/cloud_entry_point.rb +14 -0
- data/lib/cimi/models/machine.rb +4 -4
- data/lib/cimi/models/machine_admin.rb +1 -0
- data/lib/cimi/models/machine_configuration.rb +4 -4
- data/lib/cimi/models/schema.rb +17 -14
- data/lib/cimi/models/volume_image.rb +1 -1
- data/lib/cimi/server.rb +1 -1
- data/lib/deltacloud/api.rb +55 -3
- data/lib/deltacloud/collections/addresses.rb +1 -1
- data/lib/deltacloud/collections/buckets.rb +12 -10
- data/lib/deltacloud/collections/firewalls.rb +2 -1
- data/lib/deltacloud/collections/hardware_profiles.rb +1 -1
- data/lib/deltacloud/collections/images.rb +2 -2
- data/lib/deltacloud/collections/instance_states.rb +6 -3
- data/lib/deltacloud/collections/instances.rb +2 -1
- data/lib/deltacloud/collections/keys.rb +6 -2
- data/lib/deltacloud/collections/load_balancers.rb +8 -7
- data/lib/deltacloud/collections/metrics.rb +2 -1
- data/lib/deltacloud/collections/realms.rb +1 -1
- data/lib/deltacloud/collections/storage_snapshots.rb +2 -1
- data/lib/deltacloud/collections/storage_volumes.rb +2 -2
- data/lib/deltacloud/core_ext.rb +1 -7
- data/lib/deltacloud/core_ext/hash.rb +7 -5
- data/lib/deltacloud/core_ext/string.rb +1 -0
- data/lib/deltacloud/drivers/aruba/aruba_driver.rb +469 -0
- data/lib/deltacloud/drivers/base_driver.rb +12 -17
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +50 -22
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
- data/lib/deltacloud/drivers/exceptions.rb +12 -2
- data/lib/deltacloud/drivers/features.rb +8 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +21 -6
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +169 -57
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +101 -13
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +12 -6
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +10 -18
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +46 -1
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +17 -17
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +4 -4
- data/lib/deltacloud/helpers.rb +4 -4
- data/lib/deltacloud/helpers/blob_stream_helper.rb +4 -6
- data/lib/deltacloud/helpers/deltacloud_helper.rb +17 -1
- data/lib/deltacloud/helpers/driver_helper.rb +7 -3
- data/lib/deltacloud/helpers/url_helper.rb +4 -4
- data/lib/deltacloud/models/address.rb +1 -1
- data/lib/deltacloud/models/base_model.rb +0 -14
- data/lib/deltacloud/models/bucket.rb +0 -10
- data/lib/deltacloud/models/hardware_profile.rb +5 -26
- data/lib/deltacloud/models/image.rb +0 -12
- data/lib/deltacloud/models/instance.rb +6 -22
- data/lib/deltacloud/models/key.rb +2 -2
- data/lib/deltacloud/models/metric.rb +1 -1
- data/lib/deltacloud/models/storage_snapshot.rb +4 -0
- data/lib/deltacloud/server.rb +8 -2
- data/lib/deltacloud_rack.rb +40 -10
- data/lib/ec2/query_parser.rb +9 -4
- data/lib/ec2/server.rb +1 -1
- data/lib/ec2/views/create_key_pair.haml +3 -0
- data/lib/ec2/views/delete_key_pair.haml +1 -0
- data/lib/ec2/views/describe_availability_zones.haml +6 -0
- data/lib/ec2/views/describe_images.haml +10 -0
- data/lib/ec2/views/describe_instance_set.haml +24 -0
- data/lib/ec2/views/describe_instances.haml +9 -0
- data/lib/ec2/views/describe_key_pairs.haml +5 -0
- data/lib/ec2/views/error.haml +4 -0
- data/lib/ec2/views/instance_action.haml +9 -0
- data/lib/ec2/views/reboot_instances.haml +1 -0
- data/lib/ec2/views/run_instances.haml +7 -0
- data/lib/ec2/views/start_instances.haml +1 -0
- data/lib/ec2/views/stop_instances.haml +1 -0
- data/lib/ec2/views/terminate_instances.haml +9 -0
- data/lib/sinatra.rb +0 -1
- data/lib/sinatra/rack_accept.rb +1 -1
- data/lib/sinatra/rack_driver_select.rb +2 -2
- data/lib/sinatra/rack_etag.rb +5 -1
- data/lib/sinatra/rack_logger.rb +127 -0
- data/lib/sinatra/rack_matrix_params.rb +1 -1
- data/tests/cimi/collections/cloud_entry_point_test.rb +46 -0
- data/tests/cimi/collections/common.rb +17 -0
- data/tests/cimi/collections/machine_images_test.rb +44 -0
- data/tests/cimi/collections/machines_test.rb +41 -0
- data/tests/cimi/spec/cimi/model/machine_admin_spec.rb +35 -0
- data/tests/cimi/spec/cimi/model/machine_configuration_spec.rb +31 -0
- data/tests/cimi/spec/cimi/model/machine_image_spec.rb +33 -0
- data/tests/cimi/spec/cimi/model/machine_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/machine_template_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/schema_spec.rb +245 -0
- data/tests/cimi/spec/cimi/model/volume_configuration_spec.rb +34 -0
- data/tests/cimi/spec/cimi/model/volume_image_spec.rb +33 -0
- data/tests/cimi/spec/cimi/model/volume_spec.rb +32 -0
- data/tests/cimi/spec/cimi/model/volume_template_spec.rb +32 -0
- data/tests/cimi/spec/spec_helper.rb +136 -0
- data/tests/deltacloud/base_collection_test.rb +30 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +65 -0
- data/tests/deltacloud/collections/drivers_collection_test.rb +37 -0
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +53 -0
- data/tests/deltacloud/collections/images_collection_test.rb +59 -0
- data/tests/deltacloud/collections/instance_states_collection_test.rb +34 -0
- data/tests/deltacloud/collections/instances_collection_test.rb +63 -0
- data/tests/deltacloud/collections/keys_collection_test.rb +63 -0
- data/tests/deltacloud/collections_test.rb +35 -0
- data/tests/deltacloud/common.rb +14 -0
- data/tests/deltacloud/deltacloud_helper_test.rb +55 -0
- data/tests/deltacloud/drivers_test.rb +73 -0
- data/tests/deltacloud/rack_test.rb +51 -0
- data/tests/deltacloud/server_test.rb +149 -0
- data/tests/{api → deprecated/api}/common.rb +0 -0
- data/tests/{api → deprecated/api}/driver_test.rb +0 -0
- data/tests/deprecated/api/library_test.rb +6 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/common_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/machines_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/step_definitions/volumes_steps.rb +0 -0
- data/tests/{cimi → deprecated/cimi}/features/support/env.rb +0 -0
- data/tests/{common.rb → deprecated/common.rb} +0 -0
- data/tests/{core_ext → deprecated/core_ext}/string.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/ec2/api_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/common.rb +23 -0
- data/tests/{drivers → deprecated/drivers}/ec2/drivers_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/ec2/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/images_test.rb +230 -0
- data/tests/{drivers → deprecated/drivers}/ec2/instances_test.rb +0 -0
- data/tests/deprecated/drivers/ec2/keys_test.rb +181 -0
- data/tests/deprecated/drivers/ec2/realms_test.rb +146 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/fgcp/setup.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/google/common.rb +2 -2
- data/tests/{drivers → deprecated/drivers}/mock/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/drivers_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/mock/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/mock/images_test.rb +197 -0
- data/tests/deprecated/drivers/mock/instances_test.rb +343 -0
- data/tests/deprecated/drivers/mock/keys_test.rb +161 -0
- data/tests/deprecated/drivers/mock/realms_test.rb +132 -0
- data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/deprecated/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/{drivers → deprecated/drivers}/openstack/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/images_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/instances_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/openstack/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/api_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/buckets_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/common.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/hardware_profiles_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/images_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/instances_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rackspace/realms_test.rb +0 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/api_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/common.rb +21 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/hardware_profiles_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/images_test.rb +48 -0
- data/tests/{drivers → deprecated/drivers}/rhevm/instances_test.rb +0 -0
- data/tests/deprecated/drivers/rhevm/realms_test.rb +40 -0
- data/tests/{minitest_common.rb → deprecated/minitest_common.rb} +0 -0
- data/tests/{minitest_common_api_test.rb → deprecated/minitest_common_api_test.rb} +0 -0
- data/tests/{rabbit_test.rb → deprecated/rabbit_test.rb} +0 -0
- data/tests/drivers/base/base_driver_test.rb +124 -0
- data/tests/{api → drivers/base}/library_test.rb +2 -8
- data/tests/drivers/ec2/common.rb +23 -15
- data/tests/drivers/ec2/images_test.rb +30 -211
- data/tests/drivers/ec2/instance_test.rb +104 -0
- data/tests/drivers/ec2/keys_test.rb +32 -161
- data/tests/drivers/ec2/realms_test.rb +26 -128
- data/tests/drivers/ec2/storage_snapshots_test.rb +54 -0
- data/tests/drivers/mock/images_test.rb +37 -179
- data/tests/drivers/mock/instances_test.rb +103 -340
- data/tests/drivers/mock/keys_test.rb +30 -145
- data/tests/drivers/mock/realms_test.rb +23 -118
- data/tests/drivers/mock/storage_snapshots_test.rb +23 -100
- data/tests/drivers/mock/storage_volumes_test.rb +41 -104
- data/tests/drivers/models/address_test.rb +18 -0
- data/tests/drivers/models/base_test.rb +33 -0
- data/tests/drivers/models/blob_test.rb +18 -0
- data/tests/drivers/models/hardware_profile_test.rb +52 -0
- data/tests/drivers/models/instance_address_test.rb +24 -0
- data/tests/drivers/models/instance_profile_test.rb +21 -0
- data/tests/drivers/models/instance_test.rb +29 -0
- data/tests/drivers/models/keys_test.rb +25 -0
- data/tests/drivers/models/metrics_test.rb +20 -0
- data/tests/drivers/rhevm/common.rb +15 -15
- data/tests/drivers/rhevm/images_test.rb +61 -36
- data/tests/drivers/rhevm/instance_test.rb +104 -0
- data/tests/drivers/rhevm/provider_test.rb +48 -0
- data/tests/drivers/rhevm/realms_test.rb +40 -37
- data/tests/ec2/common.rb +24 -0
- data/tests/ec2/query_parser_test.rb +98 -0
- data/tests/ec2/server_test.rb +45 -0
- data/tests/helpers/core_ext/array_test.rb +24 -0
- data/tests/helpers/core_ext/hash_test.rb +42 -0
- data/tests/helpers/core_ext/integer_test.rb +19 -0
- data/tests/helpers/core_ext/string_test.rb +74 -0
- data/tests/test_helper.rb +66 -0
- data/views/api/show.html.haml +1 -2
- data/views/api/show.xml.haml +1 -2
- data/views/blobs/show.xml.haml +1 -2
- data/views/keys/new.html.haml +9 -2
- data/views/load_balancers/new.html.haml +35 -34
- data/views/metrics/index.html.haml +1 -1
- data/views/metrics/show.html.haml +2 -2
- data/views/metrics/show.xml.haml +6 -2
- data/views/storage_volumes/attach.html.haml +1 -1
- data/views/storage_volumes/show.html.haml +1 -1
- metadata +853 -544
- data/lib/sinatra/accept_media_types.rb +0 -154
@@ -1,161 +1,46 @@
|
|
1
|
-
|
2
|
-
require 'tests/drivers/mock/common'
|
1
|
+
require 'minitest/autorun'
|
3
2
|
|
4
|
-
|
5
|
-
include Deltacloud::Test
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
|
6
4
|
|
7
|
-
|
8
|
-
get root_url
|
9
|
-
(xml_response/'api/link[@rel=keys]').wont_be_empty
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must require authentication to access the "key" collection' do
|
13
|
-
get collection_url(:keys)
|
14
|
-
last_response.status.must_equal 401
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should respond with HTTP_OK when accessing the :keys collection with authentication' do
|
18
|
-
authenticate
|
19
|
-
get collection_url(:keys)
|
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(:keys)
|
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(:keys)
|
34
|
-
last_response.headers['ETag'].wont_be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'must have the "keys" element on top level' do
|
38
|
-
authenticate
|
39
|
-
get collection_url(:keys)
|
40
|
-
xml_response.root.name.must_equal 'keys'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'must have some "key" elements inside "keys"' do
|
44
|
-
authenticate
|
45
|
-
get collection_url(:keys)
|
46
|
-
(xml_response/'keys/key').wont_be_empty
|
47
|
-
end
|
5
|
+
describe 'MockDriver Keys' do
|
48
6
|
|
49
|
-
|
50
|
-
|
51
|
-
get collection_url(:keys)
|
52
|
-
(xml_response/'keys/key').each do |k|
|
53
|
-
k[:type].must_match /(key|password)/
|
54
|
-
end
|
7
|
+
before do
|
8
|
+
@driver = Deltacloud::new(:mock, :user => 'mockuser', :password => 'mockpassword')
|
55
9
|
end
|
56
10
|
|
57
|
-
it 'must
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
r[:id].wont_be_nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'must include the :href attribute for each "key" element in collection' do
|
66
|
-
authenticate
|
67
|
-
get collection_url(:keys)
|
68
|
-
(xml_response/'keys/key').each do |r|
|
69
|
-
r[:href].wont_be_nil
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'must use the absolute URL in each :href attribute' do
|
74
|
-
authenticate
|
75
|
-
get collection_url(:keys)
|
76
|
-
(xml_response/'keys/key').each do |r|
|
77
|
-
r[:href].must_match /^http/
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'must have the URL ending with the :id of the key' do
|
82
|
-
authenticate
|
83
|
-
get collection_url(:keys)
|
84
|
-
(xml_response/'keys/key').each do |r|
|
85
|
-
r[:href].must_match /#{r[:id]}$/
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'must return the list of valid parameters for the :index action' do
|
90
|
-
authenticate
|
91
|
-
options collection_url(:keys) + '/index'
|
92
|
-
last_response.headers['Allow'].wont_be_nil
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'must have the "name" element defined for each key in collection' do
|
96
|
-
authenticate
|
97
|
-
get collection_url(:keys)
|
98
|
-
(xml_response/'keys/key').each do |r|
|
99
|
-
(r/'name').wont_be_empty
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
it 'must return the full "key" when following the URL in key element' do
|
105
|
-
authenticate
|
106
|
-
get collection_url(:keys)
|
107
|
-
(xml_response/'keys/key').each do |r|
|
108
|
-
get collection_url(:keys) + '/' + r[:id]
|
109
|
-
last_response.status.must_equal 200
|
110
|
-
end
|
11
|
+
it 'must throw error when wrong credentials' do
|
12
|
+
Proc.new do
|
13
|
+
@driver.backend.keys(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
14
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
111
15
|
end
|
112
16
|
|
113
|
-
it 'must
|
114
|
-
|
115
|
-
|
116
|
-
(xml_response/'keys/key').each do |r|
|
117
|
-
get collection_url(:keys) + '/' + r[:id]
|
118
|
-
(xml_response/'name').wont_be_empty
|
119
|
-
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
120
|
-
end
|
17
|
+
it 'must return list of keys' do
|
18
|
+
@driver.keys.wont_be_empty
|
19
|
+
@driver.keys.first.must_be_kind_of Key
|
121
20
|
end
|
122
21
|
|
123
|
-
it 'must
|
124
|
-
|
125
|
-
|
126
|
-
(
|
127
|
-
|
128
|
-
|
129
|
-
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
130
|
-
end
|
22
|
+
it 'must allow to filter keys' do
|
23
|
+
@driver.keys(:id => 'test-key').wont_be_empty
|
24
|
+
@driver.keys(:id => 'test-key').must_be_kind_of Array
|
25
|
+
@driver.keys(:id => 'test-key').size.must_equal 1
|
26
|
+
@driver.keys(:id => 'test-key').first.id.must_equal 'test-key'
|
27
|
+
@driver.keys(:id => 'unknown').must_be_empty
|
131
28
|
end
|
132
29
|
|
133
|
-
it '
|
134
|
-
|
135
|
-
|
136
|
-
(
|
137
|
-
|
138
|
-
(xml_response/'actions/link').wont_be_empty
|
139
|
-
(xml_response/'actions/link').each do |l|
|
140
|
-
l[:href].wont_be_nil
|
141
|
-
l[:href].must_match /^http/
|
142
|
-
l[:method].wont_be_nil
|
143
|
-
l[:rel].wont_be_nil
|
144
|
-
end
|
145
|
-
end
|
30
|
+
it 'must allow to retrieve single key' do
|
31
|
+
@driver.key(:id => 'test-key').wont_be_nil
|
32
|
+
@driver.key(:id => 'test-key').must_be_kind_of Key
|
33
|
+
@driver.key(:id => 'test-key').id.must_equal 'test-key'
|
34
|
+
@driver.key(:id => 'unknown').must_be_nil
|
146
35
|
end
|
147
36
|
|
148
|
-
it '
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
get collection_url(:keys) + '/' + 'test_key_'+key_name
|
156
|
-
last_response.status.must_equal 200 # HTTP_OK
|
157
|
-
delete collection_url(:keys) + '/' + 'test_key_'+key_name
|
158
|
-
last_response.status.must_equal 204 # HTTP_NO_CONTENT
|
37
|
+
it 'must allow to create a new key' do
|
38
|
+
key = @driver.create_key(:key_name => 'test1')
|
39
|
+
key.wont_be_nil
|
40
|
+
key.must_be_kind_of Key
|
41
|
+
Proc.new { @driver.create_key(:key_name => 'test1') }.must_raise Deltacloud::ExceptionHandler::ForbiddenError, 'KeyExist'
|
42
|
+
@driver.destroy_key :id => key.id
|
43
|
+
@driver.key(:id => key.id).must_be_nil
|
159
44
|
end
|
160
45
|
|
161
46
|
end
|
@@ -1,132 +1,37 @@
|
|
1
|
-
|
2
|
-
require 'tests/drivers/mock/common'
|
1
|
+
require 'minitest/autorun'
|
3
2
|
|
4
|
-
|
5
|
-
include Deltacloud::Test
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
|
6
4
|
|
7
|
-
|
8
|
-
get root_url
|
9
|
-
(xml_response/'api/link[@rel=realms]').wont_be_empty
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must require authentication to access the "realm" collection' do
|
13
|
-
get collection_url(:realms)
|
14
|
-
last_response.status.must_equal 401
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should respond with HTTP_OK when accessing the :realms collection with authentication' do
|
18
|
-
authenticate
|
19
|
-
get collection_url(:realms)
|
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(:realms)
|
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(:realms)
|
34
|
-
last_response.headers['ETag'].wont_be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'must have the "realms" element on top level' do
|
38
|
-
authenticate
|
39
|
-
get collection_url(:realms)
|
40
|
-
xml_response.root.name.must_equal 'realms'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'must have some "realm" elements inside "realms"' do
|
44
|
-
authenticate
|
45
|
-
get collection_url(:realms)
|
46
|
-
(xml_response/'realms/realm').wont_be_empty
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'must provide the :id attribute for each realm in collection' do
|
50
|
-
authenticate
|
51
|
-
get collection_url(:realms)
|
52
|
-
(xml_response/'realms/realm').each do |r|
|
53
|
-
r[:id].wont_be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'must include the :href attribute for each "realm" element in collection' do
|
58
|
-
authenticate
|
59
|
-
get collection_url(:realms)
|
60
|
-
(xml_response/'realms/realm').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(:realms)
|
68
|
-
(xml_response/'realms/realm').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 realm' do
|
74
|
-
authenticate
|
75
|
-
get collection_url(:realms)
|
76
|
-
(xml_response/'realms/realm').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(:realms) + '/index'
|
84
|
-
last_response.headers['Allow'].wont_be_nil
|
85
|
-
end
|
5
|
+
describe 'MockDriver Realms' do
|
86
6
|
|
87
|
-
|
88
|
-
|
89
|
-
get collection_url(:realms)
|
90
|
-
(xml_response/'realms/realm').each do |r|
|
91
|
-
(r/'name').wont_be_empty
|
92
|
-
end
|
7
|
+
before do
|
8
|
+
@driver = Deltacloud::new(:mock, :user => 'mockuser', :password => 'mockpassword')
|
93
9
|
end
|
94
10
|
|
95
|
-
it 'must
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
(r/'state').wont_be_empty
|
100
|
-
end
|
11
|
+
it 'must throw error when wrong credentials' do
|
12
|
+
Proc.new do
|
13
|
+
@driver.backend.realms(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
14
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
101
15
|
end
|
102
16
|
|
103
|
-
it 'must return
|
104
|
-
|
105
|
-
|
106
|
-
(xml_response/'realms/realm').each do |r|
|
107
|
-
get collection_url(:realms) + '/' + r[:id]
|
108
|
-
last_response.status.must_equal 200
|
109
|
-
end
|
17
|
+
it 'must return list of realms' do
|
18
|
+
@driver.realms.wont_be_empty
|
19
|
+
@driver.realms.first.must_be_kind_of Realm
|
110
20
|
end
|
111
21
|
|
112
|
-
it 'must
|
113
|
-
|
114
|
-
|
115
|
-
(
|
116
|
-
|
117
|
-
|
118
|
-
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
119
|
-
end
|
22
|
+
it 'must allow to filter realms' do
|
23
|
+
@driver.realms(:id => 'us').wont_be_empty
|
24
|
+
@driver.realms(:id => 'us').must_be_kind_of Array
|
25
|
+
@driver.realms(:id => 'us').size.must_equal 1
|
26
|
+
@driver.realms(:id => 'us').first.id.must_equal 'us'
|
27
|
+
@driver.realms(:id => 'unknown').must_be_empty
|
120
28
|
end
|
121
29
|
|
122
|
-
it 'must
|
123
|
-
|
124
|
-
|
125
|
-
(
|
126
|
-
|
127
|
-
(xml_response/'state').wont_be_empty
|
128
|
-
(xml_response/'state').first.text.must_equal((r/'state').first.text)
|
129
|
-
end
|
30
|
+
it 'must allow to retrieve single realm' do
|
31
|
+
@driver.realm(:id => 'us').wont_be_nil
|
32
|
+
@driver.realm(:id => 'us').must_be_kind_of Realm
|
33
|
+
@driver.realm(:id => 'us').id.must_equal 'us'
|
34
|
+
@driver.realm(:id => 'unknown').must_be_nil
|
130
35
|
end
|
131
36
|
|
132
37
|
end
|
@@ -1,114 +1,37 @@
|
|
1
|
-
|
2
|
-
require 'tests/drivers/mock/common'
|
1
|
+
require 'minitest/autorun'
|
3
2
|
|
4
|
-
|
5
|
-
include Deltacloud::Test
|
3
|
+
require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
|
6
4
|
|
7
|
-
|
8
|
-
get root_url
|
9
|
-
(xml_response/'api/link[@rel=storage_snapshots]').wont_be_empty
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'must require authentication to access the "storage_snapshot" collection' do
|
13
|
-
get collection_url(:storage_snapshots)
|
14
|
-
last_response.status.must_equal 401
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should respond with HTTP_OK when accessing the :storage_snapshots collection with authentication' do
|
18
|
-
authenticate
|
19
|
-
get collection_url(:storage_snapshots)
|
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(:storage_snapshots)
|
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(:storage_snapshots)
|
34
|
-
last_response.headers['ETag'].wont_be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'must have the "storage_snapshots" element on top level' do
|
38
|
-
authenticate
|
39
|
-
get collection_url(:storage_snapshots)
|
40
|
-
xml_response.root.name.must_equal 'storage_snapshots'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'must have some "storage_snapshot" elements inside "storage_snapshots"' do
|
44
|
-
authenticate
|
45
|
-
get collection_url(:storage_snapshots)
|
46
|
-
(xml_response/'storage_snapshots/storage_snapshot').wont_be_empty
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'must provide the :id attribute for each storage_snapshot in collection' do
|
50
|
-
authenticate
|
51
|
-
get collection_url(:storage_snapshots)
|
52
|
-
(xml_response/'storage_snapshots/storage_snapshot').each do |r|
|
53
|
-
r[:id].wont_be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'must include the :href attribute for each "storage_snapshot" element in collection' do
|
58
|
-
authenticate
|
59
|
-
get collection_url(:storage_snapshots)
|
60
|
-
(xml_response/'storage_snapshots/storage_snapshot').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(:storage_snapshots)
|
68
|
-
(xml_response/'storage_snapshots/storage_snapshot').each do |r|
|
69
|
-
r[:href].must_match /^http/
|
70
|
-
end
|
71
|
-
end
|
5
|
+
describe 'MockDriver StorageSnapshots' do
|
72
6
|
|
73
|
-
|
74
|
-
|
75
|
-
get collection_url(:storage_snapshots)
|
76
|
-
(xml_response/'storage_snapshots/storage_snapshot').each do |r|
|
77
|
-
r[:href].must_match /#{r[:id]}$/
|
78
|
-
end
|
7
|
+
before do
|
8
|
+
@driver = Deltacloud::new(:mock, :user => 'mockuser', :password => 'mockpassword')
|
79
9
|
end
|
80
10
|
|
81
|
-
it 'must
|
82
|
-
|
83
|
-
|
84
|
-
|
11
|
+
it 'must throw error when wrong credentials' do
|
12
|
+
Proc.new do
|
13
|
+
@driver.backend.storage_snapshots(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
|
14
|
+
end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
|
85
15
|
end
|
86
16
|
|
87
|
-
it 'must
|
88
|
-
|
89
|
-
|
90
|
-
(xml_response/'storage_snapshots/storage_snapshot').each do |r|
|
91
|
-
(r/'name').wont_be_empty
|
92
|
-
end
|
17
|
+
it 'must return list of storage_snapshots' do
|
18
|
+
@driver.storage_snapshots.wont_be_empty
|
19
|
+
@driver.storage_snapshots.first.must_be_kind_of StorageSnapshot
|
93
20
|
end
|
94
21
|
|
95
|
-
it 'must
|
96
|
-
|
97
|
-
|
98
|
-
(
|
99
|
-
|
100
|
-
|
101
|
-
end
|
22
|
+
it 'must allow to filter storage_snapshots' do
|
23
|
+
@driver.storage_snapshots(:id => 'snap1').wont_be_empty
|
24
|
+
@driver.storage_snapshots(:id => 'snap1').must_be_kind_of Array
|
25
|
+
@driver.storage_snapshots(:id => 'snap1').size.must_equal 1
|
26
|
+
@driver.storage_snapshots(:id => 'snap1').first.id.must_equal 'snap1'
|
27
|
+
@driver.storage_snapshots(:id => 'unknown').must_be_empty
|
102
28
|
end
|
103
29
|
|
104
|
-
it 'must
|
105
|
-
|
106
|
-
|
107
|
-
(
|
108
|
-
|
109
|
-
(xml_response/'name').wont_be_empty
|
110
|
-
(xml_response/'name').first.text.must_equal((r/'name').first.text)
|
111
|
-
end
|
30
|
+
it 'must allow to retrieve single storage_snapshot' do
|
31
|
+
@driver.storage_snapshot(:id => 'snap1').wont_be_nil
|
32
|
+
@driver.storage_snapshot(:id => 'snap1').must_be_kind_of StorageSnapshot
|
33
|
+
@driver.storage_snapshot(:id => 'snap1').id.must_equal 'snap1'
|
34
|
+
@driver.storage_snapshot(:id => 'unknown').must_be_nil
|
112
35
|
end
|
113
36
|
|
114
37
|
end
|