From 6c5cfc7f458b6fa5780dbbc1f4998967cdcac8e4 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Sun, 31 Mar 2019 22:44:38 -0400 Subject: [PATCH] Add systests for listing bucket blobs (V2/V4). --- storage/tests/system.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/storage/tests/system.py b/storage/tests/system.py index d5c5a166f12e..5ac1f1b9ec60 100644 --- a/storage/tests/system.py +++ b/storage/tests/system.py @@ -19,6 +19,7 @@ import time import unittest +import pytest import requests import six @@ -752,6 +753,42 @@ def tearDown(self): if blob.exists(): retry(blob.delete)() + def _create_signed_list_blobs_url_helper( + self, version, expiration=None, max_age=None, method="GET" + ): + if expiration is None and max_age is None: + max_age = 10 + + signed_url = self.bucket.generate_signed_url( + expiration=expiration, + max_age=max_age, + method=method, + client=Config.CLIENT, + version=version, + ) + + response = requests.get(signed_url) + self.assertEqual(response.status_code, 200) + + def test_create_signed_list_blobs_url_v2(self): + self._create_signed_list_blobs_url_helper(version="v2") + + def test_create_signed_list_blobs_url_v2_w_expiration(self): + now = datetime.datetime.utcnow() + delta = datetime.timedelta(seconds=10) + + self._create_signed_list_blobs_url_helper(expiration=now + delta, version="v2") + + @pytest.mark.skip(reason="Back-end case-flattening bug: revisit 2019-04-03") + def test_create_signed_list_blobs_url_v4(self): + self._create_signed_list_blobs_url_helper(version="v4") + + @pytest.mark.skip(reason="Back-end case-flattening bug: revisit 2019-04-03") + def test_create_signed_list_blobs_url_v4_w_expiration(self): + now = datetime.datetime.utcnow() + delta = datetime.timedelta(seconds=10) + self._create_signed_list_blobs_url_helper(expiration=now + delta, version="v4") + def _create_signed_read_url_helper( self, blob_name="LogoToSign.jpg",