geemus-fog 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/.document +5 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +7 -0
  5. data/Rakefile +94 -0
  6. data/VERSION +1 -0
  7. data/benchs/fog_vs.rb +76 -0
  8. data/benchs/headers_split_vs_match.rb +18 -0
  9. data/benchs/params.rb +43 -0
  10. data/benchs/parse_vs_push.rb +60 -0
  11. data/benchs/stripping.rb +26 -0
  12. data/lib/fog/aws/ec2.rb +159 -0
  13. data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
  14. data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
  15. data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
  16. data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
  17. data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
  18. data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
  19. data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
  20. data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
  21. data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
  22. data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
  23. data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
  24. data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
  25. data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
  26. data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
  27. data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
  28. data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
  29. data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
  30. data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
  31. data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
  32. data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
  33. data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
  34. data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
  35. data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
  36. data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
  37. data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
  38. data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
  39. data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
  40. data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
  41. data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
  42. data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
  43. data/lib/fog/aws/requests/ec2/associate_address.rb +26 -0
  44. data/lib/fog/aws/requests/ec2/attach_volume.rb +32 -0
  45. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
  46. data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
  47. data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
  48. data/lib/fog/aws/requests/ec2/create_snapshot.rb +28 -0
  49. data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
  50. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
  51. data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
  52. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +24 -0
  53. data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
  54. data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
  55. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +27 -0
  56. data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
  57. data/lib/fog/aws/requests/ec2/describe_instances.rb +48 -0
  58. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
  59. data/lib/fog/aws/requests/ec2/describe_regions.rb +26 -0
  60. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
  61. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +29 -0
  62. data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
  63. data/lib/fog/aws/requests/ec2/detach_volume.rb +32 -0
  64. data/lib/fog/aws/requests/ec2/disassociate_address.rb +24 -0
  65. data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
  66. data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
  67. data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
  68. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
  69. data/lib/fog/aws/requests/ec2/run_instances.rb +74 -0
  70. data/lib/fog/aws/requests/ec2/terminate_instances.rb +31 -0
  71. data/lib/fog/aws/requests/s3/copy_object.rb +80 -0
  72. data/lib/fog/aws/requests/s3/delete_bucket.rb +49 -0
  73. data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
  74. data/lib/fog/aws/requests/s3/get_bucket.rb +92 -0
  75. data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
  76. data/lib/fog/aws/requests/s3/get_object.rb +81 -0
  77. data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
  78. data/lib/fog/aws/requests/s3/get_service.rb +58 -0
  79. data/lib/fog/aws/requests/s3/head_object.rb +61 -0
  80. data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
  81. data/lib/fog/aws/requests/s3/put_object.rb +75 -0
  82. data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
  83. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
  84. data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
  85. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
  86. data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
  87. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
  88. data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
  89. data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
  90. data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
  91. data/lib/fog/aws/requests/simpledb/select.rb +29 -0
  92. data/lib/fog/aws/s3.rb +143 -0
  93. data/lib/fog/aws/simpledb.rb +157 -0
  94. data/lib/fog/aws.rb +127 -0
  95. data/lib/fog/connection.rb +122 -0
  96. data/lib/fog/errors.rb +131 -0
  97. data/lib/fog/parser.rb +30 -0
  98. data/lib/fog/response.rb +12 -0
  99. data/lib/fog.rb +22 -0
  100. data/spec/aws/ec2/allocate_address_spec.rb +20 -0
  101. data/spec/aws/ec2/associate_address_spec.rb +22 -0
  102. data/spec/aws/ec2/attach_volume_spec.rb +33 -0
  103. data/spec/aws/ec2/authorize_security_group_ingress_spec.rb +25 -0
  104. data/spec/aws/ec2/create_key_pair_spec.rb +27 -0
  105. data/spec/aws/ec2/create_security_group_spec.rb +25 -0
  106. data/spec/aws/ec2/create_snapshot_spec.rb +27 -0
  107. data/spec/aws/ec2/create_volume_spec.rb +25 -0
  108. data/spec/aws/ec2/delete_key_pair_spec.rb +20 -0
  109. data/spec/aws/ec2/delete_security_group_spec.rb +22 -0
  110. data/spec/aws/ec2/delete_snapshot_spec.rb +25 -0
  111. data/spec/aws/ec2/delete_volume_spec.rb +22 -0
  112. data/spec/aws/ec2/describe_addresses_spec.rb +34 -0
  113. data/spec/aws/ec2/describe_availability_zones_spec.rb +25 -0
  114. data/spec/aws/ec2/describe_images_spec.rb +41 -0
  115. data/spec/aws/ec2/describe_instances_spec.rb +76 -0
  116. data/spec/aws/ec2/describe_key_pairs_spec.rb +38 -0
  117. data/spec/aws/ec2/describe_regions_spec.rb +23 -0
  118. data/spec/aws/ec2/describe_security_groups_spec.rb +47 -0
  119. data/spec/aws/ec2/describe_snapshot_spec.rb +44 -0
  120. data/spec/aws/ec2/describe_volumes_spec.rb +46 -0
  121. data/spec/aws/ec2/detach_volume_spec.rb +33 -0
  122. data/spec/aws/ec2/disassociate_address_spec.rb +23 -0
  123. data/spec/aws/ec2/get_console_output_spec.rb +22 -0
  124. data/spec/aws/ec2/reboot_instances_spec.rb +20 -0
  125. data/spec/aws/ec2/release_address_spec.rb +22 -0
  126. data/spec/aws/ec2/revoke_security_group_ingress_spec.rb +31 -0
  127. data/spec/aws/ec2/run_instances_spec.rb +43 -0
  128. data/spec/aws/ec2/terminate_instances_spec.rb +25 -0
  129. data/spec/aws/s3/copy_object_spec.rb +57 -0
  130. data/spec/aws/s3/delete_bucket_spec.rb +21 -0
  131. data/spec/aws/s3/delete_object_spec.rb +31 -0
  132. data/spec/aws/s3/get_bucket_location_spec.rb +30 -0
  133. data/spec/aws/s3/get_bucket_spec.rb +42 -0
  134. data/spec/aws/s3/get_object_spec.rb +40 -0
  135. data/spec/aws/s3/get_request_payment_spec.rb +26 -0
  136. data/spec/aws/s3/get_service_spec.rb +32 -0
  137. data/spec/aws/s3/head_object_spec.rb +27 -0
  138. data/spec/aws/s3/put_bucket_spec.rb +22 -0
  139. data/spec/aws/s3/put_object_spec.rb +34 -0
  140. data/spec/aws/s3/put_request_payment_spec.rb +25 -0
  141. data/spec/aws/simpledb/batch_put_attributes_spec.rb +21 -0
  142. data/spec/aws/simpledb/create_domain_spec.rb +20 -0
  143. data/spec/aws/simpledb/delete_attributes_spec.rb +21 -0
  144. data/spec/aws/simpledb/delete_domain_spec.rb +20 -0
  145. data/spec/aws/simpledb/domain_metadata_spec.rb +42 -0
  146. data/spec/aws/simpledb/get_attributes_spec.rb +30 -0
  147. data/spec/aws/simpledb/list_domains_spec.rb +29 -0
  148. data/spec/aws/simpledb/put_attributes_spec.rb +21 -0
  149. data/spec/aws/simpledb/select_spec.rb +7 -0
  150. data/spec/lorem.txt +1 -0
  151. data/spec/spec.opts +1 -0
  152. data/spec/spec_helper.rb +74 -0
  153. metadata +256 -0
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.describe_snapshots' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
8
+ @snapshot_id = @ec2.create_snapshot(@volume_id).body['snapshotId']
9
+ end
10
+
11
+ after(:all) do
12
+ @ec2.delete_volume(@volume_id)
13
+ eventually do
14
+ @ec2.delete_snapshot(@snapshot_id)
15
+ end
16
+ end
17
+
18
+ it "should return proper attributes with no params" do
19
+ eventually do
20
+ actual = @ec2.describe_snapshots
21
+ actual.body['snapshotSet'].should be_an(Array)
22
+ snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
23
+ snapshot['progress'].should be_a(String)
24
+ snapshot['snapshotId'].should be_a(String)
25
+ snapshot['startTime'].should be_a(Time)
26
+ snapshot['status'].should be_a(String)
27
+ snapshot['volumeId'].should be_a(String)
28
+ end
29
+ end
30
+
31
+ it "should return proper attributes with params" do
32
+ eventually do
33
+ actual = @ec2.describe_snapshots([@snapshot_id])
34
+ actual.body['snapshotSet'].should be_an(Array)
35
+ snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
36
+ snapshot['progress'].should be_a(String)
37
+ snapshot['snapshotId'].should be_a(String)
38
+ snapshot['startTime'].should be_a(Time)
39
+ snapshot['status'].should be_a(String)
40
+ snapshot['volumeId'].should be_a(String)
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.describe_volumes' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
8
+ end
9
+
10
+ after(:all) do
11
+ @ec2.delete_volume(@volume_id)
12
+ end
13
+
14
+ it "should return proper attributes with no params" do
15
+ actual = @ec2.describe_volumes
16
+ actual.body['requestId'].should be_a(String)
17
+ volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
18
+ volume['availabilityZone'].should be_a(String)
19
+ volume['createTime'].should be_a(Time)
20
+ volume['size'].should == 1
21
+ volume['snapshotId'].should == ''
22
+ volume['status'].should be_a(String)
23
+ volume['volumeId'].should == @volume_id
24
+ volume['attachmentSet'].should == []
25
+ end
26
+
27
+ it "should return proper attributes for specific volume" do
28
+ actual = @ec2.describe_volumes(@volume_id)
29
+ actual.body['requestId'].should be_a(String)
30
+ volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
31
+ volume['availabilityZone'].should be_a(String)
32
+ volume['createTime'].should be_a(Time)
33
+ volume['size'].should == 1
34
+ volume['snapshotId'].should == ''
35
+ volume['status'].should be_a(String)
36
+ volume['volumeId'].should == @volume_id
37
+ volume['attachmentSet'].should == []
38
+ end
39
+
40
+ it "should raise a BadRequest error if volume does not exist" do
41
+ lambda {
42
+ @ec2.describe_volumes('vol-00000000')
43
+ }.should raise_error(Fog::Errors::BadRequest)
44
+ end
45
+
46
+ end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.detach_volume' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
8
+ @volume_id = @ec2.create_volume('us-east-1a', 1).body['volumeId']
9
+ eventually(128) do
10
+ @ec2.attach_volume(@volume_id, @instance_id, '/dev/sdh')
11
+ end
12
+ end
13
+
14
+ after(:all) do
15
+ eventually do
16
+ @ec2.delete_volume(@volume_id)
17
+ @ec2.terminate_instances([@instance_id])
18
+ end
19
+ end
20
+
21
+ it "should return proper attributes" do
22
+ eventually do
23
+ actual = @ec2.detach_volume(@volume_id)
24
+ actual.body['attachTime'].should be_a(Time)
25
+ actual.body['device'].should be_a(String)
26
+ actual.body['instanceId'].should be_a(String)
27
+ actual.body['requestId'].should be_a(String)
28
+ actual.body['status'].should be_a(String)
29
+ actual.body['volumeId'].should be_a(String)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.disassociate_address' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
8
+ @public_ip = @ec2.allocate_address.body['publicIp']
9
+ @ec2.associate_address(@instance_id, @public_ip)
10
+ end
11
+
12
+ after(:all) do
13
+ @ec2.release_address(@public_ip)
14
+ @ec2.terminate_instances([@instance_id])
15
+ end
16
+
17
+ it "should return proper attributes" do
18
+ actual = @ec2.disassociate_address(@public_ip)
19
+ actual.body['requestId'].should be_a(String)
20
+ [false, true].should include(actual.body['return'])
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.get_console_output' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
8
+ end
9
+
10
+ after(:all) do
11
+ @ec2.terminate_instances([@instance_id])
12
+ end
13
+
14
+ it "should return proper attributes" do
15
+ actual = @ec2.get_console_output(@instance_id)
16
+ actual.body['instanceId'].should be_a(String)
17
+ actual.body['output'].should be_a(String)
18
+ actual.body['requestId'].should be_a(String)
19
+ actual.body['timestamp'].should be_a(Time)
20
+ end
21
+
22
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.reboot_instances' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
8
+ end
9
+
10
+ after(:all) do
11
+ @ec2.terminate_instances([@instance_id])
12
+ end
13
+
14
+ it "should return proper attributes" do
15
+ actual = @ec2.reboot_instances([@instance_id])
16
+ actual.body['requestId'].should be_a(String)
17
+ [false, true].should include(actual.body['return'])
18
+ end
19
+
20
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.release_address' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @public_ip = @ec2.allocate_address.body['publicIp']
8
+ end
9
+
10
+ it "should return proper attributes" do
11
+ actual = @ec2.release_address(@public_ip)
12
+ actual.body['requestId'].should be_a(String)
13
+ actual.body['return'].should == true
14
+ end
15
+
16
+ it "should raise a BadRequest error if address does not exist" do
17
+ lambda {
18
+ @ec2.release_address('127.0.0.1')
19
+ }.should raise_error(Fog::Errors::BadRequest)
20
+ end
21
+
22
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.revoke_security_group_ingress' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @ec2.create_security_group('fog_security_group', 'a security group for testing fog')
8
+ @ec2.authorize_security_group_ingress({
9
+ 'FromPort' => 80,
10
+ 'GroupName' => 'fog_security_group',
11
+ 'IpProtocol' => 'tcp',
12
+ 'ToPort' => 80
13
+ })
14
+ end
15
+
16
+ after(:all) do
17
+ @ec2.delete_security_group('fog_security_group')
18
+ end
19
+
20
+ it "should return proper attributes" do
21
+ actual = @ec2.revoke_security_group_ingress({
22
+ 'FromPort' => 80,
23
+ 'GroupName' => 'fog_security_group',
24
+ 'IpProtocol' => 'tcp',
25
+ 'ToPort' => 80
26
+ })
27
+ actual.body['requestId'].should be_a(String)
28
+ [false, true].should include(actual.body['return'])
29
+ end
30
+
31
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.run_instances' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ end
8
+
9
+ after(:all) do
10
+ @ec2.terminate_instances([@instance_id])
11
+ end
12
+
13
+ it "should return proper attributes" do
14
+ actual = @ec2.run_instances('ami-5ee70037', 1, 1)
15
+ @instance_id = actual.body['instancesSet'].first['instanceId']
16
+ actual.body['groupSet'].should be_an(Array)
17
+ actual.body['groupSet'].first.should be_a(String)
18
+ actual.body['instancesSet'].should be_an(Array)
19
+ instance = actual.body['instancesSet'].first
20
+ instance['amiLaunchIndex'].should be_a(Integer)
21
+ instance['dnsName'].should be_a(String)
22
+ instance['imageId'].should be_a(String)
23
+ instance['instanceId'].should be_a(String)
24
+ instance['instanceState'].should be_an(Hash)
25
+ instance['instanceState']['code'].should be_an(Integer)
26
+ instance['instanceState']['name'].should be_an(String)
27
+ instance['instanceType'].should be_a(String)
28
+ instance['kernelId'].should be_a(String)
29
+ instance['keyName'].should be_a(String) if instance['keyName']
30
+ instance['launchTime'].should be_a(Time)
31
+ instance['monitoring'].should be_a(Hash)
32
+ [false, true].should include(instance['monitoring']['state'])
33
+ instance['placement'].should be_a(Hash)
34
+ instance['placement']['availabilityZone'].should be_a(String)
35
+ instance['privateDnsName'].should be_a(String)
36
+ instance['ramdiskId'].should be_a(String)
37
+ instance['reason'].should be_a(String)
38
+ actual.body['ownerId'].should be_a(String)
39
+ actual.body['requestId'].should be_a(String)
40
+ actual.body['reservationId'].should be_a(String)
41
+ end
42
+
43
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'EC2.terminate_instances' do
4
+
5
+ before(:all) do
6
+ @ec2 = Fog::AWS::EC2.gen
7
+ @instance_id = @ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
8
+ end
9
+
10
+ it "should return proper attributes" do
11
+ actual = @ec2.terminate_instances([@instance_id])
12
+ actual.body['requestId'].should be_a(String)
13
+ actual.body['instancesSet'].should be_an(Array)
14
+ instance = actual.body['instancesSet'].select {|instance| instance['instanceId'] == @instance_id}.first
15
+ instance['previousState'].should be_a(Hash)
16
+ previous_state = instance['previousState']
17
+ previous_state['code'].should be_a(Integer)
18
+ previous_state['name'].should be_a(String)
19
+ instance['shutdownState'].should be_a(Hash)
20
+ shutdown_state = instance['shutdownState']
21
+ shutdown_state['code'].should be_a(Integer)
22
+ shutdown_state['name'].should be_a(String)
23
+ end
24
+
25
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.copy_object' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('fogcopyobjectsource')
8
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
9
+ @s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file)
10
+ @s3.put_bucket('fogcopyobjectdestination')
11
+ end
12
+
13
+ after(:all) do
14
+ @s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
15
+ @s3.delete_bucket('fogcopyobjectdestination')
16
+ @s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source')
17
+ @s3.delete_bucket('fogcopyobjectsource')
18
+ end
19
+
20
+ it 'should return proper attributes' do
21
+ actual = @s3.copy_object(
22
+ 'fogcopyobjectsource', 'fog_copy_object_source',
23
+ 'fogcopyobjectdestination', 'fog_copy_object_destination'
24
+ )
25
+ actual.status.should == 200
26
+ actual.body['ETag'].should be_a(String)
27
+ actual.body['LastModified'].should be_a(Time)
28
+ end
29
+
30
+ it 'should raise a NotFound error if the source_bucket does not exist' do
31
+ lambda {
32
+ @s3.copy_object(
33
+ 'fognotabucket', 'fog_copy_object_source',
34
+ 'fogcopyobjectdestination', 'fog_copy_object_destination'
35
+ )
36
+ }.should raise_error(Fog::Errors::NotFound)
37
+ end
38
+
39
+ it 'should raise a NotFound error if the source_object does not exist' do
40
+ lambda {
41
+ @s3.copy_object(
42
+ 'fogcopyobjectsource', 'fog_not_an_object',
43
+ 'fogcopyobjectdestination', 'fog_copy_object_destination'
44
+ )
45
+ }.should raise_error(Fog::Errors::NotFound)
46
+ end
47
+
48
+ it 'should raise a NotFound error if the target_bucket does not exist' do
49
+ lambda {
50
+ @s3.copy_object(
51
+ 'fogcopyobjectsource', 'fog_copy_object_source',
52
+ 'fognotabucket', 'fog_copy_object_destination'
53
+ )
54
+ }.should raise_error(Fog::Errors::NotFound)
55
+ end
56
+
57
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.delete_bucket' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('fogdeletebucket')
8
+ end
9
+
10
+ it 'should return proper attributes' do
11
+ actual = @s3.delete_bucket('fogdeletebucket')
12
+ actual.status.should == 204
13
+ end
14
+
15
+ it 'should raise a NotFound error if the bucket does not exist' do
16
+ lambda {
17
+ @s3.delete_bucket('fognotabucket')
18
+ }.should raise_error(Fog::Errors::NotFound)
19
+ end
20
+
21
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.delete_object' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('fogdeleteobject')
8
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
9
+ @s3.put_object('fogdeleteobject', 'fog_delete_object', file)
10
+ end
11
+
12
+ after(:all) do
13
+ @s3.delete_bucket('fogdeleteobject')
14
+ end
15
+
16
+ it 'should return proper attributes' do
17
+ actual = @s3.delete_object('fogdeleteobject', 'fog_delete_object')
18
+ actual.status.should == 204
19
+ end
20
+
21
+ it 'should raise NotFound error if the bucket does not exist' do
22
+ lambda {
23
+ @s3.delete_object('fognotabucket', 'fog_delete_object')
24
+ }.should raise_error(Fog::Errors::NotFound)
25
+ end
26
+
27
+ it 'should not raise an error if the object does not exist' do
28
+ @s3.delete_object('fogdeleteobject', 'fog_not_an_object')
29
+ end
30
+
31
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.get_bucket_location' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @eu_s3 = Fog::AWS::S3.gen(:eu)
8
+ @s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
9
+ end
10
+
11
+ after(:all) do
12
+ if Fog.mocking?
13
+ @eu_s3.data = @s3.data
14
+ end
15
+ @eu_s3.delete_bucket('foggetlocation')
16
+ end
17
+
18
+ it 'should return proper attributes' do
19
+ actual = @s3.get_bucket_location('foggetlocation')
20
+ actual.status.should == 200
21
+ actual.body['LocationConstraint'].should == 'EU'
22
+ end
23
+
24
+ it 'should raise NotFound error if bucket does not exist' do
25
+ lambda {
26
+ @s3.get_bucket_location('fognotabucket')
27
+ }.should raise_error(Fog::Errors::NotFound)
28
+ end
29
+
30
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.get_bucket' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('foggetbucket')
8
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
9
+ @s3.put_object('foggetbucket', 'fog_get_bucket', file)
10
+ end
11
+
12
+ after(:all) do
13
+ @s3.delete_object('foggetbucket', 'fog_get_bucket')
14
+ @s3.delete_bucket('foggetbucket')
15
+ end
16
+
17
+ it 'should return proper attributes' do
18
+ actual = @s3.get_bucket('foggetbucket')
19
+ actual.body['IsTruncated'].should == false
20
+ actual.body['Marker'].should be_a(String)
21
+ actual.body['MaxKeys'].should be_an(Integer)
22
+ actual.body['Name'].should be_a(String)
23
+ actual.body['Prefix'].should be_a(String)
24
+ actual.body['Contents'].should be_an(Array)
25
+ object = actual.body['Contents'].first
26
+ object['ETag'].should be_a(String)
27
+ object['Key'].should == 'fog_get_bucket'
28
+ object['LastModified'].should be_a(Time)
29
+ owner = object['Owner']
30
+ owner['DisplayName'].should be_a(String)
31
+ owner['ID'].should be_a(String)
32
+ object['Size'].should be_an(Integer)
33
+ object['StorageClass'].should be_a(String)
34
+ end
35
+
36
+ it 'should raise a NotFound error if the bucket does not exist' do
37
+ lambda {
38
+ @s3.get_bucket('fognotabucket')
39
+ }.should raise_error(Fog::Errors::NotFound)
40
+ end
41
+
42
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.get_object' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('foggetobject')
8
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
9
+ @s3.put_object('foggetobject', 'fog_get_object', file)
10
+ end
11
+
12
+ after(:all) do
13
+ @s3.delete_object('foggetobject', 'fog_get_object')
14
+ @s3.delete_bucket('foggetobject')
15
+ end
16
+
17
+ it 'should return proper attributes' do
18
+ actual = @s3.get_object('foggetobject', 'fog_get_object')
19
+ actual.status.should == 200
20
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
21
+ data = file.read
22
+ actual.body.should == data
23
+ actual.headers['Content-Length'].should == data.length.to_s
24
+ actual.headers['ETag'].should be_a(String)
25
+ actual.headers['Last-Modified'].should be_a(String)
26
+ end
27
+
28
+ it 'should raise a NotFound error if the bucket does not exist' do
29
+ lambda {
30
+ @s3.get_object('fognotabucket', 'fog_get_object')
31
+ }.should raise_error(Fog::Errors::NotFound)
32
+ end
33
+
34
+ it 'should raise a NotFound error if the object does not exist' do
35
+ lambda {
36
+ @s3.get_object('foggetobject', 'fog_not_an_object')
37
+ }.should raise_error(Fog::Errors::NotFound)
38
+ end
39
+
40
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.get_request_payment' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('foggetrequestpayment')
8
+ end
9
+
10
+ after(:all) do
11
+ @s3.delete_bucket('foggetrequestpayment')
12
+ end
13
+
14
+ it 'should return proper attributes' do
15
+ actual = @s3.get_request_payment('foggetrequestpayment')
16
+ actual.status.should == 200
17
+ actual.body['Payer'].should == 'BucketOwner'
18
+ end
19
+
20
+ it 'should raise a NotFound error if the bucket does not exist' do
21
+ lambda {
22
+ @s3.get_request_payment('fognotabucket')
23
+ }.should raise_error(Fog::Errors::NotFound)
24
+ end
25
+
26
+ end
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.get_service' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('foggetservice')
8
+ end
9
+
10
+ after(:all) do
11
+ @s3.delete_bucket('foggetservice')
12
+ end
13
+
14
+ it 'should return proper_attributes' do
15
+ actual = @s3.get_service
16
+ actual.body['Buckets'].should be_an(Array)
17
+ bucket = actual.body['Buckets'].select {|bucket| bucket['Name'] == 'foggetservice'}.first
18
+ bucket['CreationDate'].should be_a(Time)
19
+ bucket['Name'].should == 'foggetservice'
20
+ owner = actual.body['Owner']
21
+ owner['DisplayName'].should be_a(String)
22
+ owner['ID'].should be_a(String)
23
+ end
24
+
25
+ it 'should include foggetservice in get_service' do
26
+ eventually do
27
+ actual = @s3.get_service
28
+ actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.head_object' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ @s3.put_bucket('fogheadobject')
8
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
9
+ @s3.put_object('fogheadobject', 'fog_head_object', file)
10
+ end
11
+
12
+ after(:all) do
13
+ @s3.delete_object('fogheadobject', 'fog_head_object')
14
+ @s3.delete_bucket('fogheadobject')
15
+ end
16
+
17
+ it 'should return proper attributes' do
18
+ actual = @s3.head_object('fogheadobject', 'fog_head_object')
19
+ actual.status.should == 200
20
+ file = File.open(File.dirname(__FILE__) + '/../../lorem.txt', 'r')
21
+ data = file.read
22
+ actual.headers['Content-Length'].should == data.length.to_s
23
+ actual.headers['ETag'].should be_a(String)
24
+ actual.headers['Last-Modified'].should be_a(String)
25
+ end
26
+
27
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe 'S3.put_bucket' do
4
+
5
+ before(:all) do
6
+ @s3 = Fog::AWS::S3.gen
7
+ end
8
+
9
+ after(:all) do
10
+ @s3.delete_bucket('fogputbucket')
11
+ end
12
+
13
+ it 'should return proper attributes' do
14
+ actual = @s3.put_bucket('fogputbucket')
15
+ actual.status.should == 200
16
+ end
17
+
18
+ it 'should not raise an error if the bucket already exists' do
19
+ @s3.put_bucket('fogputbucket')
20
+ end
21
+
22
+ end