fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -60,11 +60,6 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
60
60
  directories.
61
61
  create(directory_attributes)
62
62
 
63
- model_tests(@directory.files, file_attributes.merge(:etag => 'foo'), Fog.mocking?) do
64
- tests('#save should not blow up with etag') do
65
- @instance.save
66
- end
67
- end
68
63
 
69
64
  model_tests(@directory.files, file_attributes, Fog.mocking?) do
70
65
 
@@ -187,8 +182,29 @@ Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
187
182
  tests('#streaming_url').returns(0) do
188
183
  @instance.streaming_url =~ /http:\/\/.+\.stream\..*#{@instance.key}/
189
184
  end
190
- end
185
+ end
186
+
187
+ tests('etags') do
188
+ text = lorem_file.read
189
+ md5 = Digest::MD5.new
190
+ md5 << text
191
+ etag = md5.hexdigest
192
+
193
+ begin
194
+ tests('valid tag').returns(true) do
195
+ @file = @directory.files.create :key => 'valid-etag.txt', :body => text, :etag => etag
196
+ @file.reload
197
+ @file.etag == etag
198
+ end
199
+ ensure
200
+ @file.destroy if @file
201
+ end
202
+
203
+ tests('invalid tag').raises(Fog::Storage::Rackspace::ServiceError) do
204
+ @directory.files.create :key => 'invalid-etag.txt', :body => text, :etag => "bad-bad-tag"
205
+ end
191
206
  end
207
+ end
192
208
 
193
209
  tests('#metadata keys') do
194
210
 
@@ -18,4 +18,39 @@ Shindo.tests('Fog::Rackspace', ['rackspace']) do
18
18
  end
19
19
  end
20
20
 
21
+ tests('json_response?') do
22
+ returns(false, "nil") { Fog::Rackspace.json_response?(nil) }
23
+
24
+ tests('missing header').returns(false) do
25
+ response = Excon::Response.new
26
+ response.headers = nil #maybe this is a forced case
27
+ returns(true) { response.headers.nil? }
28
+ Fog::Rackspace.json_response?(response)
29
+ end
30
+
31
+ tests('nil Content-Type header').returns(false) do
32
+ response = Excon::Response.new
33
+ response.headers['Content-Type'] = nil
34
+ Fog::Rackspace.json_response?(response)
35
+ end
36
+
37
+ tests('text/html Content-Type header').returns(false) do
38
+ response = Excon::Response.new
39
+ response.headers['Content-Type'] = 'text/html'
40
+ Fog::Rackspace.json_response?(response)
41
+ end
42
+
43
+ tests('application/json Content-Type header').returns(true) do
44
+ response = Excon::Response.new
45
+ response.headers['Content-Type'] = 'application/json'
46
+ Fog::Rackspace.json_response?(response)
47
+ end
48
+
49
+ tests('APPLICATION/JSON Content-Type header').returns(true) do
50
+ response = Excon::Response.new
51
+ response.headers['Content-Type'] = 'APPLICATION/JSON'
52
+ Fog::Rackspace.json_response?(response)
53
+ end
54
+ end
55
+
21
56
  end
@@ -8,9 +8,8 @@ Shindo.tests('Fog::Rackspace::BlockStorage | snapshot_tests', ['rackspace']) do
8
8
  'display_description' => Fog::Nullable::String,
9
9
  'volume_id' => String,
10
10
  'size' => Integer,
11
- 'created_at' => String,
12
- 'availability_zone' => String
13
- }
11
+ 'created_at' => String
12
+ }
14
13
 
15
14
  get_snapshot_format = {
16
15
  'snapshot' => snapshot_format
@@ -1,15 +1,8 @@
1
1
  Shindo.tests('Fog::Rackspace::BlockStorage | volume_type_tests', ['rackspace']) do
2
2
  volume_type_format = {
3
3
  'name' => String,
4
- 'extra_specs' => Hash
5
- }
6
-
7
- list_volume_type_format = {
8
- 'volume_types' => [volume_type_format.merge({ 'id' => Integer })]
9
- }
10
-
11
- get_volume_type_format = {
12
- 'volume_type' => volume_type_format.merge({ 'id' => String })
4
+ 'extra_specs' => Hash,
5
+ 'id' => String
13
6
  }
14
7
 
15
8
  service = Fog::Rackspace::BlockStorage.new
@@ -17,11 +10,11 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume_type_tests', ['rackspace'])
17
10
  tests('success') do
18
11
  volume_type_id = service.volume_types.first.id
19
12
 
20
- tests("#list_volume_types").formats(list_volume_type_format) do
13
+ tests("#list_volume_types").formats('volume_types' => [volume_type_format]) do
21
14
  service.list_volume_types.body
22
15
  end
23
16
 
24
- tests("#get_volume_type(#{volume_type_id})").formats(get_volume_type_format) do
17
+ tests("#get_volume_type(#{volume_type_id})").formats('volume_type' => volume_type_format) do
25
18
  service.get_volume_type(volume_type_id).body
26
19
  end
27
20
  end
@@ -5,7 +5,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | address requests', ['rackspace']) do
5
5
  tests('success') do
6
6
  unless Fog.mocking?
7
7
  @server = @service.servers.create(:flavor_id => 2, :image_id => "8a3a9f96-b997-46fd-b7a8-a9e740796ffd", :name => "address-tests-#{Time.now.to_i}")
8
- @server.wait_for(timeout=1200) { ready? }
8
+ @server.wait_for { ready? }
9
9
  @server_id = @server.id
10
10
  else
11
11
  @server_id = 42
@@ -1,9 +1,8 @@
1
1
  Shindo.tests('Fog::Compute::RackspaceV2 | attachment_tests', ['rackspace']) do
2
2
  compute_service = Fog::Compute::RackspaceV2.new
3
3
  block_storage_service = Fog::Rackspace::BlockStorage.new
4
- image_id = Fog.credentials[:rackspace_image_id] || compute_service.images.first.id
5
- flavor_id = Fog.credentials[:rackspace_flavor_id] || compute_service.flavors.first.id
6
- timeout = Fog.mocking? ? 1 : 10
4
+ image_id = rackspace_test_image_id(compute_service)
5
+ flavor_id = rackspace_test_flavor_id(compute_service)
7
6
 
8
7
  attachment_format = {
9
8
  'volumeAttachment' => {
@@ -27,12 +26,12 @@ Shindo.tests('Fog::Compute::RackspaceV2 | attachment_tests', ['rackspace']) do
27
26
 
28
27
 
29
28
  tests('success') do
30
- until compute_service.get_server(server_id).body['server']['status'] == 'ACTIVE'
31
- sleep timeout
29
+ wait_for_request("Waiting for server to become ready") do
30
+ compute_service.get_server(server_id).body['server']['status'] == 'ACTIVE'
32
31
  end
33
32
 
34
- until block_storage_service.get_volume(volume_id).body['volume']['status'] == 'available'
35
- sleep timeout
33
+ wait_for_request("Waiting for Volume to be ready") do
34
+ block_storage_service.get_volume(volume_id).body['volume']['status'] == 'available'
36
35
  end
37
36
 
38
37
  tests("#attach_volume(#{server_id}, #{volume_id}, #{device_id})").formats(attachment_format) do
@@ -43,8 +42,8 @@ Shindo.tests('Fog::Compute::RackspaceV2 | attachment_tests', ['rackspace']) do
43
42
  compute_service.list_attachments(server_id).body
44
43
  end
45
44
 
46
- until block_storage_service.get_volume(volume_id).body['volume']['status'] == 'in-use'
47
- sleep timeout
45
+ wait_for_request("Waiting for Volume to be ready") do
46
+ block_storage_service.get_volume(volume_id).body['volume']['status'] == 'in-use'
48
47
  end
49
48
 
50
49
  tests("#get_attachment(#{server_id}, #{volume_id})").formats(attachment_format) do
@@ -18,7 +18,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | flavor_tests', ['rackspace']) do
18
18
 
19
19
  get_flavor_format = {
20
20
  'flavor' => flavor_format.merge({
21
- 'OS-FLV-DISABLED:disabled' => Fog::Boolean,
21
+ 'OS-FLV-EXT-DATA:ephemeral' => Integer,
22
22
  'rxtx_factor' => Float,
23
23
  'swap' => Integer
24
24
  })
@@ -12,7 +12,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata_tests', ['rackspace']) do
12
12
  :flavor_id => 2,
13
13
  :image_id => '3afe97b2-26dc-49c5-a2cc-a2fc8d80c001',
14
14
  :metadata => metadata)
15
- @server.wait_for(timeout = 1500) { ready? }
15
+ @server.wait_for { ready? }
16
16
 
17
17
 
18
18
  @server_id = @server.id
@@ -40,12 +40,12 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata_tests', ['rackspace']) do
40
40
  @service.set_metadata_item("servers", @server_id, "environment", "test").body
41
41
  end
42
42
  tests('delete_metadata_item').succeeds do
43
- @service.delete_metadata_item("servers", @server_id, "environment").body
43
+ @service.delete_metadata_item("servers", @server_id, "environment")
44
44
  end
45
45
  end
46
46
 
47
47
  tests("images") do
48
- @image.wait_for(timeout = 1500) { ready? } unless Fog.mocking?
48
+ @image.wait_for { ready? } unless Fog.mocking?
49
49
 
50
50
  tests('list_metadata').returns(metadata) do
51
51
  h = @service.list_metadata("images", @image_id).body
@@ -66,7 +66,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata_tests', ['rackspace']) do
66
66
  @service.set_metadata_item("images", @image_id, "environment", "test").body
67
67
  end
68
68
  tests('delete_metadata_item').succeeds do
69
- @service.delete_metadata_item("images", @image_id, "environment").body
69
+ @service.delete_metadata_item("images", @image_id, "environment")
70
70
  end
71
71
  end
72
72
  ensure
@@ -4,33 +4,36 @@ Shindo.tests('Fog::Rackspace::Database | database_tests', ['rackspace']) do
4
4
 
5
5
  service = Fog::Rackspace::Databases.new
6
6
  instance_name = 'fog' + Time.now.to_i.to_s
7
- instance_id = service.create_instance(instance_name, 1, 1).body['instance']['id']
8
7
 
9
- until service.get_instance(instance_id).body["instance"]["status"] == 'ACTIVE'
10
- sleep 10
11
- end
12
-
13
- tests('success') do
14
- database_name = 'fogdb' + Time.now.to_i.to_s
8
+ begin
9
+ @instance_id = service.create_instance(instance_name, 1, 1).body['instance']['id']
15
10
 
16
- tests("#create_database(#{instance_id}, #{database_name})").succeeds do
17
- service.create_database(instance_id, database_name).body
11
+ wait_for_request("waiting for database to be created") do
12
+ service.get_instance(@instance_id).body["instance"]["status"] == 'ACTIVE'
18
13
  end
19
14
 
20
- tests("#list_databases{#{instance_id})").formats(LIST_DATABASES_FORMAT) do
21
- service.list_databases(instance_id).body
22
- end
15
+ tests('success') do
16
+ database_name = 'fogdb' + Time.now.to_i.to_s
17
+
18
+ tests("#create_database(#{@instance_id}, #{database_name})").returns(202) do
19
+ service.create_database(@instance_id, database_name).status
20
+ end
23
21
 
24
- tests("#delete_database(#{instance_id}, #{database_name})").succeeds do
25
- service.delete_database(instance_id, database_name)
22
+ tests("#list_databases{#{@instance_id})").formats(LIST_DATABASES_FORMAT) do
23
+ service.list_databases(@instance_id).body
24
+ end
25
+
26
+ tests("#delete_database(#{@instance_id}, #{database_name})").returns(202) do
27
+ service.delete_database(@instance_id, database_name).status
28
+ end
26
29
  end
27
- end
28
30
 
29
- tests('failure') do
30
- tests("#create_database(#{instance_id}, '') => Invalid Create Critera").raises(Fog::Rackspace::Databases::BadRequest) do
31
- service.create_database(instance_id, '')
31
+ tests('failure') do
32
+ tests("#create_database(#{@instance_id}, '') => Invalid Create Critera").raises(Fog::Rackspace::Databases::BadRequest) do
33
+ service.create_database(@instance_id, '')
34
+ end
32
35
  end
36
+ ensure
37
+ service.delete_instance(@instance_id) if @instance_id
33
38
  end
34
-
35
- service.delete_instance(instance_id)
36
39
  end
@@ -6,24 +6,24 @@ Shindo.tests('Fog::Rackspace::Database | user_tests', ['rackspace']) do
6
6
  instance_name = 'fog' + Time.now.to_i.to_s
7
7
  instance_id = service.create_instance(instance_name, 1, 1).body['instance']['id']
8
8
 
9
- until service.get_instance(instance_id).body["instance"]["status"] == 'ACTIVE'
10
- sleep 10
9
+ wait_for_request("Waiting for database to be created") do
10
+ service.get_instance(instance_id).body["instance"]["status"] == 'ACTIVE'
11
11
  end
12
12
 
13
13
  tests('success') do
14
14
  user_name = 'fog' + Time.now.to_i.to_s
15
15
  password = 'password1'
16
16
 
17
- tests("#create_user(#{instance_id}, #{user_name}, #{password})").succeeds do
18
- service.create_user(instance_id, user_name, password).body
17
+ tests("#create_user(#{instance_id}, #{user_name}, #{password})").returns(202) do
18
+ service.create_user(instance_id, user_name, password).status
19
19
  end
20
20
 
21
21
  tests("#list_users{#{instance_id})").formats(LIST_USERS_FORMAT) do
22
22
  service.list_users(instance_id).body
23
23
  end
24
24
 
25
- tests("#delete_user(#{instance_id}, #{user_name})").succeeds do
26
- service.delete_user(instance_id, user_name)
25
+ tests("#delete_user(#{instance_id}, #{user_name})").returns(202) do
26
+ service.delete_user(instance_id, user_name).status
27
27
  end
28
28
  end
29
29
 
@@ -41,7 +41,7 @@ Shindo.tests('Fog::Rackspace::Identity | users', ['rackspace']) do
41
41
 
42
42
  service = Fog::Rackspace::Identity.new
43
43
  id = nil
44
- username = 'foguser'
44
+ username = "fog#{Time.now.to_i.to_s}"
45
45
  email = 'fog_user@example.com'
46
46
  enabled = true
47
47
  password = 'Fog_password1'
@@ -57,6 +57,9 @@ Shindo.tests('Fog::Rackspace::Identity | users', ['rackspace']) do
57
57
  service.delete_user(id)
58
58
  end
59
59
 
60
+ # there appears to be a werid caching issue. It's just easier to create a new username and continue on
61
+ username = "fog#{Time.now.to_i.to_s}"
62
+
60
63
  tests('#create_user with password').succeeds do
61
64
  data = service.create_user(username, email, enabled, :password => password ).body
62
65
  id = data['user']['id']
@@ -6,11 +6,13 @@ Shindo.tests('Fog::Rackspace::LoadBalancers | usage', ['rackspace']) do
6
6
  tests('success') do
7
7
 
8
8
  tests("#get_usage()").formats(USAGE_FORMAT) do
9
- @service.get_usage.body
9
+ pending
10
+ # @service.get_usage.body
10
11
  end
11
12
 
12
13
  tests("#get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11')").formats(USAGE_FORMAT) do
13
- @service.get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11').body
14
+ pending
15
+ # @service.get_usage(:start_time => '2010-05-10', :end_time => '2010-05-11').body
14
16
  end
15
17
  end
16
18
  end
@@ -1,106 +1,350 @@
1
- Shindo.tests('Fog::Storage[:rackspace] | large object requests', ["rackspace"]) do
1
+ Shindo.tests('Fog::Storage[:rackspace] | large object requests', ['rackspace']) do
2
2
 
3
3
  unless Fog.mocking?
4
- @directory = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests')
4
+ @directory = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests')
5
5
  @directory2 = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests2')
6
+ @segments = {
7
+ :a => {
8
+ :container => @directory.identity,
9
+ :name => 'fog_large_object/a',
10
+ :data => 'a' * (1024**2 + 10),
11
+ :size => 1024**2 + 10,
12
+ :etag => 'c2e97007d59f0c19b850debdcb80cca5'
13
+ },
14
+ :b => {
15
+ :container => @directory.identity,
16
+ :name => 'fog_large_object/b',
17
+ :data => 'b' * (1024**2 + 20),
18
+ :size => 1024**2 + 20,
19
+ :etag => 'd35f50622a1259daad75ff7d5512c7ef'
20
+ },
21
+ :c => {
22
+ :container => @directory.identity,
23
+ :name => 'fog_large_object2/a',
24
+ :data => 'c' * (1024**2 + 30),
25
+ :size => 1024**2 + 30,
26
+ :etag => '901d3531a87d188041d4d5b43cb464c1'
27
+ },
28
+ :d => {
29
+ :container => @directory2.identity,
30
+ :name => 'fog_large_object2/b',
31
+ :data => 'd' * (1024**2 + 40),
32
+ :size => 1024**2 + 40,
33
+ :etag => '350c0e00525198813920a157df185c8d'
34
+ }
35
+ }
6
36
  end
7
37
 
8
38
  tests('success') do
9
39
 
10
- tests("#put_object('foglargeobjecttests', 'fog_large_object/1', ('x' * 4 * 1024 * 1024))").succeeds do
40
+ tests('upload test segments').succeeds do
11
41
  pending if Fog.mocking?
12
- Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/1', ('x' * 4 * 1024 * 1024))
42
+
43
+ @segments.each_value do |segment|
44
+ Fog::Storage[:rackspace].put_object(segment[:container], segment[:name], segment[:data])
45
+ end
13
46
  end
14
47
 
15
- tests("#put_object('foglargeobjecttests', 'fog_large_object/2', ('x' * 2 * 1024 * 1024))").succeeds do
48
+ tests('dynamic large object requests') do
16
49
  pending if Fog.mocking?
17
- Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/2', ('x' * 2 * 1024 * 1024))
50
+
51
+ tests('#put_object_manifest alias').succeeds do
52
+ Fog::Storage[:rackspace].put_object_manifest(@directory.identity, 'fog_large_object')
53
+ end
54
+
55
+ tests('using default X-Object-Manifest header') do
56
+
57
+ tests('#put_dynamic_obj_manifest').succeeds do
58
+ Fog::Storage[:rackspace].put_dynamic_obj_manifest(@directory.identity, 'fog_large_object')
59
+ end
60
+
61
+ tests('#get_object streams all segments matching the default prefix').succeeds do
62
+ expected = @segments[:a][:data] + @segments[:b][:data] + @segments[:c][:data]
63
+ Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == expected
64
+ end
65
+
66
+ # When the manifest object name is equal to the segment prefix, OpenStack treats it as if it's the first segment.
67
+ # So you must prepend the manifest object's Etag - Digest::MD5.hexdigest('')
68
+ tests('#head_object returns Etag that includes manifest object in calculation').succeeds do
69
+ etags = ['d41d8cd98f00b204e9800998ecf8427e', @segments[:a][:etag], @segments[:b][:etag], @segments[:c][:etag]]
70
+ expected = "\"#{ Digest::MD5.hexdigest(etags.join) }\"" # returned in quotes "\"2577f38428e895c50de6ea78ccc7da2a"\"
71
+ Fog::Storage[:rackspace].head_object(@directory.identity, 'fog_large_object').headers['Etag'] == expected
72
+ end
73
+
74
+ end
75
+
76
+ tests('specifying X-Object-Manifest segment prefix') do
77
+
78
+ tests('#put_dynamic_obj_manifest').succeeds do
79
+ options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
80
+ Fog::Storage[:rackspace].put_dynamic_obj_manifest(@directory.identity, 'fog_large_object', options)
81
+ end
82
+
83
+ tests('#get_object streams segments only matching the specified prefix').succeeds do
84
+ expected = @segments[:a][:data] + @segments[:b][:data]
85
+ Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == expected
86
+ end
87
+
88
+ tests('#head_object returns Etag that does not include manifest object in calculation').succeeds do
89
+ etags = [@segments[:a][:etag], @segments[:b][:etag]]
90
+ expected = "\"#{ Digest::MD5.hexdigest(etags.join) }\"" # returned in quotes "\"0f035ed3cc38aa0ef46dda3478fad44d"\"
91
+ Fog::Storage[:rackspace].head_object(@directory.identity, 'fog_large_object').headers['Etag'] == expected
92
+ end
93
+
94
+ end
95
+
96
+ tests('storing manifest in a different container than the segments') do
97
+
98
+ tests('#put_dynamic_obj_manifest').succeeds do
99
+ options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
100
+ Fog::Storage[:rackspace].put_dynamic_obj_manifest(@directory2.identity, 'fog_large_object', options)
101
+ end
102
+
103
+ tests('#get_object').succeeds do
104
+ expected = @segments[:a][:data] + @segments[:b][:data]
105
+ Fog::Storage[:rackspace].get_object(@directory2.identity, 'fog_large_object').body == expected
106
+ end
107
+
108
+ end
109
+
18
110
  end
19
111
 
20
- tests("#put_object('foglargeobjecttests', 'fog_large_object2/1', ('x' * 1 * 1024 * 1024))").succeeds do
112
+ tests('static large object requests') do
21
113
  pending if Fog.mocking?
22
- Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object2/1', ('x' * 1 * 1024 * 1024))
23
- end
24
114
 
25
- tests("using default X-Object-Manifest header") do
115
+ tests('single container') do
116
+
117
+ tests('#put_static_obj_manifest').succeeds do
118
+ segments = [
119
+ { :path => "#{ @segments[:a][:container] }/#{ @segments[:a][:name] }",
120
+ :etag => @segments[:a][:etag],
121
+ :size_bytes => @segments[:a][:size] },
122
+ { :path => "#{ @segments[:c][:container] }/#{ @segments[:c][:name] }",
123
+ :etag => @segments[:c][:etag],
124
+ :size_bytes => @segments[:c][:size] }
125
+ ]
126
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory.identity, 'fog_large_object', segments)
127
+ end
128
+
129
+ tests('#head_object') do
130
+ etags = [@segments[:a][:etag], @segments[:c][:etag]]
131
+ etag = "\"#{ Digest::MD5.hexdigest(etags.join) }\"" # "\"ad7e633a12e8a4915b45e6dd1d4b0b4b\""
132
+ content_length = (@segments[:a][:size] + @segments[:c][:size]).to_s
133
+ response = Fog::Storage[:rackspace].head_object(@directory.identity, 'fog_large_object')
134
+
135
+ returns(etag, 'returns ETag computed from segments') { response.headers['Etag'] }
136
+ returns(content_length , 'returns Content-Length for all segments') { response.headers['Content-Length'] }
137
+ returns('True', 'returns X-Static-Large-Object header') { response.headers['X-Static-Large-Object'] }
138
+ end
139
+
140
+ tests('#get_object').succeeds do
141
+ expected = @segments[:a][:data] + @segments[:c][:data]
142
+ Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == expected
143
+ end
144
+
145
+ tests('#delete_static_large_object') do
146
+ expected = {
147
+ 'Number Not Found' => 0,
148
+ 'Response Status' => '200 OK',
149
+ 'Errors' => [],
150
+ 'Number Deleted' => 3,
151
+ 'Response Body' => ''
152
+ }
153
+ returns(expected, 'deletes manifest and segments') do
154
+ Fog::Storage[:rackspace].delete_static_large_object(@directory.identity, 'fog_large_object').body
155
+ end
156
+ end
26
157
 
27
- tests("#put_object_manifest('foglargeobjecttests', 'fog_large_object')").succeeds do
28
- pending if Fog.mocking?
29
- Fog::Storage[:rackspace].put_object_manifest(@directory.identity, 'fog_large_object')
30
158
  end
31
159
 
32
- tests("#get_object streams all segments matching the default prefix").succeeds do
33
- pending if Fog.mocking?
34
- Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == ('x' * 7 * 1024 * 1024)
160
+ tests('multiple containers') do
161
+
162
+ tests('#put_static_obj_manifest').succeeds do
163
+ segments = [
164
+ { :path => "#{ @segments[:b][:container] }/#{ @segments[:b][:name] }",
165
+ :etag => @segments[:b][:etag],
166
+ :size_bytes => @segments[:b][:size] },
167
+ { :path => "#{ @segments[:d][:container] }/#{ @segments[:d][:name] }",
168
+ :etag => @segments[:d][:etag],
169
+ :size_bytes => @segments[:d][:size] }
170
+ ]
171
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory2.identity, 'fog_large_object', segments)
172
+ end
173
+
174
+ tests('#head_object') do
175
+ etags = [@segments[:b][:etag], @segments[:d][:etag]]
176
+ etag = "\"#{ Digest::MD5.hexdigest(etags.join) }\"" # "\"9801a4cc4472896a1e975d03f0d2c3f8\""
177
+ content_length = (@segments[:b][:size] + @segments[:d][:size]).to_s
178
+ response = Fog::Storage[:rackspace].head_object(@directory2.identity, 'fog_large_object')
179
+
180
+ returns(etag, 'returns ETag computed from segments') { response.headers['Etag'] }
181
+ returns(content_length , 'returns Content-Length for all segments') { response.headers['Content-Length'] }
182
+ returns('True', 'returns X-Static-Large-Object header') { response.headers['X-Static-Large-Object'] }
183
+ end
184
+
185
+ tests('#get_object').succeeds do
186
+ expected = @segments[:b][:data] + @segments[:d][:data]
187
+ Fog::Storage[:rackspace].get_object(@directory2.identity, 'fog_large_object').body == expected
188
+ end
189
+
190
+ tests('#delete_static_large_object') do
191
+ expected = {
192
+ 'Number Not Found' => 0,
193
+ 'Response Status' => '200 OK',
194
+ 'Errors' => [],
195
+ 'Number Deleted' => 3,
196
+ 'Response Body' => ''
197
+ }
198
+ returns(expected, 'deletes manifest and segments') do
199
+ Fog::Storage[:rackspace].delete_static_large_object(@directory2.identity, 'fog_large_object').body
200
+ end
201
+ end
202
+
35
203
  end
36
204
 
37
- tests("#head_object returns Etag that includes manifest object in calculation").succeeds do
38
- pending if Fog.mocking?
205
+ end
39
206
 
40
- etags = []
41
- # When the manifest object name is equal to the prefix, OpenStack treats it as if it's the first segment.
42
- etags << Digest::MD5.hexdigest('') # Etag for manifest object => "d41d8cd98f00b204e9800998ecf8427e"
43
- etags << Digest::MD5.hexdigest('x' * 4 * 1024 * 1024) # => "44981362d3ba9b5bacaf017c2f29d355"
44
- etags << Digest::MD5.hexdigest('x' * 2 * 1024 * 1024) # => "67b2f816a30e8956149b2d7beb479e51"
45
- etags << Digest::MD5.hexdigest('x' * 1 * 1024 * 1024) # => "b561f87202d04959e37588ee05cf5b10"
46
- expected = Digest::MD5.hexdigest(etags.join) # => "42e92048bd2c8085e7072b0b55fd76ab"
47
- actual = Fog::Storage[:rackspace].head_object(@directory.identity, 'fog_large_object').headers['Etag']
48
- actual.gsub('"', '') == expected # actual is returned in quotes "\"42e92048bd2c8085e7072b0b55fd76abu"\"
207
+ end
208
+
209
+ tests('failure') do
210
+
211
+ tests('dynamic large object requests') do
212
+ pending if Fog.mocking?
213
+
214
+ tests('#put_dynamic_obj_manifest with missing container').raises(Fog::Storage::Rackspace::NotFound) do
215
+ Fog::Storage[:rackspace].put_dynamic_obj_manifest('fognoncontainer', 'fog_large_object')
49
216
  end
50
217
 
51
218
  end
52
219
 
53
- tests("specifying X-Object-Manifest segment prefix") do
220
+ tests('static large object requests') do
221
+ pending if Fog.mocking?
54
222
 
55
- tests("#put_object_manifest('foglargeobjecttests', 'fog_large_object', {'X-Object-Manifest' => 'foglargeobjecttests/fog_large_object/')").succeeds do
56
- pending if Fog.mocking?
57
- Fog::Storage[:rackspace].put_object_manifest(@directory.identity, 'fog_large_object', {'X-Object-Manifest' => "#{@directory.identity}/fog_large_object/"})
223
+ tests('upload test segments').succeeds do
224
+ Fog::Storage[:rackspace].put_object(@segments[:a][:container], @segments[:a][:name], @segments[:a][:data])
225
+ Fog::Storage[:rackspace].put_object(@segments[:b][:container], @segments[:b][:name], @segments[:b][:data])
58
226
  end
59
227
 
60
- tests("#get_object streams segments only matching the specified prefix").succeeds do
61
- pending if Fog.mocking?
62
- Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == ('x' * 6 * 1024 * 1024)
228
+ tests('#put_static_obj_manifest with missing container').raises(Fog::Storage::Rackspace::NotFound) do
229
+ Fog::Storage[:rackspace].put_static_obj_manifest('fognoncontainer', 'fog_large_object', [])
63
230
  end
64
231
 
65
- tests("#head_object returns Etag that does not include manifest object in calculation").succeeds do
66
- pending if Fog.mocking?
232
+ tests('#put_static_obj_manifest with missing object') do
233
+ segments = [
234
+ { :path => "#{ @segments[:c][:container] }/#{ @segments[:c][:name] }",
235
+ :etag => @segments[:c][:etag],
236
+ :size_bytes => @segments[:c][:size] }
237
+ ]
238
+ expected = { 'Errors' => [[segments[0][:path], '404 Not Found']] }
239
+
240
+ error = nil
241
+ begin
242
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory.identity, 'fog_large_object', segments)
243
+ rescue => err
244
+ error = err
245
+ end
67
246
 
68
- etags = []
69
- etags << Digest::MD5.hexdigest('x' * 4 * 1024 * 1024) # => "44981362d3ba9b5bacaf017c2f29d355"
70
- etags << Digest::MD5.hexdigest('x' * 2 * 1024 * 1024) # => "67b2f816a30e8956149b2d7beb479e51"
71
- expected = Digest::MD5.hexdigest(etags.join) # => "0b348495a774eaa4d4c4bbf770820f84"
72
- actual = Fog::Storage[:rackspace].head_object(@directory.identity, 'fog_large_object').headers['Etag']
73
- actual.gsub('"', '') == expected # actual is returned in quotes "\"0b348495a774eaa4d4c4bbf770820f84"\"
247
+ raises(Fog::Storage::Rackspace::BadRequest) do
248
+ raise error if error
249
+ end
250
+
251
+ expected['Errors'][0][0] = error.response_data['Errors'][0][0] rescue nil
252
+ returns(expected, 'returns error information') do
253
+ error.response_data
254
+ end
74
255
  end
75
256
 
76
- end
257
+ tests('#put_static_obj_manifest with invalid etag') do
258
+ segments = [
259
+ { :path => "#{ @segments[:a][:container] }/#{ @segments[:a][:name] }",
260
+ :etag => @segments[:b][:etag],
261
+ :size_bytes => @segments[:a][:size] }
262
+ ]
263
+ expected = { 'Errors' => [[segments[0][:path], 'Etag Mismatch']] }
77
264
 
78
- tests("storing manifest object in a different container than the segments") do
265
+ error = nil
266
+ begin
267
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory.identity, 'fog_large_object', segments)
268
+ rescue => err
269
+ error = err
270
+ end
79
271
 
80
- tests("#put_object_manifest('foglargeobjecttests2', 'fog_large_object', {'X-Object-Manifest' => 'foglargeobjecttests/fog_large_object/'})").succeeds do
81
- pending if Fog.mocking?
82
- Fog::Storage[:rackspace].put_object_manifest(@directory2.identity, 'fog_large_object', {'X-Object-Manifest' => "#{@directory.identity}/fog_large_object/"})
272
+ raises(Fog::Storage::Rackspace::BadRequest) do
273
+ raise error if error
274
+ end
275
+
276
+ expected['Errors'][0][0] = error.response_data['Errors'][0][0] rescue nil
277
+ returns(expected, 'returns error information') do
278
+ error.response_data
279
+ end
83
280
  end
84
281
 
85
- tests("#get_object('foglargeobjecttests2', 'fog_large_object').body").succeeds do
86
- pending if Fog.mocking?
87
- Fog::Storage[:rackspace].get_object(@directory2.identity, 'fog_large_object').body == ('x' * 6 * 1024 * 1024)
282
+ tests('#put_static_obj_manifest with invalid byte_size') do
283
+ segments = [
284
+ { :path => "#{ @segments[:a][:container] }/#{ @segments[:a][:name] }",
285
+ :etag => @segments[:a][:etag],
286
+ :size_bytes => @segments[:b][:size] }
287
+ ]
288
+ expected = { 'Errors' => [[segments[0][:path], 'Size Mismatch']] }
289
+
290
+ error = nil
291
+ begin
292
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory.identity, 'fog_large_object', segments)
293
+ rescue => err
294
+ error = err
295
+ end
296
+
297
+ raises(Fog::Storage::Rackspace::BadRequest) do
298
+ raise error if error
299
+ end
300
+
301
+ expected['Errors'][0][0] = error.response_data['Errors'][0][0] rescue nil
302
+ returns(expected, 'returns error information') do
303
+ error.response_data
304
+ end
88
305
  end
89
306
 
90
- end
307
+ tests('#delete_static_large_object with missing container').raises(Fog::Storage::Rackspace::NotFound) do
308
+ Fog::Storage[:rackspace].delete_static_large_object('fognoncontainer', 'fog_large_object')
309
+ end
91
310
 
92
- unless Fog.mocking?
93
- ['fog_large_object', 'fog_large_object/1', 'fog_large_object/2', 'fog_large_object2/1'].each do |key|
94
- @directory.files.new(:key => key).destroy
311
+ tests('#delete_static_large_object with missing manifest').raises(Fog::Storage::Rackspace::NotFound) do
312
+ Fog::Storage[:rackspace].delete_static_large_object(@directory.identity, 'fog_non_object')
95
313
  end
96
- @directory2.files.new(:key => 'fog_large_object').destroy
97
- end
98
314
 
99
- end
315
+ tests('#delete_static_large_object with missing segment') do
100
316
 
101
- tests('failure') do
317
+ tests('#put_static_obj_manifest for segments :a and :b').succeeds do
318
+ segments = [
319
+ { :path => "#{ @segments[:a][:container] }/#{ @segments[:a][:name] }",
320
+ :etag => @segments[:a][:etag],
321
+ :size_bytes => @segments[:a][:size] },
322
+ { :path => "#{ @segments[:b][:container] }/#{ @segments[:b][:name] }",
323
+ :etag => @segments[:b][:etag],
324
+ :size_bytes => @segments[:b][:size] }
325
+ ]
326
+ Fog::Storage[:rackspace].put_static_obj_manifest(@directory.identity, 'fog_large_object', segments)
327
+ end
328
+
329
+ tests('#delete_object segment :b').succeeds do
330
+ Fog::Storage[:rackspace].delete_object(@segments[:b][:container], @segments[:b][:name])
331
+ end
102
332
 
103
- tests("put_object_manifest")
333
+ tests('#delete_static_large_object') do
334
+ expected = {
335
+ 'Number Not Found' => 1,
336
+ 'Response Status' => '200 OK',
337
+ 'Errors' => [],
338
+ 'Number Deleted' => 2,
339
+ 'Response Body' => ''
340
+ }
341
+ returns(expected, 'deletes manifest and segment :a, and reports missing segment :b') do
342
+ Fog::Storage[:rackspace].delete_static_large_object(@directory.identity, 'fog_large_object').body
343
+ end
344
+ end
345
+
346
+ end
347
+ end
104
348
 
105
349
  end
106
350