tests/openstack/requests/storage/object_tests.rb in fog-1.21.0 vs tests/openstack/requests/storage/object_tests.rb in fog-1.22.0
- old
+ new
@@ -39,21 +39,37 @@
tests("#delete_object('fogobjecttests', 'fog_object')").succeeds do
pending if Fog.mocking?
Fog::Storage[:openstack].delete_object('fogobjecttests', 'fog_object')
end
- tests("#get_object_http_url('directory.identity', 'fog_object', expiration timestamp)").returns(true) do
- pending if Fog.mocking?
- object_url = Fog::Storage[:openstack].get_object_http_url(@directory.identity, 'fog_object', (Time.now + 60))
+ def test_temp_url(url_s, time, desired_scheme)
+ object_url = URI.parse(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 #{desired_scheme}").returns(desired_scheme) { 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', time.to_i.to_s] }
+ end
end
- tests("#get_object_https_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_https_url(@directory.identity, 'fog_object', (Time.now + 60))
+ ts = Time.at(1395343213)
+ url_s = Fog::Storage[:openstack].get_object_http_url(@directory.identity, 'fog_object', ts)
+ test_temp_url(url_s, ts, 'http')
+ end
- (object_url =~ /https:\/\/\S+\/v1\/AUTH_\S+\/#{@directory.identity}\/fog_object\?temp_url_sig=\S+&temp_url_expires=\d+/) != nil
+ tests("#get_object_https_url('directory.identity', 'fog_object', expiration timestamp)").succeeds do
+ pending if Fog.mocking?
+ ts = Time.at(1395343215)
+ url_s = Fog::Storage[:openstack].get_object_https_url(@directory.identity, 'fog_object', ts)
+ test_temp_url(url_s, ts, 'https')
end
tests("put_object with block") do
pending if Fog.mocking?