mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|storage|test] Added mock support for setting and retrieving versioning on a bucket.
This commit is contained in:
parent
e4873182e5
commit
8d78f4d135
2 changed files with 66 additions and 0 deletions
lib/fog/aws/requests/storage
|
@ -33,7 +33,37 @@ module Fog
|
|||
:query => {'versioning' => nil}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_bucket_versioning(bucket_name)
|
||||
response = Excon::Response.new
|
||||
bucket = self.data[:buckets][bucket_name]
|
||||
|
||||
if bucket
|
||||
response.status = 200
|
||||
|
||||
if bucket[:versioning]
|
||||
response.body = { 'VersioningConfiguration' => { 'Status' => bucket[:versioning] } }
|
||||
else
|
||||
response.body = { 'VersioningConfiguration' => {} }
|
||||
end
|
||||
|
||||
else
|
||||
response.status = 404
|
||||
response.body = {
|
||||
'Error' => {
|
||||
'Code' => 'NoSuchBucket',
|
||||
'Message' => 'The specified bucket does not exist',
|
||||
'BucketName' => bucket_name,
|
||||
'RequestId' => Fog::Mock.random_hex(16),
|
||||
'HostId' => Fog::Mock.random_base64(65)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,43 @@ DATA
|
|||
:query => {'versioning' => nil}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def put_bucket_versioning(bucket_name, status)
|
||||
response = Excon::Response.new
|
||||
bucket = self.data[:buckets][bucket_name]
|
||||
|
||||
if bucket
|
||||
if ['Enabled', 'Suspended'].include?(status)
|
||||
bucket[:versioning] = status
|
||||
|
||||
response.status = 200
|
||||
else
|
||||
response.status = 400
|
||||
response.body = {
|
||||
'Error' => {
|
||||
'Code' => 'MalformedXML',
|
||||
'Message' => 'The XML you provided was not well-formed or did not validate against our published schema',
|
||||
'RequestId' => Fog::Mock.random_hex(16),
|
||||
'HostId' => Fog::Mock.random_base64(65)
|
||||
}
|
||||
}
|
||||
end
|
||||
else
|
||||
response.status = 403
|
||||
response.body = {
|
||||
'Error' => {
|
||||
'Code' => 'AccessDenied',
|
||||
'Message' => 'AccessDenied',
|
||||
'RequestId' => Fog::Mock.random_hex(16),
|
||||
'HostId' => Fog::Mock.random_base64(65)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue