Use client.bucket() in GCSFeedStorage so object-level GCS permissions suffice (#7945)

This commit is contained in:
Adrian 2026-08-09 11:57:11 +02:00 committed by GitHub
parent f123c7a1cc
commit cd7f422a1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 4 deletions

View File

@ -340,7 +340,7 @@ class GCSFeedStorage(BlockingFeedStorage):
from google.cloud.storage import Client # noqa: PLC0415
client = Client(project=self.project_id)
bucket = client.get_bucket(self.bucket_name)
bucket = client.bucket(self.bucket_name)
blob = bucket.blob(self.blob_name)
blob.upload_from_file(file, predefined_acl=self.acl)
finally:

View File

@ -524,7 +524,7 @@ class TestGCSFeedStorage:
f.seek.assert_called_once_with(0)
m.assert_called_once_with(project=project_id)
client_mock.get_bucket.assert_called_once_with("mybucket")
client_mock.bucket.assert_called_once_with("mybucket")
bucket_mock.blob.assert_called_once_with("export.csv")
blob_mock.upload_from_file.assert_called_once_with(f, predefined_acl=acl)
f.close.assert_called_once_with()
@ -548,7 +548,7 @@ class TestGCSFeedStorage:
f.seek.assert_called_once_with(0)
m.assert_called_once_with(project=project_id)
client_mock.get_bucket.assert_called_once_with("mybucket")
client_mock.bucket.assert_called_once_with("mybucket")
bucket_mock.blob.assert_called_once_with("export.csv")
blob_mock.upload_from_file.assert_called_once_with(f, predefined_acl=acl)
f.close.assert_called_once_with()

View File

@ -14,7 +14,6 @@ def mock_google_cloud_storage() -> tuple[Any, Any, Any]:
bucket_mock = mock.create_autospec(Bucket)
client_mock.bucket.return_value = bucket_mock
client_mock.get_bucket.return_value = bucket_mock
blob_mock = mock.create_autospec(Blob)
bucket_mock.blob.return_value = blob_mock