Skip to content

Commit

Permalink
Merge pull request #412 from stanhu/sh-fix-broken-get-http-url
Browse files Browse the repository at this point in the history
Fix broken calls to get_object_http_url
  • Loading branch information
Temikus authored Aug 21, 2018
2 parents fa2e560 + 154bf89 commit 9283fe6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/fog/storage/google_xml/requests/get_object_http_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ def get_object_http_url(bucket_name, object_name, expires, options = {})
raise ArgumentError.new("bucket_name is required") unless bucket_name
raise ArgumentError.new("object_name is required") unless object_name

https_url(options.merge(:headers => {},
:host => @host,
:method => "GET",
:path => "#{bucket_name}/#{object_name}"),
http_url(options.merge(:headers => {},
:host => @host,
:method => "GET",
:path => "#{bucket_name}/#{object_name}"),
expires)
http_url(url_options, expires)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Fog
module Storage
class GoogleXML
module GetObjectHttpsUrl
def get_object_https_url(bucket_name, object_name, expires, options)
def get_object_https_url(bucket_name, object_name, expires, options = {})
raise ArgumentError.new("bucket_name is required") unless bucket_name
raise ArgumentError.new("object_name is required") unless object_name

Expand Down
16 changes: 16 additions & 0 deletions test/unit/storage/test_xml_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ def teardown
Fog.unmock!
end

def test_get_http_url
url = @client.get_object_http_url("bucket",
"just some file.json",
Time.now + 2 * 60)
assert_match(/^http:\/\//, url,
"URL starts with HTTP")
end

def test_get_https_url
url = @client.get_object_https_url("bucket",
"just some file.json",
Time.now + 2 * 60)
assert_match(/^https:\/\//, url,
"URL starts with HTTPS")
end

def test_get_url_path_has_query_params
url = @client.get_object_url("bucket",
"just some file.json",
Expand Down

0 comments on commit 9283fe6

Please sign in to comment.