mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
removed location & payment functionality and test; All google storate mock tests green; Only directory tests green on real tests
This commit is contained in:
parent
7a8b5fda10
commit
f810d6b194
8 changed files with 1 additions and 208 deletions
|
@ -31,18 +31,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
def payer
|
||||
requires :key
|
||||
data = connection.get_request_payment(key)
|
||||
data.body['Payer']
|
||||
end
|
||||
|
||||
def payer=(new_payer)
|
||||
requires :key
|
||||
connection.put_request_payment(key, new_payer)
|
||||
@payer = new_payer
|
||||
end
|
||||
|
||||
def save
|
||||
requires :key
|
||||
options = {}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Google
|
||||
module Storage
|
||||
|
||||
class GetBucketLocation < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'LocationConstraint'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,48 +0,0 @@
|
|||
module Fog
|
||||
module Google
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
require 'fog/google/parsers/storage/get_request_payment'
|
||||
|
||||
# Get configured payer for an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to get payer for
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'Payer'<~String> - Specifies who pays for download and requests
|
||||
def get_request_payment(bucket_name)
|
||||
request({
|
||||
:expects => 200,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:idempotent => true,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Google::Storage::GetRequestPayment.new,
|
||||
:query => {'requestPayment' => nil}
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_request_payment(bucket_name)
|
||||
response = Excon::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
response.body = { 'Payer' => bucket['Payer'] }
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
module Fog
|
||||
module Google
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
# Change who pays for requests to an S3 bucket
|
||||
#
|
||||
# ==== Parameters
|
||||
# * bucket_name<~String> - name of bucket to modify
|
||||
# * payer<~String> - valid values are BucketOwner or Requester
|
||||
def put_request_payment(bucket_name, payer)
|
||||
data =
|
||||
<<-DATA
|
||||
<RequestPaymentConfiguration xmlns="http://s3.amazongoogle.com/doc/2006-03-01/">
|
||||
<Payer>#{payer}</Payer>
|
||||
</RequestPaymentConfiguration>
|
||||
DATA
|
||||
request({
|
||||
:body => data,
|
||||
:expects => 200,
|
||||
:headers => {},
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:method => 'PUT',
|
||||
:query => {'requestPayment' => nil}
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def put_request_payment(bucket_name, payer)
|
||||
response = Excon::Response.new
|
||||
if bucket = @data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
bucket['Payer'] = payer
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -23,7 +23,6 @@ module Fog
|
|||
request :get_object_acl
|
||||
request :get_object_torrent
|
||||
request :get_object_url
|
||||
request :get_request_payment
|
||||
request :get_service
|
||||
request :head_object
|
||||
request :put_bucket
|
||||
|
@ -32,7 +31,6 @@ module Fog
|
|||
request :put_bucket_versioning
|
||||
request :put_object
|
||||
request :put_object_url
|
||||
request :put_request_payment
|
||||
|
||||
module Utils
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../../lib/fog/google/models/storage/directory'
|
||||
|
||||
describe 'Fog::Google::Storage::Directory' do
|
||||
|
||||
|
@ -39,26 +40,6 @@ describe 'Fog::Google::Storage::Directory' do
|
|||
|
||||
end
|
||||
|
||||
describe "#payer" do
|
||||
|
||||
it "should return the request payment value" do
|
||||
directory = Google[:storage].directories.create(:key => 'fogmodeldirectory')
|
||||
directory.payer.should == 'BucketOwner'
|
||||
directory.destroy.should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#payer=" do
|
||||
|
||||
it "should set the request payment value" do
|
||||
directory = Google[:storage].directories.create(:key => 'fogmodeldirectory')
|
||||
(directory.payer = 'Requester').should == 'Requester'
|
||||
directory.destroy.should
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#reload" do
|
||||
|
||||
before(:each) do
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Storage.get_request_payment' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
Google[:storage].put_bucket('foggetrequestpayment')
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
Google[:storage].delete_bucket('foggetrequestpayment')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = Google[: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 {
|
||||
Google[:storage].get_request_payment('fognotabucket')
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Storage.put_request_payment' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
Google[:storage].put_bucket('fogputrequestpayment')
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
Google[:storage].delete_bucket('fogputrequestpayment')
|
||||
end
|
||||
|
||||
it 'should return proper attributes' do
|
||||
actual = Google[: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 {
|
||||
Google[:storage].put_request_payment('fognotabucket', 'Requester')
|
||||
}.should raise_error(Excon::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue