From 144dca1cb3b8b157ce1ef363be3b5f83f29b5075 Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:11:48 +0530 Subject: [PATCH 1/6] Update client.py --- google/cloud/storage/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 9cccf413b..2fe87e210 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -20,6 +20,7 @@ import datetime import functools import json +import os import warnings import google.api_core.client_options @@ -1761,7 +1762,7 @@ def generate_signed_post_policy_v4( elif bucket_bound_hostname: url = f"{_bucket_bound_hostname_url(bucket_bound_hostname, scheme)}/" else: - url = f"https://storage.googleapis.com/{bucket_name}/" + url = f"os.getenv("API_ENDPOINT_OVERRIDE", "https://storage.googleapis.com")/{bucket_name}/" return {"url": url, "fields": policy_fields} From 3d70843d4f42946a2a2f1a60af5e6239b14ecfa2 Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:32:50 +0530 Subject: [PATCH 2/6] Update client.py --- google/cloud/storage/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 2fe87e210..350a46b0a 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -1757,12 +1757,15 @@ def generate_signed_post_policy_v4( } ) # designate URL + + if virtual_hosted_style: url = f"https://{bucket_name}.storage.googleapis.com/" elif bucket_bound_hostname: url = f"{_bucket_bound_hostname_url(bucket_bound_hostname, scheme)}/" else: - url = f"os.getenv("API_ENDPOINT_OVERRIDE", "https://storage.googleapis.com")/{bucket_name}/" + api_access_endpoint=os.getenv("API_ENDPOINT_OVERRIDE", "https://storage.googleapis.com") + url = f"{api_access_endpoint}/{bucket_name}/" return {"url": url, "fields": policy_fields} From 2ee46831941dcec7e1aeffd85d23e34deaade1be Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:39:40 +0530 Subject: [PATCH 3/6] Update test__signing.py --- tests/system/test__signing.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/system/test__signing.py b/tests/system/test__signing.py index f6b81d7cb..58c06a4db 100644 --- a/tests/system/test__signing.py +++ b/tests/system/test__signing.py @@ -380,10 +380,7 @@ def test_create_signed_resumable_upload_url_v4(storage_client, signing_bucket, n ) -@pytest.mark.skipif( - "API_ENDPOINT_OVERRIDE" in os.environ, - reason="Failing test for the overriding endpoint", -) + def test_generate_signed_post_policy_v4( storage_client, buckets_to_delete, blobs_to_delete, service_account, no_mtls ): From 84c7b37949c7baf2f553b5d65008fa7adce509df Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:42:07 +0530 Subject: [PATCH 4/6] Update test__signing.py --- tests/system/test__signing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/test__signing.py b/tests/system/test__signing.py index 58c06a4db..5f0232be5 100644 --- a/tests/system/test__signing.py +++ b/tests/system/test__signing.py @@ -380,7 +380,6 @@ def test_create_signed_resumable_upload_url_v4(storage_client, signing_bucket, n ) - def test_generate_signed_post_policy_v4( storage_client, buckets_to_delete, blobs_to_delete, service_account, no_mtls ): From 78b36911618eb8333ceb63b7e63c5f9122485d61 Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:42:50 +0530 Subject: [PATCH 5/6] Update client.py --- google/cloud/storage/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 350a46b0a..e0b2af1ff 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -1757,14 +1757,14 @@ def generate_signed_post_policy_v4( } ) # designate URL - - if virtual_hosted_style: url = f"https://{bucket_name}.storage.googleapis.com/" elif bucket_bound_hostname: url = f"{_bucket_bound_hostname_url(bucket_bound_hostname, scheme)}/" else: - api_access_endpoint=os.getenv("API_ENDPOINT_OVERRIDE", "https://storage.googleapis.com") + api_access_endpoint = os.getenv( + "API_ENDPOINT_OVERRIDE", "https://storage.googleapis.com" + ) url = f"{api_access_endpoint}/{bucket_name}/" return {"url": url, "fields": policy_fields} From 7535f5288e99a68987cfd8c13b79a7af083e07eb Mon Sep 17 00:00:00 2001 From: rsaksham Date: Wed, 12 Oct 2022 22:50:27 +0530 Subject: [PATCH 6/6] Update test__signing.py --- tests/system/test__signing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/test__signing.py b/tests/system/test__signing.py index 5f0232be5..3e8ca1752 100644 --- a/tests/system/test__signing.py +++ b/tests/system/test__signing.py @@ -16,7 +16,6 @@ import datetime import hashlib import os -import pytest import time import requests