Skip to content

fix: align bucket bound hostname url builder consistency #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def _bucket_bound_hostname_url(host, scheme=None):
if url_parts.scheme and url_parts.netloc:
return host

return f"{scheme}://{host}/"
return f"{scheme}://{host}"


def _api_core_retry_to_resumable_media_retry(retry, num_retries=None):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ def generate_signed_post_policy_v4(
if virtual_hosted_style:
url = f"https://{bucket_name}.storage.googleapis.com/"
elif bucket_bound_hostname:
url = _bucket_bound_hostname_url(bucket_bound_hostname, scheme)
url = f"{_bucket_bound_hostname_url(bucket_bound_hostname, scheme)}/"
else:
url = f"https://storage.googleapis.com/{bucket_name}/"

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,13 @@ def _call_fut(self, **args):
return _bucket_bound_hostname_url(**args)

def test_full_hostname(self):
HOST = "scheme://domain.tcl/"
HOST = "scheme://domain.tcl"
self.assertEqual(self._call_fut(host=HOST), HOST)

def test_hostname_and_scheme(self):
HOST = "domain.tcl"
SCHEME = "scheme"
EXPECTED_URL = SCHEME + "://" + HOST + "/"
EXPECTED_URL = SCHEME + "://" + HOST

self.assertEqual(self._call_fut(host=HOST, scheme=SCHEME), EXPECTED_URL)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ def test_get_signed_policy_v4_bucket_bound_hostname(self):
bucket_bound_hostname="https://bucket.bound_hostname",
credentials=_create_signing_credentials(),
)
self.assertEqual(policy["url"], "https://bucket.bound_hostname")
self.assertEqual(policy["url"], "https://bucket.bound_hostname/")

def test_get_signed_policy_v4_bucket_bound_hostname_with_scheme(self):
import datetime
Expand Down