mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix AWS S3 bucket and object tests
Allow for other users than mtd to run the real tests. The mocking API is broken and returns XML on these tests. But fixing it would require more than returning JSON, it should also transform the email address to a user ID, DisplayName pair
This commit is contained in:
parent
e82ac2b773
commit
4a2768a403
2 changed files with 72 additions and 134 deletions
|
@ -36,6 +36,7 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
|
||||
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
|
||||
|
@ -124,53 +125,34 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', [:aws]) do
|
|||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, 'private')
|
||||
end
|
||||
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with id)").returns(<<-BODY) do
|
||||
<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].put_bucket_acl(@aws_bucket_name, {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => "8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
})
|
||||
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].put_bucket_acl(@aws_bucket_name, acl)
|
||||
Fog::Storage[:aws].get_bucket_acl(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with email)").returns(<<-BODY) do
|
||||
<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="AmazonCustomerByEmail\">
|
||||
<EmailAddress>mtd@amazon.com</EmailAddress>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with email)").returns({
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => 'f62f0218873cfa5d56ae9429ae75a592fec4fd22a5f24a20b1038a7db9a8f150', 'DisplayName' => 'mtd' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
}) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'EmailAddress' => 'mtd@amazon.com' },
|
||||
|
@ -181,31 +163,18 @@ BODY
|
|||
Fog::Storage[:aws].get_bucket_acl(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#put_bucket_acl('#{@aws_bucket_name}', hash with uri)").returns(<<-BODY) do
|
||||
<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="Group">
|
||||
<URI>http://www.w3.org/2001/XMLSchema-instance</URI>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
Fog::Storage[:aws].put_bucket_acl(@aws_bucket_name, {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'URI' => 'http://www.w3.org/2001/XMLSchema-instance' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]
|
||||
})
|
||||
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
|
||||
|
||||
|
@ -258,4 +227,6 @@ BODY
|
|||
|
||||
end
|
||||
|
||||
# don't keep the bucket around
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name) rescue nil
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Shindo.tests('AWS::Storage | object requests', ['aws']) do
|
||||
@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
|
||||
|
||||
|
@ -33,52 +34,31 @@ 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 with id)").returns(<<BODY) do
|
||||
<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].put_object_acl(@directory.identity, 'fog_object', {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => "8a6925ce4adf588a4532142d3f74dd8c71fa124b1ddee97f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]})
|
||||
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(<<BODY) do
|
||||
<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="AmazonCustomerByEmail">
|
||||
<EmailAddress>mtd@amazon.com</EmailAddress>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with email)").returns({
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'ID' => 'f62f0218873cfa5d56ae9429ae75a592fec4fd22a5f24a20b1038a7db9a8f150', 'DisplayName' => 'mtd' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]}) do
|
||||
pending if Fog.mocking?
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'Owner' => @aws_owner,
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'EmailAddress' => 'mtd@amazon.com' },
|
||||
|
@ -88,30 +68,17 @@ BODY
|
|||
Fog::Storage[:aws].get_object_acl(@directory.identity, 'fog_object').body
|
||||
end
|
||||
|
||||
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with uri)").returns(<<BODY) do
|
||||
<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="Group">
|
||||
<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
|
||||
</Grantee>
|
||||
<Permission>FULL_CONTROL</Permission>
|
||||
</Grant>
|
||||
</AccessControlList>
|
||||
</AccessControlPolicy>
|
||||
BODY
|
||||
Fog::Storage[:aws].put_object_acl(@directory.identity, 'fog_object', {
|
||||
'Owner' => { 'ID' => "8a6925ce4adf5f21c32aa379004fef", 'DisplayName' => "mtd@amazon.com" },
|
||||
'AccessControlList' => [
|
||||
{
|
||||
'Grantee' => { 'URI' => 'http://acs.amazonaws.com/groups/global/AllUsers' },
|
||||
'Permission' => "FULL_CONTROL"
|
||||
}
|
||||
]})
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue