Skip to content

Commit 734a9b3

Browse files
committed
Add V4 systests paralleling existing V2 tests.
1 parent 0d54faa commit 734a9b3

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

storage/tests/system.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ def _create_signed_read_url_helper(
764764
blob = self.bucket.blob(blob_name)
765765
if payload is not None:
766766
blob.upload_from_string(payload)
767+
self.case_blobs_to_delete.append(blob)
767768

768769
if expiration is None and max_age is None:
769770
max_age = 10
@@ -795,32 +796,59 @@ def test_create_signed_read_url_v2_w_expiration(self):
795796

796797
self._create_signed_read_url_helper(expiration=now + delta)
797798

799+
def test_create_signed_read_url_v4_w_expiration(self):
800+
now = datetime.datetime.utcnow()
801+
delta = datetime.timedelta(seconds=10)
802+
self._create_signed_read_url_helper(expiration=now + delta, version="v4")
803+
798804
def test_create_signed_read_url_v2_lowercase_method(self):
799805
self._create_signed_read_url_helper(method="get")
800806

807+
def test_create_signed_read_url_v4_lowercase_method(self):
808+
self._create_signed_read_url_helper(method="get", version="v4")
809+
801810
def test_create_signed_read_url_v2_w_non_ascii_name(self):
802811
self._create_signed_read_url_helper(
803812
blob_name=u"Caf\xe9.txt",
804813
payload=b"Test signed URL for blob w/ non-ASCII name",
805814
)
806815

807-
def _create_signed_delete_url_helper(self, version="v2"):
816+
def test_create_signed_read_url_v4_w_non_ascii_name(self):
817+
self._create_signed_read_url_helper(
818+
blob_name=u"Caf\xe9.txt",
819+
payload=b"Test signed URL for blob w/ non-ASCII name",
820+
version="v4",
821+
)
822+
823+
def _create_signed_delete_url_helper(
824+
self, version="v2", expiration=None, max_age=None
825+
):
826+
827+
if expiration is None and max_age is None:
828+
max_age = 10
829+
808830
blob = self.bucket.blob("LogoToSign.jpg")
809-
expiration = int(time.time() + 283473274)
831+
810832
signed_delete_url = blob.generate_signed_url(
811-
expiration, method="DELETE", client=Config.CLIENT, version=version
833+
expiration=expiration,
834+
max_age=max_age,
835+
method="DELETE",
836+
client=Config.CLIENT,
837+
version=version,
812838
)
813839

814840
response = requests.request("DELETE", signed_delete_url)
815841
self.assertEqual(response.status_code, 204)
816842
self.assertEqual(response.content, b"")
817843

818-
# Check that the blob has actually been deleted.
819844
self.assertFalse(blob.exists())
820845

821846
def test_create_signed_delete_url_v2(self):
822847
self._create_signed_delete_url_helper()
823848

849+
def test_create_signed_delete_url_v4(self):
850+
self._create_signed_delete_url_helper(version="v4")
851+
824852

825853
class TestStorageCompose(TestStorageFiles):
826854

0 commit comments

Comments
 (0)