fog 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/.gitignore +2 -2
  2. data/README.md +9 -10
  3. data/Rakefile +15 -299
  4. data/changelog.txt +153 -0
  5. data/docs/about/contributing.markdown +1 -0
  6. data/docs/dns/index.markdown +1 -1
  7. data/docs/index.markdown +8 -3
  8. data/fog.gemspec +3 -3
  9. data/lib/fog.rb +0 -5
  10. data/lib/fog/aws/auto_scaling.rb +1 -1
  11. data/lib/fog/aws/cloud_watch.rb +1 -1
  12. data/lib/fog/aws/compute.rb +2 -1
  13. data/lib/fog/aws/dynamodb.rb +30 -64
  14. data/lib/fog/aws/elb.rb +1 -1
  15. data/lib/fog/aws/glacier.rb +1 -1
  16. data/lib/fog/aws/iam.rb +1 -0
  17. data/lib/fog/aws/models/auto_scaling/group.rb +1 -1
  18. data/lib/fog/aws/models/compute/server.rb +2 -0
  19. data/lib/fog/aws/models/compute/volume.rb +0 -1
  20. data/lib/fog/aws/models/iam/user.rb +1 -1
  21. data/lib/fog/aws/parsers/compute/describe_instances.rb +3 -1
  22. data/lib/fog/aws/parsers/compute/describe_reserved_instances_offerings.rb +1 -1
  23. data/lib/fog/aws/parsers/storage/delete_multiple_objects.rb +50 -0
  24. data/lib/fog/aws/rds.rb +2 -2
  25. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  26. data/lib/fog/aws/requests/compute/describe_reserved_instances_offerings.rb +11 -8
  27. data/lib/fog/aws/requests/compute/modify_volume_attribute.rb +51 -0
  28. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +1 -0
  29. data/lib/fog/aws/requests/storage/delete_multiple_objects.rb +172 -0
  30. data/lib/fog/aws/signaturev4.rb +1 -1
  31. data/lib/fog/aws/sqs.rb +1 -1
  32. data/lib/fog/aws/storage.rb +2 -0
  33. data/lib/fog/bluebox/requests/compute/create_block.rb +1 -3
  34. data/lib/fog/brightbox/compute.rb +239 -84
  35. data/lib/fog/brightbox/models/compute/account.rb +9 -3
  36. data/lib/fog/brightbox/models/compute/server.rb +2 -1
  37. data/lib/fog/brightbox/models/compute/servers.rb +33 -1
  38. data/lib/fog/brightbox/oauth2.rb +164 -0
  39. data/lib/fog/brightbox/requests/compute/activate_console_server.rb +9 -2
  40. data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +11 -2
  41. data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +11 -2
  42. data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +9 -11
  43. data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +11 -2
  44. data/lib/fog/brightbox/requests/compute/create_api_client.rb +11 -2
  45. data/lib/fog/brightbox/requests/compute/create_application.rb +11 -2
  46. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +11 -1
  47. data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +13 -2
  48. data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +17 -2
  49. data/lib/fog/brightbox/requests/compute/create_image.rb +18 -2
  50. data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +14 -2
  51. data/lib/fog/brightbox/requests/compute/create_server.rb +17 -2
  52. data/lib/fog/brightbox/requests/compute/create_server_group.rb +11 -2
  53. data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +9 -2
  54. data/lib/fog/brightbox/requests/compute/destroy_application.rb +9 -2
  55. data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +9 -2
  56. data/lib/fog/brightbox/requests/compute/destroy_firewall_policy.rb +9 -2
  57. data/lib/fog/brightbox/requests/compute/destroy_firewall_rule.rb +9 -2
  58. data/lib/fog/brightbox/requests/compute/destroy_image.rb +9 -2
  59. data/lib/fog/brightbox/requests/compute/destroy_load_balancer.rb +9 -2
  60. data/lib/fog/brightbox/requests/compute/destroy_server.rb +9 -2
  61. data/lib/fog/brightbox/requests/compute/destroy_server_group.rb +9 -2
  62. data/lib/fog/brightbox/requests/compute/get_account.rb +7 -15
  63. data/lib/fog/brightbox/requests/compute/get_api_client.rb +9 -2
  64. data/lib/fog/brightbox/requests/compute/get_application.rb +9 -2
  65. data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +1 -3
  66. data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +9 -2
  67. data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +9 -2
  68. data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +9 -2
  69. data/lib/fog/brightbox/requests/compute/get_image.rb +9 -2
  70. data/lib/fog/brightbox/requests/compute/get_interface.rb +9 -2
  71. data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +9 -2
  72. data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +1 -5
  73. data/lib/fog/brightbox/requests/compute/get_server.rb +9 -2
  74. data/lib/fog/brightbox/requests/compute/get_server_group.rb +9 -2
  75. data/lib/fog/brightbox/requests/compute/get_server_type.rb +9 -2
  76. data/lib/fog/brightbox/requests/compute/get_user.rb +7 -15
  77. data/lib/fog/brightbox/requests/compute/get_zone.rb +9 -2
  78. data/lib/fog/brightbox/requests/compute/list_accounts.rb +6 -2
  79. data/lib/fog/brightbox/requests/compute/list_api_clients.rb +8 -2
  80. data/lib/fog/brightbox/requests/compute/list_applications.rb +8 -2
  81. data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +8 -2
  82. data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +8 -2
  83. data/lib/fog/brightbox/requests/compute/list_images.rb +8 -2
  84. data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +8 -2
  85. data/lib/fog/brightbox/requests/compute/list_server_groups.rb +8 -2
  86. data/lib/fog/brightbox/requests/compute/list_server_types.rb +8 -2
  87. data/lib/fog/brightbox/requests/compute/list_servers.rb +8 -2
  88. data/lib/fog/brightbox/requests/compute/list_users.rb +8 -2
  89. data/lib/fog/brightbox/requests/compute/list_zones.rb +8 -2
  90. data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +11 -2
  91. data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +10 -12
  92. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +11 -2
  93. data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +11 -2
  94. data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +11 -2
  95. data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +9 -10
  96. data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +22 -3
  97. data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +18 -0
  98. data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +13 -1
  99. data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +9 -2
  100. data/lib/fog/brightbox/requests/compute/shutdown_server.rb +9 -2
  101. data/lib/fog/brightbox/requests/compute/snapshot_server.rb +9 -2
  102. data/lib/fog/brightbox/requests/compute/start_server.rb +9 -2
  103. data/lib/fog/brightbox/requests/compute/stop_server.rb +9 -2
  104. data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +9 -2
  105. data/lib/fog/brightbox/requests/compute/update_account.rb +32 -34
  106. data/lib/fog/brightbox/requests/compute/update_api_client.rb +12 -2
  107. data/lib/fog/brightbox/requests/compute/update_application.rb +12 -2
  108. data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +13 -2
  109. data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +16 -1
  110. data/lib/fog/brightbox/requests/compute/update_image.rb +17 -2
  111. data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +15 -2
  112. data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +12 -19
  113. data/lib/fog/brightbox/requests/compute/update_server.rb +12 -2
  114. data/lib/fog/brightbox/requests/compute/update_server_group.rb +12 -2
  115. data/lib/fog/brightbox/requests/compute/update_user.rb +15 -2
  116. data/lib/fog/cloudstack/models/compute/server.rb +3 -1
  117. data/lib/fog/core.rb +1 -0
  118. data/lib/fog/core/connection.rb +1 -0
  119. data/lib/fog/google/storage.rb +13 -2
  120. data/lib/fog/libvirt/models/compute/server.rb +1 -0
  121. data/lib/fog/libvirt/requests/compute/list_domains.rb +2 -2
  122. data/lib/fog/openstack.rb +57 -58
  123. data/lib/fog/openstack/compute.rb +15 -14
  124. data/lib/fog/openstack/identity.rb +10 -2
  125. data/lib/fog/openstack/image.rb +1 -1
  126. data/lib/fog/openstack/models/compute/flavor.rb +5 -1
  127. data/lib/fog/openstack/models/compute/security_group.rb +1 -1
  128. data/lib/fog/openstack/models/compute/server.rb +5 -0
  129. data/lib/fog/openstack/models/identity/users.rb +1 -2
  130. data/lib/fog/openstack/requests/compute/create_flavor.rb +4 -1
  131. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  132. data/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
  133. data/lib/fog/openstack/requests/compute/list_tenants.rb +1 -0
  134. data/lib/fog/openstack/requests/compute/release_address.rb +13 -1
  135. data/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
  136. data/lib/fog/openstack/requests/identity/create_role.rb +1 -1
  137. data/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
  138. data/lib/fog/openstack/volume.rb +2 -1
  139. data/lib/fog/rackspace/models/compute_v2/server.rb +27 -0
  140. data/lib/fog/rackspace/models/compute_v2/servers.rb +8 -0
  141. data/lib/fog/rackspace/models/dns/record.rb +14 -1
  142. data/lib/fog/rackspace/models/storage/file.rb +68 -2
  143. data/lib/fog/rackspace/requests/compute_v2/create_server.rb +3 -0
  144. data/lib/fog/version.rb +5 -0
  145. data/lib/fog/vsphere/compute.rb +74 -8
  146. data/lib/fog/vsphere/models/compute/cluster.rb +31 -0
  147. data/lib/fog/vsphere/models/compute/clusters.rb +26 -0
  148. data/lib/fog/vsphere/models/compute/datacenter.rb +35 -0
  149. data/lib/fog/vsphere/models/compute/datacenters.rb +23 -0
  150. data/lib/fog/vsphere/models/compute/datastore.rb +24 -0
  151. data/lib/fog/vsphere/models/compute/datastores.rb +25 -0
  152. data/lib/fog/vsphere/models/compute/folder.rb +28 -0
  153. data/lib/fog/vsphere/models/compute/folders.rb +27 -0
  154. data/lib/fog/vsphere/models/compute/interface.rb +39 -0
  155. data/lib/fog/vsphere/models/compute/interfaces.rb +33 -0
  156. data/lib/fog/vsphere/models/compute/network.rb +21 -0
  157. data/lib/fog/vsphere/models/compute/networks.rb +25 -0
  158. data/lib/fog/vsphere/models/compute/resource_pool.rb +23 -0
  159. data/lib/fog/vsphere/models/compute/resource_pools.rb +26 -0
  160. data/lib/fog/vsphere/models/compute/server.rb +78 -12
  161. data/lib/fog/vsphere/models/compute/servers.rb +16 -20
  162. data/lib/fog/vsphere/models/compute/template.rb +13 -0
  163. data/lib/fog/vsphere/models/compute/templates.rb +23 -0
  164. data/lib/fog/vsphere/models/compute/volume.rb +45 -0
  165. data/lib/fog/vsphere/models/compute/volumes.rb +33 -0
  166. data/lib/fog/vsphere/requests/compute/create_vm.rb +114 -0
  167. data/lib/fog/vsphere/requests/compute/get_cluster.rb +25 -0
  168. data/lib/fog/vsphere/requests/compute/get_datacenter.rb +29 -0
  169. data/lib/fog/vsphere/requests/compute/get_datastore.rb +25 -0
  170. data/lib/fog/vsphere/requests/compute/get_folder.rb +73 -0
  171. data/lib/fog/vsphere/requests/compute/get_network.rb +25 -0
  172. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +26 -0
  173. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +62 -0
  174. data/lib/fog/vsphere/requests/compute/list_clusters.rb +37 -0
  175. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +34 -0
  176. data/lib/fog/vsphere/requests/compute/list_datastores.rb +40 -0
  177. data/lib/fog/vsphere/requests/compute/list_folders.rb +45 -0
  178. data/lib/fog/vsphere/requests/compute/list_networks.rb +38 -0
  179. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +39 -0
  180. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -166
  181. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +52 -0
  182. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +51 -0
  183. data/lib/fog/vsphere/requests/compute/vm_clone.rb +6 -8
  184. data/lib/fog/vsphere/requests/compute/vm_destroy.rb +1 -8
  185. data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +1 -2
  186. data/lib/tasks/changelog_task.rb +98 -0
  187. data/lib/tasks/documentation_task.rb +155 -0
  188. data/lib/tasks/test_task.rb +46 -0
  189. data/tests/aws/models/iam/users_tests.rb +16 -2
  190. data/tests/aws/requests/auto_scaling/notification_configuration_tests.rb +1 -0
  191. data/tests/aws/requests/auto_scaling/tag_tests.rb +1 -0
  192. data/tests/aws/requests/compute/instance_tests.rb +2 -0
  193. data/tests/aws/requests/compute/volume_tests.rb +8 -0
  194. data/tests/aws/requests/storage/object_tests.rb +18 -1
  195. data/tests/aws/requests/storage/versioning_tests.rb +70 -0
  196. data/tests/brightbox/compute_tests.rb +96 -4
  197. data/tests/brightbox/models/compute/account_tests.rb +15 -0
  198. data/tests/brightbox/oauth2_tests.rb +103 -0
  199. data/tests/brightbox/requests/compute/account_tests.rb +9 -2
  200. data/tests/brightbox/requests/compute/interface_tests.rb +18 -4
  201. data/tests/dns/models/record_tests.rb +17 -3
  202. data/tests/openstack/requests/compute/address_tests.rb +22 -19
  203. data/tests/openstack/requests/compute/flavor_tests.rb +4 -2
  204. data/tests/openstack/requests/compute/limit_tests.rb +60 -0
  205. data/tests/openstack/requests/compute/quota_tests.rb +16 -3
  206. data/tests/openstack/requests/compute/security_group_tests.rb +1 -1
  207. data/tests/rackspace/models/compute_v2/servers_tests.rb +6 -0
  208. data/tests/rackspace/models/storage/file_tests.rb +172 -0
  209. data/tests/rackspace/requests/dns/helper.rb +12 -26
  210. data/tests/vsphere/compute_tests.rb +3 -3
  211. data/tests/vsphere/models/compute/server_tests.rb +1 -2
  212. data/tests/vsphere/requests/compute/list_virtual_machines_tests.rb +5 -13
  213. data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -2
  214. metadata +59 -11
  215. data/lib/fog/vsphere/requests/compute/datacenters.rb +0 -34
  216. data/lib/fog/vsphere/requests/compute/find_vm_by_ref.rb +0 -41
  217. data/lib/fog/vsphere/requests/compute/vm_create.rb +0 -97
  218. data/tests/vsphere/requests/compute/find_vm_by_ref_tests.rb +0 -26
  219. data/tests/vsphere/requests/compute/vm_create_tests.rb +0 -20
@@ -4,12 +4,16 @@ Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do
4
4
  @iam = Fog::AWS[:iam]
5
5
  @user_one_name = 'fake_user_one'
6
6
  @user_two_name = 'fake_user_two'
7
-
7
+
8
+ @user_three_name = 'fake_user_three'
9
+ @user_three_path = '/path/to/fake_user_three/'
10
+ @user_four_name = 'fake_user_four'
11
+
8
12
  tests('#create').succeeds do
9
13
  @user_one = @iam.users.create(:id => @user_one_name)
10
14
  @user_one.id == @user_one_name
11
15
  end
12
-
16
+
13
17
  tests('#all','there is only one user').succeeds do
14
18
  @iam.users.size == 1
15
19
  end
@@ -43,6 +47,16 @@ Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do
43
47
  @iam.users.get(@user_one_name).access_keys.empty?
44
48
  end
45
49
 
50
+ tests('#create', 'assigns path').succeeds do
51
+ @user_three = @iam.users.create(:id => @user_three_name, :path => @user_three_path)
52
+ @user_three.path == @user_three_path
53
+ end
54
+
55
+ tests('#create', 'defaults path to /').succeeds do
56
+ @user_four = @iam.users.create(:id => @user_four_name)
57
+ @user_four.path == '/'
58
+ end
59
+
46
60
  tests('#destroy','an existing user').succeeds do
47
61
  @iam.users.get(@user_one_name).destroy
48
62
  end
@@ -3,6 +3,7 @@ Shindo.tests('AWS::AutoScaling | notification configuration requests', ['aws', '
3
3
  image_id = { # Ubuntu 12.04 LTS 64-bit EBS
4
4
  'ap-northeast-1' => 'ami-60c77761',
5
5
  'ap-southeast-1' => 'ami-a4ca8df6',
6
+ 'ap-southeast-2' => 'ami-fb8611c1',
6
7
  'eu-west-1' => 'ami-e1e8d395',
7
8
  'sa-east-1' => 'ami-8cd80691',
8
9
  'us-east-1' => 'ami-a29943cb',
@@ -3,6 +3,7 @@ Shindo.tests('AWS::AutoScaling | tag requests', ['aws', 'auto_scaling']) do
3
3
  image_id = { # Ubuntu 12.04 LTS 64-bit EBS
4
4
  'ap-northeast-1' => 'ami-60c77761',
5
5
  'ap-southeast-1' => 'ami-a4ca8df6',
6
+ 'ap-southeast-2' => 'ami-fb8611c1',
6
7
  'eu-west-1' => 'ami-e1e8d395',
7
8
  'sa-east-1' => 'ami-8cd80691',
8
9
  'us-east-1' => 'ami-a29943cb',
@@ -92,6 +92,7 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
92
92
  'availabilityZone' => String,
93
93
  'duration' => Integer,
94
94
  'fixedPrice' => Float,
95
+ 'offeringType' => String,
95
96
  'usagePrice' => Float,
96
97
  'productDescription' => String,
97
98
  'instanceTenancy' => String,
@@ -115,6 +116,7 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
115
116
  'fixedPrice' => Float,
116
117
  'usagePrice' => Float,
117
118
  'instanceCount' => Integer,
119
+ 'offeringType' => String,
118
120
  'productDescription' => String,
119
121
  'state' => String,
120
122
  'tagSet' => [{
@@ -136,6 +136,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
136
136
 
137
137
  Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
138
138
 
139
+ tests("#modify_volume_attribute('#{@volume_id}', true)").formats(AWS::Compute::Formats::BASIC) do
140
+ Fog::Compute[:aws].modify_volume_attribute(@volume_id, true).body
141
+ end
142
+
139
143
  tests("#delete_volume('#{@volume_id}')").formats(AWS::Compute::Formats::BASIC) do
140
144
  Fog::Compute[:aws].delete_volume(@volume_id).body
141
145
  end
@@ -156,6 +160,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
156
160
  Fog::Compute[:aws].detach_volume('vol-00000000')
157
161
  end
158
162
 
163
+ tests("#modify_volume_attribute('vol-00000000', true)").raises(Fog::Compute::AWS::NotFound) do
164
+ Fog::Compute[:aws].modify_volume_attribute('vol-00000000', true)
165
+ end
166
+
159
167
  tests("#detach_volume('#{@volume.identity}')").raises(Fog::Compute::AWS::Error) do
160
168
  Fog::Compute[:aws].detach_volume(@volume.identity)
161
169
  end
@@ -4,6 +4,14 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
4
4
 
5
5
  tests('success') do
6
6
 
7
+ @multiple_delete_format = {
8
+ 'DeleteResult' => [{
9
+ 'Deleted' => {
10
+ 'Key' => String
11
+ }
12
+ }]
13
+ }
14
+
7
15
  tests("#put_object('#{@directory.identity}', 'fog_object', lorem_file)").succeeds do
8
16
  Fog::Storage[:aws].put_object(@directory.identity, 'fog_object', lorem_file)
9
17
  end
@@ -91,12 +99,16 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
91
99
  tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
92
100
  Fog::Storage[:aws].delete_object(@directory.identity, 'fog_object')
93
101
  end
94
-
102
+
95
103
  tests("#get_object_http_url('#{@directory.identity}', 'fog_object', expiration timestamp)").returns(true) do
96
104
  object_url = Fog::Storage[:aws].get_object_http_url(@directory.identity, 'fog_object', (Time.now + 60))
97
105
  (object_url =~ /http:\/\/#{Regexp.quote(@directory.identity)}\.s3\.amazonaws\.com\/fog_object/) != nil
98
106
  end
99
107
 
108
+ tests("delete_multiple_objects('#{@directory.identity}', ['fog_object', 'fog_other_object'])").formats(@multiple_delete_format) do
109
+ Fog::Storage[:aws].delete_multiple_objects(@directory.identity, ['fog_object', 'fog_other_object']).body
110
+ end
111
+
100
112
  end
101
113
 
102
114
  tests('failure') do
@@ -137,6 +149,11 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
137
149
  Fog::Storage[:aws].delete_object('fognonbucket', 'fog_non_object')
138
150
  end
139
151
 
152
+ tests("#delete_multiple_objects('fognonbucket', ['fog_non_object'])").raises(Excon::Errors::NotFound) do
153
+ pending if Fog.mocking?
154
+ Fog::Storage[:aws].delete_multiple_objects('fognonbucket', ['fog_non_object'])
155
+ end
156
+
140
157
  tests("#put_object_acl('#{@directory.identity}', 'fog_object', 'invalid')").raises(Excon::Errors::BadRequest) do
141
158
  Fog::Storage[:aws].put_object_acl('#{@directory.identity}', 'fog_object', 'invalid')
142
159
  end
@@ -134,6 +134,75 @@ Shindo.tests('Fog::Storage[:aws] | versioning', ["aws"]) do
134
134
  end
135
135
  end
136
136
 
137
+ tests("deleting_multiple_objects('#{@aws_bucket_name}", 'file') do
138
+ clear_bucket
139
+
140
+ bucket = Fog::Storage[:aws].directories.get(@aws_bucket_name)
141
+
142
+ file_count = 5
143
+ file_names = []
144
+ files = {}
145
+ file_count.times do |id|
146
+ file_names << "file_#{id}"
147
+ files[file_names.last] = bucket.files.create(:body => 'a',
148
+ :key => file_names.last)
149
+ end
150
+
151
+ tests("deleting an object just stores a delete marker").returns(true) do
152
+ Fog::Storage[:aws].delete_multiple_objects(@aws_bucket_name,
153
+ file_names)
154
+ versions = Fog::Storage[:aws].get_bucket_object_versions(
155
+ @aws_bucket_name)
156
+ all_versions = {}
157
+ versions.body['Versions'].each do |version|
158
+ object = version[version.keys.first]
159
+ next if file_names.index(object['Key']).nil?
160
+ if !all_versions.has_key?(object['Key'])
161
+ all_versions[object['Key']] = version.has_key?('DeleteMarker')
162
+ else
163
+ all_versions[object['Key']] |= version.has_key?('DeleteMarker')
164
+ end
165
+ end
166
+ all_true = true
167
+ all_versions.values.each do |marker|
168
+ all_true = false if !marker
169
+ end
170
+ all_true
171
+ end
172
+
173
+ tests("there are two versions: the original and the delete marker").
174
+ returns(file_count*2) do
175
+ versions = Fog::Storage[:aws].get_bucket_object_versions(
176
+ @aws_bucket_name)
177
+ versions.body['Versions'].size
178
+ end
179
+
180
+ tests("deleting the delete marker makes the object available again").
181
+ returns(true) do
182
+ versions = Fog::Storage[:aws].get_bucket_object_versions(
183
+ @aws_bucket_name)
184
+ delete_markers = []
185
+ file_versions = {}
186
+ versions.body['Versions'].each do |version|
187
+ object = version[version.keys.first]
188
+ next if object['VersionId'] == files[object['Key']].version
189
+ file_versions[object['Key']] = object['VersionId']
190
+ end
191
+
192
+ Fog::Storage[:aws].delete_multiple_objects(@aws_bucket_name,
193
+ file_names,
194
+ 'versionId' => file_versions)
195
+ all_true = true
196
+ file_names.each do |file|
197
+ res = Fog::Storage[:aws].get_object(@aws_bucket_name, file)
198
+ all_true = false if res.headers['x-amz-version-id'] !=
199
+ files[file].version
200
+ end
201
+ all_true
202
+ end
203
+
204
+ end
205
+
137
206
  tests("get_bucket('#{@aws_bucket_name}'") do
138
207
  clear_bucket
139
208
 
@@ -181,6 +250,7 @@ Shindo.tests('Fog::Storage[:aws] | versioning', ["aws"]) do
181
250
  tests("#delete_object('#{@aws_bucket_name}', '#{file.key}', 'versionId' => 'bad_version'").raises(Excon::Errors::BadRequest) do
182
251
  Fog::Storage[:aws].delete_object(@aws_bucket_name, file.key, 'versionId' => '-1')
183
252
  end
253
+
184
254
  end
185
255
 
186
256
  # don't keep the bucket around
@@ -1,9 +1,101 @@
1
- Shindo.tests('Fog::Compute::Brightbox::Real', ['brightbox']) do
1
+ Shindo.tests('Fog::Compute[:brightbox]', ['brightbox']) do
2
2
 
3
- @bb = Fog::Compute::Brightbox::Real.new({})
3
+ @test_service = Fog::Compute[:brightbox]
4
4
 
5
5
  tests("#respond_to? :default_image").returns(true) do
6
- @bb.respond_to?(:default_image)
6
+ @test_service.respond_to?(:default_image)
7
7
  end
8
8
 
9
- end
9
+ end
10
+
11
+ Shindo.tests('Fog::Compute.new', ['brightbox']) do
12
+
13
+ tests("service options") do
14
+ {
15
+ :brightbox_api_url => "https://example.com",
16
+ :brightbox_auth_url => "https://example.com",
17
+ :brightbox_client_id => "app-12345",
18
+ :brightbox_secret => "12345abdef6789",
19
+ :brightbox_username => "user-12345",
20
+ :brightbox_password => "password1234",
21
+ :brightbox_account => "acc-12345",
22
+ :brightbox_access_token => "12345abdef6789",
23
+ :brightbox_refresh_token => "12345abdef6789",
24
+ :brightbox_token_management => false
25
+ }.each_pair do |option, sample|
26
+ tests("recognises :#{option}").returns(true) do
27
+ options = {:provider => "Brightbox"}
28
+ options[option] = sample
29
+ begin
30
+ Fog::Compute.new(options)
31
+ true
32
+ rescue ArgumentError
33
+ false
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ tests("automatic token management") do
40
+ service_options = {:provider => "Brightbox"}
41
+
42
+ tests("when enabled (default)") do
43
+ service_options[:brightbox_token_management] = true
44
+
45
+ tests("using bad token") do
46
+ service_options[:brightbox_access_token] = "bad-token"
47
+
48
+ tests("#request").returns(true, "returns a Hash") do
49
+ pending if Fog.mocking?
50
+ service = Fog::Compute.new(service_options)
51
+ response = service.get_authenticated_user
52
+ response.is_a?(Hash) # This is an outstanding issue, should be Excon::Response
53
+ end
54
+ end
55
+ end
56
+
57
+ tests("when disabled") do
58
+ service_options[:brightbox_token_management] = false
59
+
60
+ tests("using bad token") do
61
+ service_options[:brightbox_access_token] = "bad-token"
62
+
63
+ tests("#request").raises(Excon::Errors::Unauthorized) do
64
+ pending if Fog.mocking?
65
+ service = Fog::Compute.new(service_options)
66
+ service.get_authenticated_user
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ tests("account scoping") do
73
+ service = Fog::Compute.new(:provider => "Brightbox")
74
+ configured_account = Fog.credentials[:brightbox_account]
75
+ tests("when Fog.credentials are #{configured_account}") do
76
+ test("#scoped_account == #{configured_account}") { service.scoped_account == configured_account }
77
+ end
78
+
79
+ set_account = "acc-35791"
80
+ tests("when Compute instance is updated to #{set_account}") do
81
+ service.scoped_account = set_account
82
+ test("#scoped_account == #{set_account}") { service.scoped_account == set_account }
83
+ end
84
+
85
+ tests("when Compute instance is reset") do
86
+ service.scoped_account_reset
87
+ test("#scoped_account == #{configured_account}") { service.scoped_account == configured_account }
88
+ end
89
+
90
+ optioned_account = "acc-56789"
91
+ tests("when Compute instance created with :brightbox_account => #{optioned_account}") do
92
+ service = Fog::Compute.new(:provider => "Brightbox", :brightbox_account => optioned_account )
93
+ test("#scoped_account == #{optioned_account}") { service.scoped_account == optioned_account }
94
+ end
95
+
96
+ request_account = "acc-24680"
97
+ tests("when requested with #{request_account}") do
98
+ test("#scoped_account(#{request_account}) == #{request_account}") { service.scoped_account(request_account) == request_account }
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,15 @@
1
+ Shindo.tests("Fog::Compute[:brightbox] | Account model", ["brightbox"]) do
2
+
3
+ @account = Fog::Compute[:brightbox].account
4
+
5
+ tests("success") do
6
+
7
+ tests("#reset_ftp_password") do
8
+ pending if Fog.mocking?
9
+ test("original ftp password is blanked") { @account.library_ftp_password.nil? }
10
+ @new_password = @account.reset_ftp_password
11
+ test("new ftp password was not nil") { !@new_password.nil? }
12
+ test("new ftp password is set") { @account.library_ftp_password == @new_password }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,103 @@
1
+ Shindo.tests("Fog::Brightbox::OAuth2", ["brightbox"]) do
2
+
3
+ tests("CredentialSet") do
4
+ @client_id = "app-12345"
5
+ @client_secret = "__mashed_keys_123__"
6
+ @username = "usr-12345"
7
+ @password = "__mushed_keys_321__"
8
+ @access_token = "12efde32fdfe4989"
9
+ @refresh_token = "7894389f9074f071"
10
+
11
+ tests("with client credentials") do
12
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret)
13
+ tests("#user_details?").returns(false) { credentials.user_details? }
14
+ tests("#access_token?").returns(false) { credentials.access_token? }
15
+ tests("#refresh_token?").returns(false) { credentials.refresh_token? }
16
+ tests("#best_grant_strategy").returns(true) do
17
+ credentials.best_grant_strategy.is_a?(Fog::Brightbox::OAuth2::ClientCredentialsStrategy)
18
+ end
19
+ end
20
+
21
+ tests("with user credentials") do
22
+ options = {:username => @username, :password => @password}
23
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
24
+ tests("#user_details?").returns(true) { credentials.user_details? }
25
+ tests("#access_token?").returns(false) { credentials.access_token? }
26
+ tests("#refresh_token?").returns(false) { credentials.refresh_token? }
27
+ tests("#best_grant_strategy").returns(true) do
28
+ credentials.best_grant_strategy.is_a?(Fog::Brightbox::OAuth2::UserCredentialsStrategy)
29
+ end
30
+ end
31
+
32
+ tests("with existing tokens") do
33
+ options = {:username => @username, :access_token => @access_token, :refresh_token => @refresh_token}
34
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
35
+ tests("#user_details?").returns(false) { credentials.user_details? }
36
+ tests("#access_token?").returns(true) { credentials.access_token? }
37
+ tests("#refresh_token?").returns(true) { credentials.refresh_token? }
38
+ tests("#best_grant_strategy").returns(true) do
39
+ credentials.best_grant_strategy.is_a?(Fog::Brightbox::OAuth2::RefreshTokenStrategy)
40
+ end
41
+ end
42
+ end
43
+
44
+ tests("GrantTypeStrategy") do
45
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret)
46
+ strategy = Fog::Brightbox::OAuth2::GrantTypeStrategy.new(credentials)
47
+
48
+ tests("#respond_to? :authorization_body_data").returns(true) do
49
+ strategy.respond_to?(:authorization_body_data)
50
+ end
51
+ end
52
+
53
+ tests("ClientCredentialsStrategy") do
54
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret)
55
+ strategy = Fog::Brightbox::OAuth2::ClientCredentialsStrategy.new(credentials)
56
+
57
+ tests("#respond_to? :authorization_body_data").returns(true) do
58
+ strategy.respond_to?(:authorization_body_data)
59
+ end
60
+
61
+ tests("#authorization_body_data") do
62
+ authorization_body_data = strategy.authorization_body_data
63
+ test("grant_type == none") { authorization_body_data["grant_type"] == "none" }
64
+ test("client_id == #{@client_id}") { authorization_body_data["client_id"] == @client_id }
65
+ end
66
+ end
67
+
68
+ tests("UserCredentialsStrategy") do
69
+ options = {:username => @username, :password => @password}
70
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
71
+ strategy = Fog::Brightbox::OAuth2::UserCredentialsStrategy.new(credentials)
72
+
73
+ tests("#respond_to? :authorization_body_data").returns(true) do
74
+ strategy.respond_to?(:authorization_body_data)
75
+ end
76
+
77
+ tests("#authorization_body_data") do
78
+ authorization_body_data = strategy.authorization_body_data
79
+ test("grant_type == password") { authorization_body_data["grant_type"] == "password" }
80
+ test("client_id == #{@client_id}") { authorization_body_data["client_id"] == @client_id }
81
+ test("username == #{@username}") { authorization_body_data["username"] == @username }
82
+ test("password == #{@password}") { authorization_body_data["password"] == @password }
83
+ end
84
+ end
85
+
86
+ tests("RefreshTokenStrategy") do
87
+ refresh_token = "ab4b39dddf909"
88
+ options = {:refresh_token => refresh_token}
89
+ credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
90
+ strategy = Fog::Brightbox::OAuth2::RefreshTokenStrategy.new(credentials)
91
+
92
+ tests("#respond_to? :authorization_body_data").returns(true) do
93
+ strategy.respond_to?(:authorization_body_data)
94
+ end
95
+
96
+ tests("#authorization_body_data") do
97
+ authorization_body_data = strategy.authorization_body_data
98
+ test("grant_type == refresh_token") { authorization_body_data["grant_type"] == "refresh_token" }
99
+ test("client_id == #{@client_id}") { authorization_body_data["client_id"] == @client_id }
100
+ test("refresh_token == #{refresh_token}") { authorization_body_data["refresh_token"] == refresh_token }
101
+ end
102
+ end
103
+ end
@@ -36,9 +36,16 @@ Shindo.tests('Fog::Compute[:brightbox] | account requests', ['brightbox']) do
36
36
  formats(Brightbox::Compute::Formats::Full::ACCOUNT, false) { result }
37
37
  end
38
38
 
39
- tests("#reset_ftp_password_account") do
39
+ tests("#reset_ftp_password_scoped_account") do
40
40
  pending if Fog.mocking?
41
- result = Fog::Compute[:brightbox].reset_ftp_password_account
41
+ result = Fog::Compute[:brightbox].reset_ftp_password_scoped_account
42
+ formats(Brightbox::Compute::Formats::Full::ACCOUNT, false) { result }
43
+ test("new ftp password is visible") { ! result["library_ftp_password"].nil? }
44
+ end
45
+
46
+ tests("#reset_ftp_password_account(#{@scoped_account_identifier})") do
47
+ pending if Fog.mocking?
48
+ result = Fog::Compute[:brightbox].reset_ftp_password_account(@scoped_account_identifier)
42
49
  formats(Brightbox::Compute::Formats::Full::ACCOUNT, false) { result }
43
50
  test("new ftp password is visible") { ! result["library_ftp_password"].nil? }
44
51
  end