diff --git a/spec/aws/requests/storage/copy_object_spec.rb b/spec/aws/requests/storage/copy_object_spec.rb deleted file mode 100644 index ad2216434..000000000 --- a/spec/aws/requests/storage/copy_object_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.copy_object' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('fogcopyobjectsource') - AWS[:storage].put_object('fogcopyobjectsource', 'fog_copy_object_source', lorem_file) - AWS[:storage].put_bucket('fogcopyobjectdestination') - end - - after(:each) do - AWS[:storage].delete_object('fogcopyobjectdestination', 'fog_copy_object_destination') - AWS[:storage].delete_bucket('fogcopyobjectdestination') - AWS[:storage].delete_object('fogcopyobjectsource', 'fog_copy_object_source') - AWS[:storage].delete_bucket('fogcopyobjectsource') - end - - it 'should return proper attributes' do - actual = AWS[:storage].copy_object( - 'fogcopyobjectsource', 'fog_copy_object_source', - 'fogcopyobjectdestination', 'fog_copy_object_destination' - ) - actual.status.should == 200 - actual.body['ETag'].should be_a(String) - actual.body['LastModified'].should be_a(Time) - end - - end - describe 'failure' do - - it 'should raise a NotFound error if the source_bucket does not exist' do - lambda { - AWS[:storage].copy_object( - 'fognotabucket', 'fog_copy_object_source', - 'fogcopyobjectdestination', 'fog_copy_object_destination' - ) - }.should raise_error(Excon::Errors::NotFound) - end - - it 'should raise a NotFound error if the source_object does not exist' do - lambda { - AWS[:storage].copy_object( - 'fogcopyobjectsource', 'fog_not_an_object', - 'fogcopyobjectdestination', 'fog_copy_object_destination' - ) - }.should raise_error(Excon::Errors::NotFound) - end - - it 'should raise a NotFound error if the target_bucket does not exist' do - lambda { - AWS[:storage].copy_object( - 'fogcopyobjectsource', 'fog_copy_object_source', - 'fognotabucket', 'fog_copy_object_destination' - ) - }.should raise_error(Excon::Errors::NotFound) - end - - end - -end diff --git a/spec/aws/requests/storage/get_bucket_location_spec.rb b/spec/aws/requests/storage/get_bucket_location_spec.rb deleted file mode 100644 index 40f08fb91..000000000 --- a/spec/aws/requests/storage/get_bucket_location_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.get_bucket_location' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('foggetlocation', 'LocationConstraint' => 'EU') - end - - after(:each) do - AWS[:eu_storage].delete_bucket('foggetlocation') - end - - it 'should return proper attributes' do - actual = AWS[:storage].get_bucket_location('foggetlocation') - actual.status.should == 200 - actual.body['LocationConstraint'].should == 'EU' - end - - end - describe 'failure' do - - it 'should raise NotFound error if bucket does not exist' do - lambda { - AWS[:storage].get_bucket_location('fognotabucket') - }.should raise_error(Excon::Errors::NotFound) - end - - end -end diff --git a/spec/aws/requests/storage/get_bucket_spec.rb b/spec/aws/requests/storage/get_bucket_spec.rb deleted file mode 100644 index 1c23973d2..000000000 --- a/spec/aws/requests/storage/get_bucket_spec.rb +++ /dev/null @@ -1,114 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.get_bucket' do - describe 'success' do - - before(:all) do - AWS[:storage].put_bucket('foggetbucket') - AWS[:storage].put_object('foggetbucket', 'fog_object', lorem_file) - AWS[:storage].put_object('foggetbucket', 'fog_other_object', lorem_file) - end - - after(:all) do - AWS[:storage].delete_object('foggetbucket', 'fog_object') - AWS[:storage].delete_object('foggetbucket', 'fog_other_object') - AWS[:storage].delete_bucket('foggetbucket') - end - - it 'should return proper attributes' do - actual = AWS[:storage].get_bucket('foggetbucket') - actual.body['IsTruncated'].should == false - actual.body['Marker'].should be_nil - actual.body['MaxKeys'].should be_an(Integer) - actual.body['Name'].should be_a(String) - actual.body['Prefix'].should be_nil - actual.body['Contents'].should be_an(Array) - actual.body['Contents'].length.should == 2 - object = actual.body['Contents'].first - object['ETag'].should be_a(String) - object['Key'].should == 'fog_object' - object['LastModified'].should be_a(Time) - owner = object['Owner'] - owner['DisplayName'].should be_a(String) - owner['ID'].should be_a(String) - object['Size'].should be_an(Integer) - object['StorageClass'].should be_a(String) - end - - it 'should accept marker option' do - actual = AWS[:storage].get_bucket('foggetbucket', 'marker' => 'fog_object') - actual.body['IsTruncated'].should == false - actual.body['Marker'].should be_a(String) - actual.body['MaxKeys'].should be_an(Integer) - actual.body['Name'].should be_a(String) - actual.body['Prefix'].should be_nil - actual.body['Contents'].should be_an(Array) - actual.body['Contents'].length.should == 1 - object = actual.body['Contents'].first - object['ETag'].should be_a(String) - object['Key'].should == 'fog_other_object' - object['LastModified'].should be_a(Time) - owner = object['Owner'] - owner['DisplayName'].should be_a(String) - owner['ID'].should be_a(String) - object['Size'].should be_an(Integer) - object['StorageClass'].should be_a(String) - end - - it 'should accept max-keys option' do - actual = AWS[:storage].get_bucket('foggetbucket', 'max-keys' => 1) - actual.body['IsTruncated'].should == true - actual.body['Marker'].should be_nil - actual.body['MaxKeys'].should be_an(Integer) - actual.body['Name'].should be_a(String) - actual.body['Prefix'].should be_nil - actual.body['Contents'].should be_an(Array) - actual.body['Contents'].length.should == 1 - object = actual.body['Contents'].first - object['ETag'].should be_a(String) - object['Key'].should == 'fog_object' - object['LastModified'].should be_a(Time) - owner = object['Owner'] - owner['DisplayName'].should be_a(String) - owner['ID'].should be_a(String) - object['Size'].should be_an(Integer) - object['StorageClass'].should be_a(String) - end - - it 'should accept prefix option' do - actual = AWS[:storage].get_bucket('foggetbucket', 'prefix' => 'fog_ob') - actual.body['IsTruncated'].should == false - actual.body['Marker'].should be_nil - actual.body['MaxKeys'].should be_an(Integer) - actual.body['Name'].should be_a(String) - actual.body['Prefix'].should be_a(String) - actual.body['Contents'].should be_an(Array) - actual.body['Contents'].length.should == 1 - object = actual.body['Contents'].first - object['ETag'].should be_a(String) - object['Key'].should == 'fog_object' - object['LastModified'].should be_a(Time) - owner = object['Owner'] - owner['DisplayName'].should be_a(String) - owner['ID'].should be_a(String) - object['Size'].should be_an(Integer) - object['StorageClass'].should be_a(String) - end - - end - describe 'failure' do - - it 'should raise a NotFound error if the bucket does not exist' do - lambda { - AWS[:storage].get_bucket('fognotabucket') - }.should raise_error(Excon::Errors::NotFound) - end - - it 'should request non-subdomain buckets and raise a NotFound error' do - lambda { - AWS[:storage].get_bucket('A-invalid--name') - }.should raise_error(Excon::Errors::NotFound) - end - - end -end diff --git a/spec/aws/requests/storage/get_request_payment_spec.rb b/spec/aws/requests/storage/get_request_payment_spec.rb deleted file mode 100644 index 9b024cdba..000000000 --- a/spec/aws/requests/storage/get_request_payment_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.get_request_payment' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('foggetrequestpayment') - end - - after(:each) do - AWS[:storage].delete_bucket('foggetrequestpayment') - end - - it 'should return proper attributes' do - actual = AWS[:storage].get_request_payment('foggetrequestpayment') - actual.status.should == 200 - actual.body['Payer'].should == 'BucketOwner' - end - - end - describe 'failure' do - - it 'should raise a NotFound error if the bucket does not exist' do - lambda { - AWS[:storage].get_request_payment('fognotabucket') - }.should raise_error(Excon::Errors::NotFound) - end - - end -end diff --git a/spec/aws/requests/storage/put_request_payment_spec.rb b/spec/aws/requests/storage/put_request_payment_spec.rb deleted file mode 100644 index 394a13eb3..000000000 --- a/spec/aws/requests/storage/put_request_payment_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.put_request_payment' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('fogputrequestpayment') - end - - after(:each) do - AWS[:storage].delete_bucket('fogputrequestpayment') - end - - it 'should return proper attributes' do - actual = AWS[:storage].put_request_payment('fogputrequestpayment', 'Requester') - actual.status.should == 200 - end - - end - describe 'failure' do - - it 'should raise a NotFound error if bucket does not exist' do - lambda { - AWS[:storage].put_request_payment('fognotabucket', 'Requester') - }.should raise_error(Excon::Errors::NotFound) - end - - end -end diff --git a/tests/aws/requests/storage/bucket_tests.rb b/tests/aws/requests/storage/bucket_tests.rb index 99ec4252a..781450d06 100644 --- a/tests/aws/requests/storage/bucket_tests.rb +++ b/tests/aws/requests/storage/bucket_tests.rb @@ -2,6 +2,25 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do tests('success') do + @bucket_format = { + 'IsTruncated' => Fog::Boolean, + 'Marker' => NilClass, + 'MaxKeys' => Integer, + 'Name' => String, + 'Prefix' => NilClass, + 'Contents' => [{ + 'ETag' => String, + 'Key' => String, + 'LastModified' => Time, + 'Owner' => { + 'DisplayName' => String, + 'ID' => String + }, + 'Size' => Integer, + 'StorageClass' => String + }] + } + @service_format = { 'Buckets' => [{ 'CreationDate' => Time, @@ -21,6 +40,26 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do AWS[:storage].get_service.body end + file = AWS[:storage].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x') + + tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do + AWS[:storage].get_bucket('fogbuckettests').body + end + + file.destroy + + tests("#get_bucket_location('fogbuckettests)").formats('LocationConstraint' => NilClass) do + AWS[:storage].get_bucket_location('fogbuckettests').body + end + + tests("#get_request_payment('fogbuckettests')").formats('Payer' => String) do + AWS[:storage].get_request_payment('fogbuckettests').body + end + + tests("#put_request_payment('fogbuckettests', 'Requester')").succeeds do + AWS[:storage].put_request_payment('fogbuckettests', 'Requester') + end + tests("#delete_bucket('fogbuckettests')").succeeds do AWS[:storage].delete_bucket('fogbuckettests') end @@ -43,6 +82,22 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do @file.destroy @bucket.destroy + tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do + AWS[:storage].get_bucket('fognonbucket') + end + + tests("#get_bucket_location('fognonbucket')").raises(Excon::Errors::NotFound) do + AWS[:storage].get_bucket_location('fognonbucket') + end + + tests("#gett_request_payment('fognonbucket')").raises(Excon::Errors::NotFound) do + AWS[:storage].get_request_payment('fognonbucket') + end + + tests("#put_request_payment('fognonbucket', 'Requester')").raises(Excon::Errors::NotFound) do + AWS[:storage].put_request_payment('fognonbucket', 'Requester') + end + end end diff --git a/tests/aws/requests/storage/object_tests.rb b/tests/aws/requests/storage/object_tests.rb index d929bd103..fea405347 100644 --- a/tests/aws/requests/storage/object_tests.rb +++ b/tests/aws/requests/storage/object_tests.rb @@ -8,6 +8,12 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do AWS[:storage].put_object(@directory.identity, 'fog_object', lorem_file) end + tests("#copy_object('#{@directory.identity}', 'fog_object', '#{@directory.identity}', 'fog_other_object')").succeeds do + AWS[:storage].copy_object(@directory.identity, 'fog_object', @directory.identity, 'fog_other_object') + end + + @directory.files.get('fog_other_object').destroy + tests("#get_object('#{@directory.identity}', 'fog_object')").returns(lorem_file.read) do AWS[:storage].get_object(@directory.identity, 'fog_object').body end @@ -36,6 +42,18 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do AWS[:storage].put_object('fognonbucket', 'fog_non_object', lorem_file) end + tests("#copy_object('fognonbucket', 'fog_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do + AWS[:storage].copy_object('fognonbucket', 'fog_object', @directory.identity, 'fog_other_object') + end + + tests("#copy_object('#{@directory.identity}', 'fog_non_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do + AWS[:storage].copy_object(@directory.identity, 'fog_non_object', @directory.identity, 'fog_other_object') + end + + tests("#copy_object('#{@directory.identity}', 'fog_object', 'fognonbucket', 'fog_other_object')").raises(Excon::Errors::NotFound) do + AWS[:storage].copy_object(@directory.identity, 'fog_object', 'fognonbucket', 'fog_other_object') + end + tests("#get_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do AWS[:storage].get_object('fognonbucket', 'fog_non_object') end