Lock down the local release console
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
@@ -36,6 +37,30 @@ class ReleaseConsoleSecurityTests(unittest.TestCase):
|
||||
self.assertIn("window.location.hash.slice(1)", webui)
|
||||
self.assertIn("history.replaceState", webui)
|
||||
|
||||
def test_tokenless_embedding_is_read_only(self) -> None:
|
||||
with TestClient(create_app(workspace_root=META_ROOT)) as client:
|
||||
read_response = client.get("/api/health")
|
||||
write_response = client.post("/api/selective-plan", json={})
|
||||
|
||||
self.assertEqual(200, read_response.status_code)
|
||||
self.assertEqual(403, write_response.status_code)
|
||||
self.assertIn("read-only", write_response.json()["detail"])
|
||||
|
||||
def test_launcher_rejects_non_loopback_and_tokenless_modes(self) -> None:
|
||||
launcher = RELEASE_ROOT / "release-console.py"
|
||||
for arguments in (("--host", "0.0.0.0"), ("--no-token",)):
|
||||
with self.subTest(arguments=arguments):
|
||||
result = subprocess.run(
|
||||
(sys.executable, str(launcher), *arguments),
|
||||
cwd=META_ROOT,
|
||||
check=False,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
timeout=10,
|
||||
)
|
||||
self.assertEqual(2, result.returncode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user