|
19 | 19 | import time |
20 | 20 | import unittest |
21 | 21 |
|
| 22 | +import pytest |
22 | 23 | import requests |
23 | 24 | import six |
24 | 25 |
|
@@ -752,6 +753,42 @@ def tearDown(self): |
752 | 753 | if blob.exists(): |
753 | 754 | retry(blob.delete)() |
754 | 755 |
|
| 756 | + def _create_signed_list_blobs_url_helper( |
| 757 | + self, version, expiration=None, max_age=None, method="GET" |
| 758 | + ): |
| 759 | + if expiration is None and max_age is None: |
| 760 | + max_age = 10 |
| 761 | + |
| 762 | + signed_url = self.bucket.generate_signed_url( |
| 763 | + expiration=expiration, |
| 764 | + max_age=max_age, |
| 765 | + method=method, |
| 766 | + client=Config.CLIENT, |
| 767 | + version=version, |
| 768 | + ) |
| 769 | + |
| 770 | + response = requests.get(signed_url) |
| 771 | + self.assertEqual(response.status_code, 200) |
| 772 | + |
| 773 | + def test_create_signed_list_blobs_url_v2(self): |
| 774 | + self._create_signed_list_blobs_url_helper(version="v2") |
| 775 | + |
| 776 | + def test_create_signed_list_blobs_url_v2_w_expiration(self): |
| 777 | + now = datetime.datetime.utcnow() |
| 778 | + delta = datetime.timedelta(seconds=10) |
| 779 | + |
| 780 | + self._create_signed_list_blobs_url_helper(expiration=now + delta, version="v2") |
| 781 | + |
| 782 | + @pytest.mark.skip(reason="Back-end case-flattening bug: revisit 2019-04-03") |
| 783 | + def test_create_signed_list_blobs_url_v4(self): |
| 784 | + self._create_signed_list_blobs_url_helper(version="v4") |
| 785 | + |
| 786 | + @pytest.mark.skip(reason="Back-end case-flattening bug: revisit 2019-04-03") |
| 787 | + def test_create_signed_list_blobs_url_v4_w_expiration(self): |
| 788 | + now = datetime.datetime.utcnow() |
| 789 | + delta = datetime.timedelta(seconds=10) |
| 790 | + self._create_signed_list_blobs_url_helper(expiration=now + delta, version="v4") |
| 791 | + |
755 | 792 | def _create_signed_read_url_helper( |
756 | 793 | self, |
757 | 794 | blob_name="LogoToSign.jpg", |
|
0 commit comments