1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Test the relevant bits of the temp_urls explicitly.

This commit is contained in:
Ash Wilson 2014-03-20 15:31:26 -04:00
parent 6d3ffa48b5
commit 9ace678803

View file

@ -41,18 +41,42 @@ Shindo.tests('Fog::Storage[:openstack] | object requests', ["openstack"]) do
Fog::Storage[:openstack].delete_object('fogobjecttests', 'fog_object')
end
tests("#get_object_http_url('directory.identity', 'fog_object', expiration timestamp)").returns(true) do
tests("#get_object_http_url('directory.identity', 'fog_object', expiration timestamp)").succeeds do
pending if Fog.mocking?
object_url = Fog::Storage[:openstack].get_object_http_url(@directory.identity, 'fog_object', (Time.now + 60))
ts = Time.at(1395343213)
object_url_s = Fog::Storage[:openstack].get_object_http_url(@directory.identity, 'fog_object', ts)
object_url = URI.parse(object_url_s)
query_params = URI.decode_www_form(object_url.query)
(object_url =~ /http:\/\/\S+\/v1\/AUTH_\S+\/#{@directory.identity}\/fog_object\?temp_url_sig=\S+&temp_url_expires=\d+/) != nil
tests('the link is http').returns('http') { object_url.scheme }
tests('the container and object are present in the path').returns(true) do
(object_url.path =~ /\/#{@directory.identity}\/fog_object/) != nil
end
tests('a temp_url_sig is present').returns(true) do
query_params.any? { |p| p[0] == 'temp_url_sig' }
end
tests('temp_url_expires matches the expiration').returns(true) do
query_params.any? { |p| p == ['temp_url_expires', ts.to_i.to_s] }
end
end
tests("#get_object_https_url('directory.identity', 'fog_object', expiration timestamp)").returns(true) do
tests("#get_object_https_url('directory.identity', 'fog_object', expiration timestamp)").succeeds do
pending if Fog.mocking?
object_url = Fog::Storage[:openstack].get_object_https_url(@directory.identity, 'fog_object', (Time.now + 60))
ts = Time.at(1395343213)
object_url_s = Fog::Storage[:openstack].get_object_https_url(@directory.identity, 'fog_object', ts)
object_url = URI.parse(object_url_s)
query_params = URI.decode_www_form(object_url.query)
(object_url =~ /https:\/\/\S+\/v1\/AUTH_\S+\/#{@directory.identity}\/fog_object\?temp_url_sig=\S+&temp_url_expires=\d+/) != nil
tests('the link is https').returns('https') { object_url.scheme }
tests('the container and object are present in the path').returns(true) do
(object_url.path =~ /\/#{@directory.identity}\/fog_object/) != nil
end
tests('a temp_url_sig is present').returns(true) do
query_params.any? { |p| p[0] == 'temp_url_sig' }
end
tests('temp_url_expires matches the expiration').returns(true) do
query_params.any? { |p| p == ['temp_url_expires', ts.to_i.to_s] }
end
end
tests("put_object with block") do