feat: SPA sites
This commit is contained in:
@@ -465,6 +465,29 @@ class TestRequestHandler(BaseHandlerTestCase):
|
||||
):
|
||||
handler.do_PUT()
|
||||
|
||||
def test_do_put_extract_with_spa(self) -> None:
|
||||
handler = self._get_handler(
|
||||
"/path", {"X-Token": "secret", "X-SPA": "index.html", "Content-Length": "1"}
|
||||
)
|
||||
handler.rfile.write(b"\0")
|
||||
with (
|
||||
self.mock_call(self.token_manager.is_valid, ["secret"], True), # noqa: FBT003
|
||||
self.mock_call(
|
||||
self.token_manager.is_valid_for_path,
|
||||
["secret", "path"],
|
||||
True, # noqa: FBT003
|
||||
),
|
||||
self.mock_call_unchecked(self.data_dir.extract_tar_bytes),
|
||||
self.mock_call(self.registry.add, ["path"]),
|
||||
self.mock_call(self.token_manager.set_token, ["path", "secret"]),
|
||||
self.mock_call(self.registry.set_spa, ["path", "index.html"]),
|
||||
self.expects_status_only(
|
||||
handler, http.HTTPStatus.CREATED, "Resource /path/ updated"
|
||||
),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
handler.do_PUT()
|
||||
|
||||
def test_do_put_redirect_with_content(self) -> None:
|
||||
handler = self._get_handler(
|
||||
"/path",
|
||||
@@ -1166,6 +1189,23 @@ class TestRequestHandler(BaseHandlerTestCase):
|
||||
"",
|
||||
)
|
||||
|
||||
def test_translate_path_spa(self) -> None:
|
||||
handler = self._get_handler()
|
||||
with (
|
||||
self.mock_call(
|
||||
self.registry.get_from_path, ["path"], Page("path", spa="index.html")
|
||||
),
|
||||
self.patch_call(
|
||||
"http.server.SimpleHTTPRequestHandler.translate_path",
|
||||
["/path/index.html"],
|
||||
),
|
||||
self.seal_mocks(),
|
||||
):
|
||||
self.assertEqual(
|
||||
handler.translate_path("/path/to/thing"),
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
class TestUpgradeHandler(BaseHandlerTestCase):
|
||||
@typing.override
|
||||
|
||||
Reference in New Issue
Block a user