1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/aws/models/storage/directory_tests.rb
Jonas Pfenniger f6d361b2e2 AWS | storage: big refactor
Logics have been centralised:

* region to hostname
* url generation
* signature
* chaning scheme also changes the port

During the process a couple of inconsistencies have also
been fixed.

Known limitations:

When using the @endpoint with a custom port you need to specify the port
when using get_object_http_url or get_object_https_url.

When using bucket names that contain dots outside of us-east-1 make sure to
access it with the same region in your AWS::Storage.
2013-04-16 23:30:35 +01:00

87 lines
2.4 KiB
Ruby

Shindo.tests("Storage[:aws] | directory", ["aws"]) do
directory_attributes = {
:key => uniq_id('fogdirectorytests')
}
model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
tests("#public_url").returns(nil) do
@instance.public_url
end
@instance.acl = 'public-read'
@instance.save
tests("#public_url").returns(true) do
if @instance.public_url =~ %r[\Ahttps://fogdirectorytests-[\da-f]+\.s3\.amazonaws\.com/\z]
true
else
@instance.public_url
end
end
end
directory_attributes = {
:key => uniq_id('different-region'),
:location => 'eu-west-1',
}
model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
tests("#location").returns('eu-west-1') do
@instance.location
end
tests("#location").returns('eu-west-1') do
Fog::Storage[:aws].directories.get(@instance.identity).location
end
end
directory_attributes = {
:key => uniq_id('fogdirectorytests')
}
model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
tests("#versioning=") do
tests("#versioning=(true)").succeeds do
@instance.versioning = true
end
tests("#versioning=(true) sets versioning to 'Enabled'").returns('Enabled') do
@instance.versioning = true
@instance.service.get_bucket_versioning(@instance.key).body['VersioningConfiguration']['Status']
end
tests("#versioning=(false)").succeeds do
(@instance.versioning = false).equal? false
end
tests("#versioning=(false) sets versioning to 'Suspended'").returns('Suspended') do
@instance.versioning = false
@instance.service.get_bucket_versioning(@instance.key).body['VersioningConfiguration']['Status']
end
end
end
model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do
tests("#versioning?") do
tests("#versioning? false if not enabled").returns(false) do
@instance.versioning?
end
tests("#versioning? true if enabled").returns(true) do
@instance.service.put_bucket_versioning(@instance.key, 'Enabled')
@instance.versioning?
end
tests("#versioning? false if suspended").returns(false) do
@instance.service.put_bucket_versioning(@instance.key, 'Suspended')
@instance.versioning?
end
end
end
end