deltacloud-core 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/Rakefile +2 -1
  2. data/bin/deltacloudd +11 -5
  3. data/config.ru +3 -3
  4. data/deltacloud-core.gemspec +24 -18
  5. data/lib/cimi/collections/address_templates.rb +3 -3
  6. data/lib/cimi/collections/addresses.rb +6 -5
  7. data/lib/cimi/collections/entity_metadata.rb +0 -2
  8. data/lib/cimi/collections/machine_admins.rb +5 -5
  9. data/lib/cimi/collections/machine_configurations.rb +2 -2
  10. data/lib/cimi/collections/machine_images.rb +3 -3
  11. data/lib/cimi/collections/machines.rb +32 -10
  12. data/lib/cimi/collections/network_configurations.rb +4 -3
  13. data/lib/cimi/collections/network_templates.rb +4 -3
  14. data/lib/cimi/collections/networks.rb +8 -8
  15. data/lib/cimi/collections/routing_group_templates.rb +4 -3
  16. data/lib/cimi/collections/routing_groups.rb +4 -3
  17. data/lib/cimi/collections/volume_configurations.rb +3 -3
  18. data/lib/cimi/collections/volume_images.rb +3 -3
  19. data/lib/cimi/collections/volumes.rb +4 -3
  20. data/lib/cimi/collections/vsp_configurations.rb +4 -3
  21. data/lib/cimi/collections/vsp_templates.rb +4 -3
  22. data/lib/cimi/collections/vsps.rb +8 -7
  23. data/lib/cimi/helpers.rb +1 -1
  24. data/lib/cimi/helpers/cimi_helper.rb +11 -1
  25. data/lib/cimi/models.rb +4 -0
  26. data/lib/cimi/models/base.rb +11 -1
  27. data/lib/cimi/models/cloud_entry_point.rb +7 -14
  28. data/lib/cimi/models/disk.rb +40 -0
  29. data/lib/cimi/models/disk_collection.rb +38 -0
  30. data/lib/cimi/models/machine.rb +9 -43
  31. data/lib/cimi/models/machine_collection.rb +7 -4
  32. data/lib/cimi/models/machine_configuration.rb +8 -15
  33. data/lib/cimi/models/machine_configuration_collection.rb +6 -4
  34. data/lib/cimi/models/machine_image_collection.rb +6 -4
  35. data/lib/cimi/models/machine_template_collection.rb +6 -4
  36. data/lib/cimi/models/machine_volume.rb +42 -0
  37. data/lib/cimi/models/machine_volume_collection.rb +34 -0
  38. data/lib/cimi/models/network.rb +5 -9
  39. data/lib/cimi/models/network_collection.rb +6 -5
  40. data/lib/cimi/models/schema.rb +20 -0
  41. data/lib/cimi/models/volume_collection.rb +6 -4
  42. data/lib/cimi/models/volume_configuration_collection.rb +6 -4
  43. data/lib/cimi/models/volume_image_collection.rb +6 -4
  44. data/lib/cimi/models/volume_template_collection.rb +6 -4
  45. data/lib/deltacloud/api.rb +3 -3
  46. data/lib/deltacloud/collections/addresses.rb +1 -1
  47. data/lib/deltacloud/collections/firewalls.rb +4 -2
  48. data/lib/deltacloud/collections/keys.rb +1 -1
  49. data/lib/deltacloud/collections/load_balancers.rb +1 -1
  50. data/lib/deltacloud/collections/storage_volumes.rb +4 -4
  51. data/lib/deltacloud/drivers/base_driver.rb +12 -20
  52. data/lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb +294 -0
  53. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +38 -6
  54. data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +4 -0
  55. data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +40 -4
  56. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +8 -7
  57. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +422 -416
  58. data/lib/deltacloud/drivers/google/google_driver.rb +2 -1
  59. data/lib/deltacloud/drivers/openstack/openstack_driver.rb +30 -16
  60. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +1 -0
  61. data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +3 -9
  62. data/lib/deltacloud/helpers/deltacloud_helper.rb +0 -2
  63. data/lib/deltacloud/models/firewall_rule.rb +2 -0
  64. data/lib/deltacloud/models/hardware_profile.rb +61 -59
  65. data/{tests/deprecated/core_ext/string.rb → lib/deltacloud/version.rb} +3 -15
  66. data/lib/deltacloud_rack.rb +1 -0
  67. data/lib/ec2/server.rb +5 -3
  68. data/lib/sinatra/rack_accept.rb +53 -53
  69. data/lib/sinatra/rack_etag.rb +1 -1
  70. data/tests/cimi/collections/cloud_entry_point_test.rb +11 -2
  71. data/tests/deltacloud/common.rb +1 -1
  72. data/tests/deltacloud/rack_test.rb +3 -3
  73. data/tests/drivers/base/base_driver_test.rb +6 -2
  74. data/tests/drivers/base/common.rb +1 -0
  75. data/tests/drivers/base/library_test.rb +6 -2
  76. data/tests/drivers/ec2/common.rb +34 -15
  77. data/tests/drivers/ec2/images_test.rb +2 -3
  78. data/tests/drivers/ec2/instance_test.rb +12 -2
  79. data/tests/drivers/ec2/keys_test.rb +2 -2
  80. data/tests/drivers/ec2/realms_test.rb +7 -3
  81. data/tests/drivers/ec2/storage_snapshots_test.rb +2 -3
  82. data/tests/drivers/gogrid/common.rb +24 -0
  83. data/tests/drivers/gogrid/hardware_profiles_test.rb +51 -0
  84. data/tests/drivers/gogrid/images_test.rb +57 -0
  85. data/tests/drivers/gogrid/instances_test.rb +92 -0
  86. data/tests/drivers/gogrid/realms_test.rb +45 -0
  87. data/tests/drivers/google/buckets_test.rb +105 -0
  88. data/tests/drivers/google/common.rb +20 -0
  89. data/tests/drivers/mock/common.rb +1 -0
  90. data/tests/drivers/mock/images_test.rb +3 -2
  91. data/tests/drivers/mock/instances_test.rb +3 -2
  92. data/tests/drivers/mock/keys_test.rb +3 -2
  93. data/tests/drivers/mock/realms_test.rb +3 -2
  94. data/tests/drivers/mock/storage_snapshots_test.rb +3 -2
  95. data/tests/drivers/mock/storage_volumes_test.rb +3 -2
  96. data/tests/drivers/models/address_test.rb +3 -3
  97. data/tests/drivers/models/base_test.rb +4 -2
  98. data/tests/drivers/models/blob_test.rb +3 -3
  99. data/tests/drivers/models/common.rb +3 -0
  100. data/tests/drivers/models/hardware_profile_test.rb +5 -4
  101. data/tests/drivers/models/instance_address_test.rb +3 -3
  102. data/tests/drivers/models/instance_profile_test.rb +3 -3
  103. data/tests/drivers/models/instance_test.rb +3 -3
  104. data/tests/drivers/models/keys_test.rb +3 -3
  105. data/tests/drivers/models/metrics_test.rb +3 -3
  106. data/tests/drivers/openstack/common.rb +26 -0
  107. data/tests/drivers/openstack/hardware_profiles_test.rb +46 -0
  108. data/tests/drivers/openstack/images_test.rb +50 -0
  109. data/tests/drivers/openstack/instances_test.rb +66 -0
  110. data/tests/drivers/openstack/keys_test.rb +61 -0
  111. data/tests/drivers/openstack/realms_test.rb +46 -0
  112. data/tests/drivers/rhevm/common.rb +2 -0
  113. data/tests/drivers/rhevm/images_test.rb +3 -4
  114. data/tests/drivers/rhevm/instance_test.rb +2 -2
  115. data/tests/drivers/rhevm/provider_test.rb +2 -2
  116. data/tests/drivers/rhevm/realms_test.rb +2 -3
  117. data/tests/ec2/common.rb +5 -4
  118. data/tests/ec2/server_test.rb +3 -2
  119. data/tests/helpers/rack/common.rb +3 -0
  120. data/tests/helpers/rack/rack_accept_test.rb +65 -0
  121. data/tests/helpers/rack/rack_date_test.rb +27 -0
  122. data/tests/helpers/rack/rack_driver_select_test.rb +53 -0
  123. data/tests/helpers/rack/rack_etag_test.rb +29 -0
  124. data/tests/helpers/rack/rack_matrix_params_test.rb +72 -0
  125. data/tests/test_helper.rb +44 -36
  126. data/views/hardware_profiles/index.html.haml +1 -1
  127. data/views/hardware_profiles/show.html.haml +2 -2
  128. data/views/hardware_profiles/show.xml.haml +2 -1
  129. data/views/images/show.html.haml +6 -5
  130. metadata +74 -117
  131. data/tests/deprecated/api/common.rb +0 -1
  132. data/tests/deprecated/api/driver_test.rb +0 -79
  133. data/tests/deprecated/api/library_test.rb +0 -6
  134. data/tests/deprecated/cimi/features/step_definitions/common_steps.rb +0 -59
  135. data/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb +0 -0
  136. data/tests/deprecated/cimi/features/step_definitions/machines_steps.rb +0 -100
  137. data/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb +0 -115
  138. data/tests/deprecated/cimi/features/support/env.rb +0 -75
  139. data/tests/deprecated/common.rb +0 -279
  140. data/tests/deprecated/drivers/ec2/api_test.rb +0 -19
  141. data/tests/deprecated/drivers/ec2/common.rb +0 -23
  142. data/tests/deprecated/drivers/ec2/drivers_test.rb +0 -120
  143. data/tests/deprecated/drivers/ec2/hardware_profiles_test.rb +0 -224
  144. data/tests/deprecated/drivers/ec2/images_test.rb +0 -230
  145. data/tests/deprecated/drivers/ec2/instances_test.rb +0 -356
  146. data/tests/deprecated/drivers/ec2/keys_test.rb +0 -181
  147. data/tests/deprecated/drivers/ec2/realms_test.rb +0 -146
  148. data/tests/deprecated/drivers/fgcp/api_test.rb +0 -47
  149. data/tests/deprecated/drivers/fgcp/hardware_profiles_test.rb +0 -54
  150. data/tests/deprecated/drivers/fgcp/realms_test.rb +0 -42
  151. data/tests/deprecated/drivers/fgcp/setup.rb +0 -13
  152. data/tests/deprecated/drivers/google/api_test.rb +0 -19
  153. data/tests/deprecated/drivers/google/buckets_test.rb +0 -100
  154. data/tests/deprecated/drivers/google/common.rb +0 -54
  155. data/tests/deprecated/drivers/mock/api_test.rb +0 -10
  156. data/tests/deprecated/drivers/mock/buckets_test.rb +0 -195
  157. data/tests/deprecated/drivers/mock/common.rb +0 -7
  158. data/tests/deprecated/drivers/mock/drivers_test.rb +0 -123
  159. data/tests/deprecated/drivers/mock/hardware_profiles_test.rb +0 -224
  160. data/tests/deprecated/drivers/mock/images_test.rb +0 -197
  161. data/tests/deprecated/drivers/mock/instances_test.rb +0 -343
  162. data/tests/deprecated/drivers/mock/keys_test.rb +0 -161
  163. data/tests/deprecated/drivers/mock/realms_test.rb +0 -132
  164. data/tests/deprecated/drivers/mock/storage_snapshots_test.rb +0 -114
  165. data/tests/deprecated/drivers/mock/storage_volumes_test.rb +0 -122
  166. data/tests/deprecated/drivers/openstack/api_test.rb +0 -46
  167. data/tests/deprecated/drivers/openstack/common.rb +0 -21
  168. data/tests/deprecated/drivers/openstack/hardware_profiles_test.rb +0 -64
  169. data/tests/deprecated/drivers/openstack/images_test.rb +0 -46
  170. data/tests/deprecated/drivers/openstack/instances_test.rb +0 -208
  171. data/tests/deprecated/drivers/openstack/realms_test.rb +0 -40
  172. data/tests/deprecated/drivers/rackspace/api_test.rb +0 -46
  173. data/tests/deprecated/drivers/rackspace/buckets_test.rb +0 -150
  174. data/tests/deprecated/drivers/rackspace/common.rb +0 -16
  175. data/tests/deprecated/drivers/rackspace/hardware_profiles_test.rb +0 -58
  176. data/tests/deprecated/drivers/rackspace/images_test.rb +0 -45
  177. data/tests/deprecated/drivers/rackspace/instances_test.rb +0 -166
  178. data/tests/deprecated/drivers/rackspace/realms_test.rb +0 -41
  179. data/tests/deprecated/drivers/rhevm/api_test.rb +0 -45
  180. data/tests/deprecated/drivers/rhevm/common.rb +0 -21
  181. data/tests/deprecated/drivers/rhevm/hardware_profiles_test.rb +0 -58
  182. data/tests/deprecated/drivers/rhevm/images_test.rb +0 -48
  183. data/tests/deprecated/drivers/rhevm/instances_test.rb +0 -182
  184. data/tests/deprecated/drivers/rhevm/realms_test.rb +0 -40
  185. data/tests/deprecated/minitest_common.rb +0 -58
  186. data/tests/deprecated/minitest_common_api_test.rb +0 -115
  187. data/tests/deprecated/rabbit_test.rb +0 -52
@@ -1,19 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/ec2/common'
3
-
4
- describe 'Deltacloud API' do
5
-
6
- before do
7
- Timecop.freeze(FREEZED_TIME)
8
- VCR.insert_cassette __name__
9
- end
10
-
11
- after do
12
- VCR.eject_cassette
13
- end
14
-
15
- include Deltacloud::Test
16
-
17
- eval File.read('tests/minitest_common_api_test.rb')
18
-
19
- end
@@ -1,23 +0,0 @@
1
- ENV['API_DRIVER'] = 'ec2'
2
- ENV['TESTS_API_USERNAME'] = 'AKIAIZ63KHGXIWDMBY6Q'
3
- ENV['TESTS_API_PASSWORD'] = 'zUfBCbML2S6pXKS44eEEXw0Cf/G8z9hMSxP2hcLV'
4
- ENV['RACK_ENV'] = 'test'
5
-
6
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
7
- require 'tests/minitest_common'
8
-
9
- require 'vcr'
10
- require 'timecop'
11
-
12
- VCR.configure do |c|
13
- c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
14
- c.hook_into :webmock
15
- c.default_cassette_options = { :record => :new_episodes }
16
- #c.default_cassette_options = { :record => :none }
17
- end
18
-
19
- # Let's set time that timecop will use to freeze
20
- # Time.now will then return this time instead of 'real' system time
21
-
22
- FREEZED_TIME = DateTime.parse("2012-05-31 12:58:00 +0200")
23
- Timecop.freeze(FREEZED_TIME)
@@ -1,120 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/ec2/common'
3
-
4
- describe 'Deltacloud API drivers' do
5
- include Deltacloud::Test
6
- before do
7
- Timecop.freeze(FREEZED_TIME)
8
- VCR.insert_cassette __name__
9
- end
10
-
11
- after do
12
- VCR.eject_cassette
13
- end
14
-
15
- it 'must advertise have the drivers collection in API entrypoint' do
16
- get root_url
17
- (xml_response/'api/link[@rel=drivers]').wont_be_empty
18
- end
19
-
20
- it 'must not require authentication to access the "driver" collection' do
21
- get collection_url(:drivers)
22
- last_response.status.must_equal 200
23
- end
24
-
25
- it 'should respond with HTTP_OK when accessing the :drivers collection with authentication' do
26
- get collection_url(:drivers)
27
- last_response.status.must_equal 200
28
- end
29
-
30
- it 'should support the JSON media type' do
31
- header 'Accept', 'application/json'
32
- get collection_url(:drivers)
33
- last_response.status.must_equal 200
34
- last_response.headers['Content-Type'].must_equal 'application/json'
35
- end
36
-
37
- it 'must include the ETag in HTTP headers' do
38
- get collection_url(:drivers)
39
- last_response.headers['ETag'].wont_be_nil
40
- end
41
-
42
- it 'must have the "drivers" element on top level' do
43
- get collection_url(:drivers)
44
- xml_response.root.name.must_equal 'drivers'
45
- end
46
-
47
- it 'must have some "driver" elements inside "drivers"' do
48
- get collection_url(:drivers)
49
- (xml_response/'drivers/driver').wont_be_empty
50
- end
51
-
52
- it 'must provide the :id attribute for each driver in collection' do
53
- get collection_url(:drivers)
54
- (xml_response/'drivers/driver').each do |r|
55
- r[:id].wont_be_nil
56
- end
57
- end
58
-
59
- it 'must include the :href attribute for each "driver" element in collection' do
60
- get collection_url(:drivers)
61
- (xml_response/'drivers/driver').each do |r|
62
- r[:href].wont_be_nil
63
- end
64
- end
65
-
66
- it 'must use the absolute URL in each :href attribute' do
67
- get collection_url(:drivers)
68
- (xml_response/'drivers/driver').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 driver' do
74
- get collection_url(:drivers)
75
- (xml_response/'drivers/driver').each do |r|
76
- r[:href].must_match /#{r[:id]}$/
77
- end
78
- end
79
-
80
- it 'must return the list of valid parameters for the :index action' do
81
- options collection_url(:drivers) + '/index'
82
- last_response.headers['Allow'].wont_be_nil
83
- end
84
-
85
- it 'must have the "name" element defined for each driver in collection' do
86
- get collection_url(:drivers)
87
- (xml_response/'drivers/driver').each do |r|
88
- (r/'name').wont_be_nil
89
- end
90
- end
91
-
92
-
93
- it 'must return the full "driver" when following the URL in driver element' do
94
- authenticate
95
- get collection_url(:drivers)
96
- (xml_response/'drivers/driver').each do |r|
97
- get collection_url(:drivers) + '/' + r[:id]
98
- last_response.status.must_equal 200
99
- end
100
- end
101
-
102
- it 'must have the "name" element for the driver and it should match with the one in collection' do
103
- authenticate
104
- get collection_url(:drivers)
105
- (xml_response/'drivers/driver').each do |r|
106
- r[:id].wont_be_nil
107
- get collection_url(:drivers) + '/' + r[:id]
108
- (xml_response/'name').wont_be_empty
109
- (xml_response/'name').first.text.must_equal((r/'name').first.text)
110
- end
111
- end
112
-
113
- it 'should advertise available providers for some drivers' do
114
- get collection_url(:drivers)
115
- (xml_response/'drivers/driver/provider').each do |p|
116
- p[:id].wont_be_nil
117
- end
118
- end
119
-
120
- end
@@ -1,224 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/ec2/common'
3
-
4
- describe 'Deltacloud API Hardware Profiles' do
5
- include Deltacloud::Test
6
-
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
11
-
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
17
-
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
49
- end
50
- end
51
-
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
57
- end
58
- end
59
-
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/
65
- end
66
- end
67
-
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]}$/
73
- end
74
- end
75
-
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
87
- end
88
- end
89
-
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
96
- end
97
- end
98
-
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 }
105
- end
106
- end
107
-
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 }
114
- end
115
- end
116
-
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 }
123
- end
124
- end
125
-
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
134
-
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
149
- end
150
- end
151
- end
152
-
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
165
-
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
180
-
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
192
-
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
201
- end
202
- end
203
- end
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
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
-
224
- end
@@ -1,230 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
2
- require 'tests/drivers/ec2/common'
3
-
4
- describe 'Deltacloud API Images' do
5
- before do
6
- Timecop.freeze(FREEZED_TIME)
7
- VCR.insert_cassette __name__
8
- end
9
-
10
- after do
11
- VCR.eject_cassette
12
- end
13
-
14
- include Deltacloud::Test
15
-
16
- it 'must advertise have the images collection in API entrypoint' do
17
- get root_url
18
- (xml_response/'api/link[@rel=images]').wont_be_empty
19
- end
20
-
21
- it 'must require authentication to access the "image" collection' do
22
- get collection_url(:images)
23
- last_response.status.must_equal 401
24
- end
25
-
26
- it 'should respond with HTTP_OK when accessing the :images collection with authentication' do
27
- authenticate
28
- get collection_url(:images)
29
- last_response.status.must_equal 200
30
- end
31
-
32
- it 'should support the JSON media type' do
33
- authenticate
34
- header 'Accept', 'application/json'
35
- get collection_url(:images)
36
- last_response.status.must_equal 200
37
- last_response.headers['Content-Type'].must_equal 'application/json'
38
- end
39
-
40
- it 'must include the ETag in HTTP headers' do
41
- authenticate
42
- get collection_url(:images)
43
- last_response.headers['ETag'].wont_be_nil
44
- end
45
-
46
- it 'must have the "images" element on top level' do
47
- authenticate
48
- get collection_url(:images)
49
- xml_response.root.name.must_equal 'images'
50
- end
51
-
52
- it 'must have some "image" elements inside "images"' do
53
- authenticate
54
- get collection_url(:images)
55
- (xml_response/'images/image').wont_be_empty
56
- end
57
-
58
- it 'must provide the :id attribute for each image in collection' do
59
- authenticate
60
- get collection_url(:images)
61
- (xml_response/'images/image').each do |r|
62
- r[:id].wont_be_nil
63
- end
64
- end
65
-
66
- it 'must include the :href attribute for each "image" element in collection' do
67
- authenticate
68
- get collection_url(:images)
69
- (xml_response/'images/image').each do |r|
70
- r[:href].wont_be_nil
71
- end
72
- end
73
-
74
- it 'must use the absolute URL in each :href attribute' do
75
- authenticate
76
- get collection_url(:images)
77
- (xml_response/'images/image').each do |r|
78
- r[:href].must_match /^http/
79
- end
80
- end
81
-
82
- it 'must have the URL ending with the :id of the image' do
83
- authenticate
84
- get collection_url(:images)
85
- (xml_response/'images/image').each do |r|
86
- r[:href].must_match /#{r[:id]}$/
87
- end
88
- end
89
-
90
- it 'must return the list of valid parameters for the :index action' do
91
- authenticate
92
- options collection_url(:images) + '/index'
93
- last_response.headers['Allow'].wont_be_nil
94
- end
95
-
96
- it 'must have the "name" element defined for each image in collection' do
97
- authenticate
98
- get collection_url(:images)
99
- (xml_response/'images/image').each do |r|
100
- (r/'name').wont_be_empty
101
- end
102
- end
103
-
104
- it 'must have the "state" element defined for each image in collection' do
105
- authenticate
106
- get collection_url(:images)
107
- (xml_response/'images/image').each do |r|
108
- (r/'state').wont_be_empty
109
- end
110
- end
111
-
112
- it 'must return the full "image" when following the URL in image element' do
113
- authenticate
114
- get collection_url(:images)
115
- (xml_response/'images/image').wont_be_empty
116
- (xml_response/'images/image')[0..10].each do |r|
117
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
118
- get collection_url(:images) + '/' + r[:id]
119
- end
120
- last_response.status.must_equal 200
121
- end
122
- end
123
-
124
- it 'must have the "name" element for the image and it should match with the one in collection' do
125
- authenticate
126
- get collection_url(:images)
127
- (xml_response/'images/image').wont_be_empty
128
- (xml_response/'images/image')[0..10].each do |r|
129
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
130
- get collection_url(:images) + '/' + r[:id]
131
- end
132
- (xml_response/'name').wont_be_empty
133
- (xml_response/'name').first.text.must_equal((r/'name').first.text)
134
- end
135
- end
136
-
137
- it 'must have the "name" element for the image and it should match with the one in collection' do
138
- authenticate
139
- get collection_url(:images)
140
- (xml_response/'images/image').wont_be_empty
141
- (xml_response/'images/image')[0..10].each do |r|
142
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
143
- get collection_url(:images) + '/' + r[:id]
144
- end
145
- (xml_response/'state').wont_be_empty
146
- (xml_response/'state').first.text.must_equal((r/'state').first.text)
147
- end
148
- end
149
-
150
- it 'should have the "owner_id" element for each image' do
151
- authenticate
152
- get collection_url(:images)
153
- (xml_response/'images/image').wont_be_empty
154
- (xml_response/'images/image')[0..10].each do |r|
155
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
156
- get collection_url(:images) + '/' + r[:id]
157
- end
158
- (xml_response/'owner_id').wont_be_empty
159
- end
160
- end
161
-
162
- it 'should have the "description" element for each image' do
163
- authenticate
164
- get collection_url(:images)
165
- (xml_response/'images/image').wont_be_empty
166
- (xml_response/'images/image')[0..10].each do |r|
167
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
168
- get collection_url(:images) + '/' + r[:id]
169
- end
170
- (xml_response/'description').wont_be_empty
171
- end
172
- end
173
-
174
- it 'should have the "architecture" element for each image' do
175
- authenticate
176
- get collection_url(:images)
177
- (xml_response/'images/image').wont_be_empty
178
- (xml_response/'images/image')[0..10].each do |r|
179
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
180
- get collection_url(:images) + '/' + r[:id]
181
- end
182
- (xml_response/'architecture').wont_be_empty
183
- end
184
- end
185
-
186
- it 'should include the list of compatible hardware_profiles for each image' do
187
- authenticate
188
- get collection_url(:images)
189
- (xml_response/'images/image').wont_be_empty
190
- (xml_response/'images/image')[0..10].each do |r|
191
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
192
- get collection_url(:images) + '/' + r[:id]
193
- end
194
- (xml_response/'hardware_profiles/hardware_profile').wont_be_empty
195
- (xml_response/'hardware_profiles/hardware_profile').each do |hwp|
196
- hwp[:href].wont_be_nil
197
- hwp[:href].must_match /^http/
198
- hwp[:id].wont_be_nil
199
- hwp[:href].must_match /\/#{hwp[:id]}$/
200
- hwp[:rel].must_equal 'hardware_profile'
201
- end
202
- end
203
- end
204
-
205
- it 'should advertise the list of actions that can be executed for each image' do
206
- authenticate
207
- get collection_url(:images)
208
- (xml_response/'images/image').wont_be_empty
209
- (xml_response/'images/image')[0..10].each do |r|
210
- VCR.use_cassette "#{__name__}_image_#{r[:id]}" do
211
- get collection_url(:images) + '/' + r[:id]
212
- end
213
- (xml_response/'actions/link').wont_be_empty
214
- (xml_response/'actions/link').each do |l|
215
- l[:href].wont_be_nil
216
- l[:href].must_match /^http/
217
- l[:method].wont_be_nil
218
- l[:rel].wont_be_nil
219
- end
220
- end
221
- end
222
-
223
- it 'should give client HTML form to create new image' do
224
- authenticate
225
- header 'Accept', 'text/html'
226
- get collection_url(:images) + '/new'
227
- last_response.status.must_equal 200
228
- end
229
-
230
- end