mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #577 from zimbatm/master
Thanks for the T-shirt ! (+ patch)
This commit is contained in:
commit
1fc65e8d98
3 changed files with 141 additions and 90 deletions
|
@ -15,18 +15,21 @@ DATA
|
|||
|
||||
acl['AccessControlList'].each do |grant|
|
||||
data << " <Grant>\n"
|
||||
type = case grant['Grantee'].keys.sort
|
||||
case grant['Grantee'].keys.sort
|
||||
when ['DisplayName', 'ID']
|
||||
'CanonicalUser'
|
||||
data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">\n"
|
||||
data << " <ID>#{grant['Grantee']['ID']}</ID>\n"
|
||||
data << " <DisplayName>#{grant['Grantee']['DisplayName']}</DisplayName>\n"
|
||||
data << " </Grantee>\n"
|
||||
when ['EmailAddress']
|
||||
'AmazonCustomerByEmail'
|
||||
data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"AmazonCustomerByEmail\">\n"
|
||||
data << " <EmailAddress>#{grant['Grantee']['EmailAddress']}</EmailAddress>\n"
|
||||
data << " </Grantee>\n"
|
||||
when ['URI']
|
||||
'Group'
|
||||
data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Group\">\n"
|
||||
data << " <URI>#{grant['Grantee']['URI']}</URI>\n"
|
||||
data << " </Grantee>\n"
|
||||
end
|
||||
data << " <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"#{type}\">\n"
|
||||
data << " <ID>#{grant['Grantee']['ID']}</ID>\n"
|
||||
data << " <DisplayName>#{grant['Grantee']['DisplayName']}</DisplayName>\n"
|
||||
data << " </Grantee>\n"
|
||||
data << " <Permission>#{grant['Permission']}</Permission>\n"
|
||||
data << " </Grant>\n"
|
||||
end
|
||||
|
@ -39,6 +42,6 @@ DATA
|
|||
data
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
||||
@aws_bucket_name = 'fogbuckettests-' + Time.now.to_i.to_s(32)
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
@ -33,30 +34,31 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
}
|
||||
}
|
||||
|
||||
tests("#put_bucket('fogbuckettests')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket('fogbuckettests')
|
||||
tests("#put_bucket('#{@aws_bucket_name}')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
@aws_owner = Fog::Storage[:aws].get_bucket_acl(Fog::Storage[:aws].directories.first.key).body['Owner']
|
||||
end
|
||||
|
||||
tests("#get_service").formats(@service_format) do
|
||||
Fog::Storage[:aws].get_service.body
|
||||
end
|
||||
|
||||
file = Fog::Storage[:aws].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x')
|
||||
file = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'y', :key => 'x')
|
||||
|
||||
tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
|
||||
Fog::Storage[:aws].get_bucket('fogbuckettests').body
|
||||
tests("#get_bucket('#{@aws_bucket_name}')").formats(@bucket_format) do
|
||||
Fog::Storage[:aws].get_bucket(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
file.destroy
|
||||
|
||||
file1 = Fog::Storage[:aws].directories.get('fogbuckettests').files.create(:body => 'a', :key => 'a/a1/file1')
|
||||
file2 = Fog::Storage[:aws].directories.get('fogbuckettests').files.create(:body => 'ab', :key => 'a/file2')
|
||||
file3 = Fog::Storage[:aws].directories.get('fogbuckettests').files.create(:body => 'abc', :key => 'b/file3')
|
||||
file4 = Fog::Storage[:aws].directories.get('fogbuckettests').files.create(:body => 'abcd', :key => 'file4')
|
||||
file1 = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'a', :key => 'a/a1/file1')
|
||||
file2 = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'ab', :key => 'a/file2')
|
||||
file3 = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'abc', :key => 'b/file3')
|
||||
file4 = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'abcd', :key => 'file4')
|
||||
|
||||
tests("#get_bucket('fogbuckettests')") do
|
||||
tests("#get_bucket('#{@aws_bucket_name}')") do
|
||||
before do
|
||||
@bucket = Fog::Storage[:aws].get_bucket('fogbuckettests')
|
||||
@bucket = Fog::Storage[:aws].get_bucket(@aws_bucket_name)
|
||||
end
|
||||
|
||||
tests(".body['Contents'].map{|n| n['Key']}").returns(["a/a1/file1", "a/file2", "b/file3", "file4"]) do
|
||||
|
@ -72,9 +74,9 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
end
|
||||
end
|
||||
|
||||
tests("#get_bucket('fogbuckettests', 'delimiter' => '/')") do
|
||||
tests("#get_bucket('#{@aws_bucket_name}', 'delimiter' => '/')") do
|
||||
before do
|
||||
@bucket = Fog::Storage[:aws].get_bucket('fogbuckettests', 'delimiter' => '/')
|
||||
@bucket = Fog::Storage[:aws].get_bucket(@aws_bucket_name, 'delimiter' => '/')
|
||||
end
|
||||
|
||||
tests(".body['Contents'].map{|n| n['Key']}").returns(['file4']) do
|
||||
|
@ -86,9 +88,9 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
end
|
||||
end
|
||||
|
||||
tests("#get_bucket('fogbuckettests', 'delimiter' => '/', 'prefix' => 'a/')") do
|
||||
tests("#get_bucket('#{@aws_bucket_name}', 'delimiter' => '/', 'prefix' => 'a/')") do
|
||||
before do
|
||||
@bucket = Fog::Storage[:aws].get_bucket('fogbuckettests', 'delimiter' => '/', 'prefix' => 'a/')
|
||||
@bucket = Fog::Storage[:aws].get_bucket(@aws_bucket_name, 'delimiter' => '/', 'prefix' => 'a/')
|
||||
end
|
||||
|
||||
tests(".body['Contents'].map{|n| n['Key']}").returns(['a/file2']) do
|
||||
|
@ -102,63 +104,87 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
|
||||
file1.destroy; file2.destroy; file3.destroy; file4.destroy
|
||||
|
||||
tests("#get_bucket_location('fogbuckettests)").formats('LocationConstraint' => NilClass) do
|
||||
Fog::Storage[:aws].get_bucket_location('fogbuckettests').body
|
||||
tests("#get_bucket_location('#{@aws_bucket_name}')").formats('LocationConstraint' => NilClass) do
|
||||
Fog::Storage[:aws].get_bucket_location(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#get_request_payment('fogbuckettests')").formats('Payer' => String) do
|
||||
Fog::Storage[:aws].get_request_payment('fogbuckettests').body
|
||||
tests("#get_request_payment('#{@aws_bucket_name}')").formats('Payer' => String) do
|
||||
Fog::Storage[:aws].get_request_payment(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#put_request_payment('fogbuckettests', 'Requester')").succeeds do
|
||||
Fog::Storage[:aws].put_request_payment('fogbuckettests', 'Requester')
|
||||
tests("#put_request_payment('#{@aws_bucket_name}', 'Requester')").succeeds do
|
||||
Fog::Storage[:aws].put_request_payment(@aws_bucket_name, 'Requester')
|
||||
end
|
||||
|
||||
tests("#put_bucket_website('fogbuckettests', 'index.html')").succeeds do
|
||||
tests("#put_bucket_website('#{@aws_bucket_name}', 'index.html')").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_bucket_website('fogbuckettests', 'index.html')
|
||||
Fog::Storage[:aws].put_bucket_website(@aws_bucket_name, 'index.html')
|
||||
end
|
||||
|
||||
tests("#delete_bucket_website('fogbuckettests')").succeeds do
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', 'private')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, 'private')
|
||||
end
|
||||
|
||||
acl = {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => @aws_owner,
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
}
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with id)").returns(acl) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].delete_bucket_website('fogbuckettests')
|
||||
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, acl)
|
||||
Fog::Storage[:aws].get_bucket_acl(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#delete_bucket('fogbuckettests')").succeeds do
|
||||
Fog::Storage[:aws].delete_bucket('fogbuckettests')
|
||||
end
|
||||
|
||||
tests("#put_bucket_acl('fogbuckettests', 'private')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket_acl('fogbuckettests', 'private')
|
||||
end
|
||||
|
||||
tests("#put_bucket_acl('fogbuckettests', hash)").returns(true) do
|
||||
Fog::Storage[:aws].put_bucket_acl('fogbuckettests', {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with email)").returns({
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => "8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
{
|
||||
'Grantee' => { 'ID' => 'f62f0218873cfa5d56ae9429ae75a592fec4fd22a5f24a20b1038a7db9a8f150', 'DisplayName' => 'mtd' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
}) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'EmailAddress' => 'mtd@amazon.com' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
})
|
||||
Fog::Storage[:aws].get_bucket_acl('fogbuckettests').body == <<-BODY
|
||||
<AccessControlPolicy>
|
||||
<Owner>
|
||||
<ID>8a6925ce4adf5f21c32aa379004fef</ID>
|
||||
<DisplayName>mtd@amazon.com</DisplayName>
|
||||
</Owner>
|
||||
<AccessControlList>
|
||||
<Grant>
|
||||
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
|
||||
<ID>8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef</ID>
|
||||
<DisplayName>mtd@amazon.com</DisplayName>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
Fog::Storage[:aws].get_bucket_acl(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
acl = {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'URI' => 'http://acs.amazonaws.com/groups/global/AllUsers' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
}
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with uri)").returns(acl) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, acl)
|
||||
Fog::Storage[:aws].get_bucket_acl(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#delete_bucket_website('#{@aws_bucket_name}')").succeeds do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].delete_bucket_website(@aws_bucket_name)
|
||||
end
|
||||
|
||||
tests("#delete_bucket('#{@aws_bucket_name}')").succeeds do
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -201,4 +227,6 @@ BODY
|
|||
|
||||
end
|
||||
|
||||
# don't keep the bucket around
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name) rescue nil
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests('AWS::Storage | object requests', ['aws']) do
|
||||
|
||||
@directory = Fog::Storage[:aws].directories.create(:key => 'fogobjecttests')
|
||||
@directory = Fog::Storage[:aws].directories.create(:key => 'fogobjecttests-' + Time.now.to_i.to_s(32))
|
||||
@aws_owner = Fog::Storage[:aws].get_bucket_acl(@directory.key).body['Owner']
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
@ -34,32 +34,52 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
|
|||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', 'private')
|
||||
end
|
||||
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash)").returns(true) do
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
acl = {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => @aws_owner,
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]}
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with id)").returns(acl) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', acl)
|
||||
Fog::Storage[:aws].get_object_acl(@directory.identity, 'fog_object').body
|
||||
end
|
||||
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with email)").returns({
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => "8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
{
|
||||
'Grantee' => { 'ID' => 'f62f0218873cfa5d56ae9429ae75a592fec4fd22a5f24a20b1038a7db9a8f150', 'DisplayName' => 'mtd' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]}) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'EmailAddress' => 'mtd@amazon.com' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]})
|
||||
Fog::Storage[:aws].get_object_acl(@directory.identity, 'fog_object').body == <<-BODY
|
||||
<AccessControlPolicy>
|
||||
<Owner>
|
||||
<ID>8a6925ce4adf5f21c32aa379004fef</ID>
|
||||
<DisplayName>mtd@amazon.com</DisplayName>
|
||||
</Owner>
|
||||
<AccessControlList>
|
||||
<Grant>
|
||||
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
|
||||
<ID>8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef</ID>
|
||||
<DisplayName>mtd@amazon.com</DisplayName>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
Fog::Storage[:aws].get_object_acl(@directory.identity, 'fog_object').body
|
||||
end
|
||||
|
||||
acl = {
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'URI' => 'http://acs.amazonaws.com/groups/global/AllUsers' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]}
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with uri)").returns(acl) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', acl)
|
||||
Fog::Storage[:aws].get_object_acl(@directory.identity, 'fog_object').body
|
||||
end
|
||||
|
||||
tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
|
||||
|
|
Loading…
Add table
Reference in a new issue