2013-01-18 15:06:41 -05:00
|
|
|
Shindo.tests("Fog::Storage[:hp] | object requests", ['hp', 'storage']) do
|
2012-04-02 15:31:29 -04:00
|
|
|
|
|
|
|
@directory = Fog::Storage[:hp].directories.create(:key => 'fogobjecttests')
|
|
|
|
@dir_name = @directory.identity
|
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#put_object('#{@dir_name}', 'fog_object')").succeeds do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].put_object(@dir_name, 'fog_object', lorem_file)
|
|
|
|
end
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#get_object('#{@dir_name}', 'fog_object')").succeeds do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].get_object(@dir_name, 'fog_object')
|
|
|
|
end
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#get_object('#{@dir_name}', 'fog_object', &block)").returns(lorem_file.read) do
|
2012-04-02 15:31:29 -04:00
|
|
|
data = ''
|
|
|
|
Fog::Storage[:hp].get_object(@dir_name, 'fog_object') do |chunk, remaining_bytes, total_bytes|
|
|
|
|
data << chunk
|
|
|
|
end
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#head_object('#{@dir_name}', 'fog_object')").succeeds do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].head_object(@dir_name, 'fog_object')
|
|
|
|
end
|
|
|
|
|
2012-09-26 14:12:57 -04:00
|
|
|
tests("#get_object_temp_url('#{@dir_name}', 'fog_object', 60, 'GET')").succeeds do
|
|
|
|
Fog::Storage[:hp].get_object_temp_url(@dir_name, 'fog_object', 60, 'GET')
|
|
|
|
end
|
|
|
|
|
2012-04-02 19:09:58 -04:00
|
|
|
# copy a file within the same container
|
2012-04-02 19:04:46 -04:00
|
|
|
tests("#put_object('#{@dir_name}', 'fog_other_object', nil, {'X-Copy-From' => '/#{@dir_name}/fog_object'})" ).succeeds do
|
|
|
|
Fog::Storage[:hp].put_object(@dir_name, 'fog_other_object', nil, {'X-Copy-From' => "/#{@dir_name}/fog_object"})
|
|
|
|
end
|
|
|
|
@directory.files.get('fog_other_object').destroy
|
|
|
|
|
2012-04-02 19:09:58 -04:00
|
|
|
# copy a file from one container to another
|
|
|
|
@another_dir = Fog::Storage[:hp].directories.create(:key => 'fogobjecttests2')
|
|
|
|
tests("#put_object('#{@another_dir.identity}', 'fog_another_object', nil, {'X-Copy-From' => '/#{@dir_name}/fog_object'})" ).succeeds do
|
|
|
|
Fog::Storage[:hp].put_object(@another_dir.identity, 'fog_another_object', nil, {'X-Copy-From' => "/#{@dir_name}/fog_object"})
|
|
|
|
end
|
|
|
|
@another_dir.files.get('fog_another_object').destroy
|
|
|
|
@another_dir.destroy
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#delete_object('#{@dir_name}', 'fog_object')").succeeds do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].delete_object(@dir_name, 'fog_object')
|
|
|
|
end
|
2013-10-08 10:48:26 -04:00
|
|
|
|
|
|
|
tests("#get_object_http_url('#{@directory.identity}', 'fog_object', expiration timestamp)").returns(true) do
|
|
|
|
object_url = Fog::Storage[:hp].get_object_http_url(@dir_name, 'fog_object', (Time.now + 60))
|
2013-10-16 08:25:31 -04:00
|
|
|
object_url.include? "fog_object"
|
|
|
|
object_url.include? "&temp_url_expires="
|
|
|
|
object_url.include? "temp_url_sig="
|
|
|
|
object_url.include? @dir_name
|
|
|
|
object_url.start_with? "http://"
|
2013-10-08 10:48:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_object_https_url('#{@directory.identity}', 'fog_object', expiration timestamp)").returns(true) do
|
|
|
|
object_url = Fog::Storage[:hp].get_object_https_url(@dir_name, 'fog_object', (Time.now + 60))
|
2013-10-16 08:25:31 -04:00
|
|
|
object_url.include? "fog_object"
|
|
|
|
object_url.include? "&temp_url_expires="
|
|
|
|
object_url.include? "temp_url_sig="
|
|
|
|
object_url.include? @dir_name
|
|
|
|
object_url.start_with? "https://"
|
2013-10-08 10:48:26 -04:00
|
|
|
end
|
2012-04-02 15:31:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#put_object('fognoncontainer', 'fog_object')").raises(Fog::Storage::HP::NotFound) do
|
|
|
|
Fog::Storage[:hp].put_object('fognoncontainer', 'fog_object', lorem_file)
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_object('#{@dir_name}', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].get_object(@dir_name, 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
|
|
|
Fog::Storage[:hp].get_object('fognoncontainer', 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
2012-09-26 14:12:57 -04:00
|
|
|
tests("#get_object_temp_url('#{@dir_name}', 'fog_object', 60, 'POST')").raises(ArgumentError) do
|
|
|
|
Fog::Storage[:hp].get_object_temp_url(@dir_name, 'fog_object', 60, 'POST')
|
|
|
|
end
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#head_object('#{@dir_name}', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].head_object(@dir_name, 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#head_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
|
|
|
Fog::Storage[:hp].head_object('fognoncontainer', 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
2012-04-02 18:46:04 -04:00
|
|
|
tests("#delete_object('#{@dir_name}', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
2012-04-02 15:31:29 -04:00
|
|
|
Fog::Storage[:hp].delete_object(@dir_name, 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#delete_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
|
|
|
|
Fog::Storage[:hp].delete_object('fognoncontainer', 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2013-10-08 10:48:26 -04:00
|
|
|
|
2012-04-02 15:31:29 -04:00
|
|
|
@directory.destroy
|
|
|
|
|
|
|
|
end
|