fix(static-sites): retry Bunny zone credential propagation
This commit is contained in:
parent
86964aa187
commit
d9ea6cf9b7
2 changed files with 55 additions and 18 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import importlib.util
|
||||
from io import BytesIO
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
|
@ -91,6 +92,29 @@ class StaticSiteTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(DeployError, "HTTPS origin"):
|
||||
purge_bunny_gateway(endpoint, "example-org", "password")
|
||||
|
||||
@mock.patch.object(static_site.time, "sleep")
|
||||
@mock.patch.object(static_site.urllib.request, "urlopen")
|
||||
def test_storage_retries_transient_new_zone_authentication(
|
||||
self, urlopen: mock.Mock, sleep: mock.Mock
|
||||
) -> None:
|
||||
unauthorized = static_site.urllib.error.HTTPError(
|
||||
"https://storage.example/example/.static-site-manifest.json",
|
||||
401,
|
||||
"Unauthorized",
|
||||
{},
|
||||
BytesIO(b'{"HttpCode":401,"Message":"Unauthorized"}'),
|
||||
)
|
||||
response = mock.MagicMock()
|
||||
response.__enter__.return_value.read.return_value = b"manifest"
|
||||
urlopen.side_effect = [unauthorized, response]
|
||||
storage = static_site.BunnyStorage(
|
||||
"example", "new-password", "storage.example"
|
||||
)
|
||||
|
||||
self.assertEqual(storage.get_manifest(), b"manifest")
|
||||
sleep.assert_called_once_with(1)
|
||||
self.assertEqual(urlopen.call_count, 2)
|
||||
|
||||
@mock.patch.object(static_site.urllib.request, "urlopen")
|
||||
def test_gateway_reuses_storage_password(self, urlopen: mock.Mock) -> None:
|
||||
urlopen.return_value.__enter__.return_value = object()
|
||||
|
|
|
|||
Loading…
Reference in a new issue