fog 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +135 -0
- data/benchs/headers_split_vs_match.rb +18 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +60 -0
- data/benchs/stripping.rb +26 -0
- data/lib/fog.rb +21 -0
- data/lib/fog/aws.rb +145 -0
- data/lib/fog/aws/ec2.rb +173 -0
- data/lib/fog/aws/models/ec2/address.rb +31 -0
- data/lib/fog/aws/models/ec2/addresses.rb +36 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +35 -0
- data/lib/fog/aws/models/ec2/key_pairs.rb +36 -0
- data/lib/fog/aws/models/ec2/volume.rb +47 -0
- data/lib/fog/aws/models/ec2/volumes.rb +36 -0
- data/lib/fog/aws/models/s3/bucket.rb +77 -0
- data/lib/fog/aws/models/s3/buckets.rb +83 -0
- data/lib/fog/aws/models/s3/object.rb +76 -0
- data/lib/fog/aws/models/s3/objects.rb +97 -0
- data/lib/fog/aws/models/s3/owner.rb +18 -0
- data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
- data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
- data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
- data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
- data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
- data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
- data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
- data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
- data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
- data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
- data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
- data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
- data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
- data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
- data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
- data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
- data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
- data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +59 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +71 -0
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
- data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +65 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +53 -0
- data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +64 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +114 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +78 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +62 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +55 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
- data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +134 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +80 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +79 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +53 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +100 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +82 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
- data/lib/fog/aws/requests/s3/get_service.rb +58 -0
- data/lib/fog/aws/requests/s3/head_object.rb +61 -0
- data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
- data/lib/fog/aws/requests/s3/put_object.rb +76 -0
- data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
- data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
- data/lib/fog/aws/requests/simpledb/select.rb +29 -0
- data/lib/fog/aws/s3.rb +157 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/collection.rb +77 -0
- data/lib/fog/connection.rb +130 -0
- data/lib/fog/errors.rb +145 -0
- data/lib/fog/model.rb +72 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/spec/aws/models/s3/bucket_spec.rb +130 -0
- data/spec/aws/models/s3/buckets_spec.rb +79 -0
- data/spec/aws/models/s3/object_spec.rb +121 -0
- data/spec/aws/models/s3/objects_spec.rb +112 -0
- data/spec/aws/models/s3/owner_spec.rb +18 -0
- data/spec/aws/requests/ec2/allocate_address_spec.rb +18 -0
- data/spec/aws/requests/ec2/associate_address_spec.rb +42 -0
- data/spec/aws/requests/ec2/attach_volume_spec.rb +53 -0
- data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +26 -0
- data/spec/aws/requests/ec2/create_key_pair_spec.rb +36 -0
- data/spec/aws/requests/ec2/create_security_group_spec.rb +34 -0
- data/spec/aws/requests/ec2/create_snapshot_spec.rb +37 -0
- data/spec/aws/requests/ec2/create_volume_spec.rb +23 -0
- data/spec/aws/requests/ec2/delete_key_pair_spec.rb +21 -0
- data/spec/aws/requests/ec2/delete_security_group_spec.rb +26 -0
- data/spec/aws/requests/ec2/delete_snapshot_spec.rb +35 -0
- data/spec/aws/requests/ec2/delete_volume_spec.rb +26 -0
- data/spec/aws/requests/ec2/describe_addresses_spec.rb +38 -0
- data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +23 -0
- data/spec/aws/requests/ec2/describe_images_spec.rb +39 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +86 -0
- data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +42 -0
- data/spec/aws/requests/ec2/describe_regions_spec.rb +21 -0
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +51 -0
- data/spec/aws/requests/ec2/describe_snapshots_spec.rb +54 -0
- data/spec/aws/requests/ec2/describe_volumes_spec.rb +50 -0
- data/spec/aws/requests/ec2/detach_volume_spec.rb +43 -0
- data/spec/aws/requests/ec2/disassociate_address_spec.rb +35 -0
- data/spec/aws/requests/ec2/get_console_output_spec.rb +23 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +21 -0
- data/spec/aws/requests/ec2/release_address_spec.rb +26 -0
- data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +32 -0
- data/spec/aws/requests/ec2/run_instances_spec.rb +41 -0
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +35 -0
- data/spec/aws/requests/s3/copy_object_spec.rb +62 -0
- data/spec/aws/requests/s3/delete_bucket_spec.rb +36 -0
- data/spec/aws/requests/s3/delete_object_spec.rb +37 -0
- data/spec/aws/requests/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/requests/s3/get_bucket_spec.rb +110 -0
- data/spec/aws/requests/s3/get_object_spec.rb +45 -0
- data/spec/aws/requests/s3/get_request_payment_spec.rb +30 -0
- data/spec/aws/requests/s3/get_service_spec.rb +33 -0
- data/spec/aws/requests/s3/head_object_spec.rb +28 -0
- data/spec/aws/requests/s3/put_bucket_spec.rb +19 -0
- data/spec/aws/requests/s3/put_object_spec.rb +38 -0
- data/spec/aws/requests/s3/put_request_payment_spec.rb +29 -0
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/create_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +43 -0
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +31 -0
- data/spec/aws/requests/simpledb/list_domains_spec.rb +30 -0
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/select_spec.rb +9 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +309 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.terminate_instances' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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
|
26
|
+
describe 'failure' do
|
27
|
+
|
28
|
+
it 'should raise a BadRequest error if the instance does not exist' do
|
29
|
+
lambda {
|
30
|
+
ec2.terminate_instances('i-00000000')
|
31
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.copy_object' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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(:each) 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
|
+
end
|
31
|
+
describe 'failure' do
|
32
|
+
|
33
|
+
it 'should raise a NotFound error if the source_bucket does not exist' do
|
34
|
+
lambda {
|
35
|
+
s3.copy_object(
|
36
|
+
'fognotabucket', 'fog_copy_object_source',
|
37
|
+
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
38
|
+
)
|
39
|
+
}.should raise_error(Fog::Errors::NotFound)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should raise a NotFound error if the source_object does not exist' do
|
43
|
+
lambda {
|
44
|
+
s3.copy_object(
|
45
|
+
'fogcopyobjectsource', 'fog_not_an_object',
|
46
|
+
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
47
|
+
)
|
48
|
+
}.should raise_error(Fog::Errors::NotFound)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should raise a NotFound error if the target_bucket does not exist' do
|
52
|
+
lambda {
|
53
|
+
s3.copy_object(
|
54
|
+
'fogcopyobjectsource', 'fog_copy_object_source',
|
55
|
+
'fognotabucket', 'fog_copy_object_destination'
|
56
|
+
)
|
57
|
+
}.should raise_error(Fog::Errors::NotFound)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.delete_bucket' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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
|
+
end
|
16
|
+
describe 'failure' do
|
17
|
+
|
18
|
+
it 'should raise a NotFound error if the bucket does not exist' do
|
19
|
+
lambda {
|
20
|
+
s3.delete_bucket('fognotabucket')
|
21
|
+
}.should raise_error(Fog::Errors::NotFound)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should raise a Conflict error if the bucket is not empty' do
|
25
|
+
s3.put_bucket('fogdeletebucket')
|
26
|
+
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
27
|
+
s3.put_object('fogdeletebucket', 'fog_delete_object', file)
|
28
|
+
lambda {
|
29
|
+
s3.delete_bucket('fogdeletebucket')
|
30
|
+
}.should raise_error(Fog::Errors::Conflict)
|
31
|
+
s3.delete_object('fogdeletebucket', 'fog_delete_object')
|
32
|
+
s3.delete_bucket('fogdeletebucket')
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.delete_object' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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(:each) 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
|
+
end
|
22
|
+
describe 'failure' do
|
23
|
+
|
24
|
+
it 'should raise a NotFound error if the bucket does not exist' do
|
25
|
+
lambda {
|
26
|
+
s3.delete_object('fognotabucket', 'fog_delete_object')
|
27
|
+
}.should raise_error(Fog::Errors::NotFound)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not raise an error if the object does not exist' do
|
31
|
+
s3.put_bucket('fogdeleteobject')
|
32
|
+
s3.delete_object('fogdeleteobject', 'fog_not_an_object')
|
33
|
+
s3.delete_bucket('fogdeleteobject')
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.get_bucket_location' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
s3.put_bucket('foggetlocation', 'LocationConstraint' => 'EU')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
eu_s3.delete_bucket('foggetlocation')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return proper attributes' do
|
15
|
+
actual = s3.get_bucket_location('foggetlocation')
|
16
|
+
actual.status.should == 200
|
17
|
+
actual.body['LocationConstraint'].should == 'EU'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
describe 'failure' do
|
22
|
+
|
23
|
+
it 'should raise NotFound error if bucket does not exist' do
|
24
|
+
lambda {
|
25
|
+
s3.get_bucket_location('fognotabucket')
|
26
|
+
}.should raise_error(Fog::Errors::NotFound)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.get_bucket' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
s3.put_bucket('foggetbucket')
|
8
|
+
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
9
|
+
s3.put_object('foggetbucket', 'fog_object', file)
|
10
|
+
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
11
|
+
s3.put_object('foggetbucket', 'fog_other_object', file)
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
s3.delete_object('foggetbucket', 'fog_object')
|
16
|
+
s3.delete_object('foggetbucket', 'fog_other_object')
|
17
|
+
s3.delete_bucket('foggetbucket')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return proper attributes' do
|
21
|
+
actual = s3.get_bucket('foggetbucket')
|
22
|
+
actual.body['IsTruncated'].should == false
|
23
|
+
actual.body['Marker'].should be_a(String)
|
24
|
+
actual.body['MaxKeys'].should be_an(Integer)
|
25
|
+
actual.body['Name'].should be_a(String)
|
26
|
+
actual.body['Prefix'].should be_a(String)
|
27
|
+
actual.body['Contents'].should be_an(Array)
|
28
|
+
actual.body['Contents'].length.should == 2
|
29
|
+
object = actual.body['Contents'].first
|
30
|
+
object['ETag'].should be_a(String)
|
31
|
+
object['Key'].should == 'fog_object'
|
32
|
+
object['LastModified'].should be_a(Time)
|
33
|
+
owner = object['Owner']
|
34
|
+
owner['DisplayName'].should be_a(String)
|
35
|
+
owner['ID'].should be_a(String)
|
36
|
+
object['Size'].should be_an(Integer)
|
37
|
+
object['StorageClass'].should be_a(String)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should accept marker option' do
|
41
|
+
actual = s3.get_bucket('foggetbucket', 'marker' => 'fog_object')
|
42
|
+
actual.body['IsTruncated'].should == false
|
43
|
+
actual.body['Marker'].should be_a(String)
|
44
|
+
actual.body['MaxKeys'].should be_an(Integer)
|
45
|
+
actual.body['Name'].should be_a(String)
|
46
|
+
actual.body['Prefix'].should be_a(String)
|
47
|
+
actual.body['Contents'].should be_an(Array)
|
48
|
+
actual.body['Contents'].length.should == 1
|
49
|
+
object = actual.body['Contents'].first
|
50
|
+
object['ETag'].should be_a(String)
|
51
|
+
object['Key'].should == 'fog_other_object'
|
52
|
+
object['LastModified'].should be_a(Time)
|
53
|
+
owner = object['Owner']
|
54
|
+
owner['DisplayName'].should be_a(String)
|
55
|
+
owner['ID'].should be_a(String)
|
56
|
+
object['Size'].should be_an(Integer)
|
57
|
+
object['StorageClass'].should be_a(String)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should respect max-keys option' do
|
61
|
+
actual = s3.get_bucket('foggetbucket', 'max-keys' => 1)
|
62
|
+
actual.body['IsTruncated'].should == true
|
63
|
+
actual.body['Marker'].should be_a(String)
|
64
|
+
actual.body['MaxKeys'].should be_an(Integer)
|
65
|
+
actual.body['Name'].should be_a(String)
|
66
|
+
actual.body['Prefix'].should be_a(String)
|
67
|
+
actual.body['Contents'].should be_an(Array)
|
68
|
+
actual.body['Contents'].length.should == 1
|
69
|
+
object = actual.body['Contents'].first
|
70
|
+
object['ETag'].should be_a(String)
|
71
|
+
object['Key'].should == 'fog_object'
|
72
|
+
object['LastModified'].should be_a(Time)
|
73
|
+
owner = object['Owner']
|
74
|
+
owner['DisplayName'].should be_a(String)
|
75
|
+
owner['ID'].should be_a(String)
|
76
|
+
object['Size'].should be_an(Integer)
|
77
|
+
object['StorageClass'].should be_a(String)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should accept prefix option' do
|
81
|
+
actual = s3.get_bucket('foggetbucket', 'prefix' => 'fog_ob')
|
82
|
+
actual.body['IsTruncated'].should == false
|
83
|
+
actual.body['Marker'].should be_a(String)
|
84
|
+
actual.body['MaxKeys'].should be_an(Integer)
|
85
|
+
actual.body['Name'].should be_a(String)
|
86
|
+
actual.body['Prefix'].should be_a(String)
|
87
|
+
actual.body['Contents'].should be_an(Array)
|
88
|
+
actual.body['Contents'].length.should == 1
|
89
|
+
object = actual.body['Contents'].first
|
90
|
+
object['ETag'].should be_a(String)
|
91
|
+
object['Key'].should == 'fog_object'
|
92
|
+
object['LastModified'].should be_a(Time)
|
93
|
+
owner = object['Owner']
|
94
|
+
owner['DisplayName'].should be_a(String)
|
95
|
+
owner['ID'].should be_a(String)
|
96
|
+
object['Size'].should be_an(Integer)
|
97
|
+
object['StorageClass'].should be_a(String)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
describe 'failure' do
|
102
|
+
|
103
|
+
it 'should raise a NotFound error if the bucket does not exist' do
|
104
|
+
lambda {
|
105
|
+
s3.get_bucket('fognotabucket')
|
106
|
+
}.should raise_error(Fog::Errors::NotFound)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.get_object' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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(:each) 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['Content-Type'].should be_a(String)
|
25
|
+
actual.headers['ETag'].should be_a(String)
|
26
|
+
actual.headers['Last-Modified'].should be_a(String)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
describe 'failure' do
|
31
|
+
|
32
|
+
it 'should raise a NotFound error if the bucket does not exist' do
|
33
|
+
lambda {
|
34
|
+
s3.get_object('fognotabucket', 'fog_get_object')
|
35
|
+
}.should raise_error(Fog::Errors::NotFound)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should raise a NotFound error if the object does not exist' do
|
39
|
+
lambda {
|
40
|
+
s3.get_object('foggetobject', 'fog_not_an_object')
|
41
|
+
}.should raise_error(Fog::Errors::NotFound)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.get_request_payment' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
s3.put_bucket('foggetrequestpayment')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) 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
|
+
end
|
21
|
+
describe 'failure' do
|
22
|
+
|
23
|
+
it 'should raise a NotFound error if the bucket does not exist' do
|
24
|
+
lambda {
|
25
|
+
s3.get_request_payment('fognotabucket')
|
26
|
+
}.should raise_error(Fog::Errors::NotFound)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.get_service' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
s3.put_bucket('foggetservice')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) 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
|
33
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'S3.head_object' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
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(:each) 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
|
28
|
+
end
|