diff --git a/google-cloud-storage/acceptance/storage/bucket_test.rb b/google-cloud-storage/acceptance/storage/bucket_test.rb index 0f2f61b52543..0723c5687b49 100644 --- a/google-cloud-storage/acceptance/storage/bucket_test.rb +++ b/google-cloud-storage/acceptance/storage/bucket_test.rb @@ -195,9 +195,9 @@ _(bucket.lifecycle.last.created_before).must_be_kind_of Date _(bucket.lifecycle.last.created_before).must_equal created_before_2 - _(bucket.lifecycle.last.custom_time_before).must_be_kind_of DateTime + _(bucket.lifecycle.last.custom_time_before).must_be_kind_of Date _(bucket.lifecycle.last.custom_time_before).must_equal custom_time_before_2 - _(bucket.lifecycle.last.noncurrent_time_before).must_be_kind_of DateTime + _(bucket.lifecycle.last.noncurrent_time_before).must_be_kind_of Date _(bucket.lifecycle.last.noncurrent_time_before).must_equal noncurrent_time_before_2 @@ -210,13 +210,13 @@ _(bucket.lifecycle.last.age).must_equal 20 _(bucket.lifecycle.last.created_before).must_be_kind_of Date _(bucket.lifecycle.last.created_before).must_equal created_before_2 - _(bucket.lifecycle.last.custom_time_before).must_be_kind_of DateTime + _(bucket.lifecycle.last.custom_time_before).must_be_kind_of Date _(bucket.lifecycle.last.custom_time_before).must_equal custom_time_before_2 _(bucket.lifecycle.last.days_since_custom_time).must_equal 6 _(bucket.lifecycle.last.days_since_noncurrent_time).must_equal 15 _(bucket.lifecycle.last.is_live).must_equal false _(bucket.lifecycle.last.matches_storage_class).must_equal ["NEARLINE"] - _(bucket.lifecycle.last.noncurrent_time_before).must_be_kind_of DateTime + _(bucket.lifecycle.last.noncurrent_time_before).must_be_kind_of Date _(bucket.lifecycle.last.noncurrent_time_before).must_equal noncurrent_time_before_2 _(bucket.lifecycle.last.num_newer_versions).must_equal 4 diff --git a/google-cloud-storage/acceptance/storage/signed_url_v2_test.rb b/google-cloud-storage/acceptance/storage/signed_url_v2_test.rb index ad03007519e8..0bb9479c11f7 100644 --- a/google-cloud-storage/acceptance/storage/signed_url_v2_test.rb +++ b/google-cloud-storage/acceptance/storage/signed_url_v2_test.rb @@ -44,9 +44,9 @@ end describe Google::Cloud::Storage::Project, :signed_url do - it "should create a signed read url" do + it "should create a signed read url with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetBucket.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetBucket.png" five_min_from_now = 5 * 60 url = storage.signed_url bucket.name, file.name, method: "GET", @@ -69,9 +69,9 @@ end end - it "should create a signed POST url version v2" do + it "should create a signed POST url version v2 with space in file name" do url = storage.signed_url bucket.name, - "CloudLogoProjectSignedUrlPost.png", + "CloudLogoProjectSignedUrl Post.png", method: "POST", content_type: "image/png", # Required for V2 headers: { "x-goog-resumable" => "start" }, @@ -90,9 +90,9 @@ end describe Google::Cloud::Storage::Bucket, :signed_url do - it "should create a signed read url" do + it "should create a signed read url with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetBucket.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetBucket.png" five_min_from_now = 5 * 60 url = bucket.signed_url file.name, method: "GET", @@ -197,9 +197,9 @@ end describe Google::Cloud::Storage::File, :signed_url do - it "should create a signed read url" do + it "should create a signed read url with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetFile.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetFile.png" five_min_from_now = 5 * 60 url = file.signed_url method: "GET", diff --git a/google-cloud-storage/acceptance/storage/signed_url_v4_test.rb b/google-cloud-storage/acceptance/storage/signed_url_v4_test.rb index 697e017d0c3c..f8de07c4cd56 100644 --- a/google-cloud-storage/acceptance/storage/signed_url_v4_test.rb +++ b/google-cloud-storage/acceptance/storage/signed_url_v4_test.rb @@ -44,9 +44,9 @@ end describe Google::Cloud::Storage::Project, :signed_url do - it "should create a signed read url version v4" do + it "should create a signed read url version v4 with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetBucket.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetBucket.png" five_min_from_now = 5 * 60 url = storage.signed_url bucket.name, file.name, method: "GET", @@ -69,10 +69,10 @@ end end - it "should create a signed POST url version v4" do + it "should create a signed POST url version v4 with space in file name" do five_min_from_now = 60 * 60 url = storage.signed_url bucket.name, - "CloudLogoProjectSignedUrlPost.png", + "CloudLogoProjectSignedUrl Post.png", method: "POST", expires: five_min_from_now, headers: { "x-goog-resumable" => "start" }, @@ -90,9 +90,9 @@ end describe Google::Cloud::Storage::Bucket, :signed_url do - it "should create a signed read url version v4" do + it "should create a signed read url version v4 with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetBucket.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetBucket.png" five_min_from_now = 5 * 60 url = bucket.signed_url file.name, method: "GET", @@ -197,9 +197,9 @@ end describe Google::Cloud::Storage::File, :signed_url do - it "should create a signed read url version v4" do + it "should create a signed read url version v4 with space in file name" do local_file = File.new files[:logo][:path] - file = bucket.create_file local_file, "CloudLogoSignedUrlGetFile.png" + file = bucket.create_file local_file, "CloudLogoSignedUrl GetFile.png" five_min_from_now = 5 * 60 url = file.signed_url method: "GET", @@ -222,9 +222,9 @@ end end - it "should create a signed POST url version v4" do + it "should create a signed POST url version v4 with space in file name" do five_min_from_now = 60 * 60 - file = bucket.file "CloudLogoFileSignedUrlPost.png", skip_lookup: true + file = bucket.file "CloudLogoFileSignedUrl Post.png", skip_lookup: true url = file.signed_url method: "POST", expires: five_min_from_now, headers: { "x-goog-resumable" => "start"}, diff --git a/google-cloud-storage/lib/google/cloud/storage/file/signer_v4.rb b/google-cloud-storage/lib/google/cloud/storage/file/signer_v4.rb index 10707e554148..3dabd9849e55 100644 --- a/google-cloud-storage/lib/google/cloud/storage/file/signer_v4.rb +++ b/google-cloud-storage/lib/google/cloud/storage/file/signer_v4.rb @@ -273,7 +273,7 @@ def canonical_query query, algorithm, credential, goog_date, expires, signed_hea # Only the characters in the regex set [A-Za-z0-9.~_-] must be left un-escaped; all others must be # percent-encoded using %XX UTF-8 style. def escape_query_param str - CGI.escape(str.to_s).gsub("%7E", "~").gsub("+", "%20") + CGI.escape(str.to_s).gsub("%7E", "~").gsub "+", "%20" end def host_name virtual_hosted_style, bucket_bound_hostname @@ -287,7 +287,7 @@ def file_path path_style path = [] path << "/#{@bucket_name}" if path_style path << "/#{String(@file_name)}" if @file_name && !@file_name.empty? - CGI.escape(path.join).gsub "%2F", "/" + CGI.escape(path.join).gsub("%2F", "/").gsub "+", "%20" end ##