@@ -778,8 +778,11 @@ def dummy_service_account():
778778 return _DUMMY_SERVICE_ACCOUNT
779779
780780
781+ _API_ACCESS_ENDPOINT = "https://storage.googleapis.com"
782+
783+
781784def _run_conformance_test (
782- resource , test_data , api_access_endpoint = "https://storage.googleapis.com"
785+ resource , test_data , api_access_endpoint = _API_ACCESS_ENDPOINT
783786):
784787 credentials = dummy_service_account ()
785788 url = Test_generate_signed_url_v4 ._call_fut (
@@ -804,29 +807,37 @@ def test_conformance_client(test_data):
804807
805808@pytest .mark .parametrize ("test_data" , _BUCKET_TESTS )
806809def test_conformance_bucket (test_data ):
810+ global _API_ACCESS_ENDPOINT
807811 if "urlStyle" in test_data and test_data ["urlStyle" ] == "BUCKET_BOUND_HOSTNAME" :
808- api_access_endpoint = "{scheme}://{bucket_bound_hostname}" .format (
812+ _API_ACCESS_ENDPOINT = "{scheme}://{bucket_bound_hostname}" .format (
809813 scheme = test_data ["scheme" ],
810814 bucket_bound_hostname = test_data ["bucketBoundHostname" ],
811815 )
812816 resource = "/"
813- _run_conformance_test (resource , test_data , api_access_endpoint )
817+ _run_conformance_test (resource , test_data , _API_ACCESS_ENDPOINT )
814818 else :
815819 resource = "/{}" .format (test_data ["bucket" ])
816820 _run_conformance_test (resource , test_data )
817821
818822
819823@pytest .mark .parametrize ("test_data" , _BLOB_TESTS )
820824def test_conformance_blob (test_data ):
821- if "urlStyle" in test_data and test_data ["urlStyle" ] == "BUCKET_BOUND_HOSTNAME" :
822- api_access_endpoint = "{scheme}://{bucket_bound_hostname}" .format (
823- scheme = test_data ["scheme" ],
824- bucket_bound_hostname = test_data ["bucketBoundHostname" ],
825- )
825+ global _API_ACCESS_ENDPOINT
826+ if "urlStyle" in test_data :
827+ if test_data ["urlStyle" ] == "BUCKET_BOUND_HOSTNAME" :
828+ _API_ACCESS_ENDPOINT = "{scheme}://{bucket_bound_hostname}" .format (
829+ scheme = test_data ["scheme" ],
830+ bucket_bound_hostname = test_data ["bucketBoundHostname" ],
831+ )
832+
833+ # For the VIRTUAL_HOSTED_STYLE
834+ else :
835+ _API_ACCESS_ENDPOINT = "{scheme}://{bucket_name}.storage.googleapis.com" .format (
836+ scheme = test_data ["scheme" ], bucket_name = test_data ["bucket" ]
837+ )
826838 resource = "/{}" .format (test_data ["object" ])
827- _run_conformance_test (resource , test_data , api_access_endpoint )
839+ _run_conformance_test (resource , test_data , _API_ACCESS_ENDPOINT )
828840 else :
829-
830841 resource = "/{}/{}" .format (test_data ["bucket" ], test_data ["object" ])
831842 _run_conformance_test (resource , test_data )
832843
0 commit comments