Skip to content

Commit

Permalink
FIX: Fix api_access_endpoint for cloud storage emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
cortadocodes committed May 1, 2024
1 parent b45b1d3 commit aa8bd93
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions octue/cloud/emulators/cloud_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import closing

from gcp_storage_emulator.server import create_server
from google.cloud.storage.blob import _API_ACCESS_ENDPOINT
from google.cloud.storage._helpers import _get_default_storage_base_url


# Silence the GCP storage emulator logger below `ERROR` level messages.
Expand Down Expand Up @@ -100,7 +100,12 @@ def stopTestRun(self):
del os.environ[self.STORAGE_EMULATOR_HOST_ENVIRONMENT_VARIABLE_NAME]


def mock_generate_signed_url(blob, expiration=datetime.timedelta(days=7), **kwargs):
def mock_generate_signed_url(
blob,
expiration=datetime.timedelta(days=7),
api_access_endpoint=_get_default_storage_base_url(),
**kwargs,
):
"""Mock generating a signed URL for a Google Cloud Storage blob. Signed URLs can't currently be generated when using
workload identity federation, which we use for our CI tests.
Expand All @@ -113,5 +118,5 @@ def mock_generate_signed_url(blob, expiration=datetime.timedelta(days=7), **kwar
f"roject.iam.gserviceaccount.com&Signature=mock-signature"
)

base_url = "/".join((kwargs.get("api_access_endpoint", _API_ACCESS_ENDPOINT), blob.bucket.name, blob.name))
base_url = "/".join((api_access_endpoint, blob.bucket.name, blob.name))
return base_url + mock_signed_query_parameter

0 comments on commit aa8bd93

Please sign in to comment.