feat: require standalone admin login before the web workbench

This commit is contained in:
AttilaNet
2026-11-10 19:03:22 +08:00
parent 664db51d3b
commit 0230a933b0
12 changed files with 710 additions and 41 deletions
+11 -5
View File
@@ -513,12 +513,18 @@ class ApiTests(unittest.TestCase):
for url in ("/static/.env", "/static/config.py", "/static/../app.py", "/static/%2e%2e/requirements.txt"):
with self.subTest(url=url):
self.assertEqual(self.client.get(url).status_code, 404)
response = self.client.get("/")
self.assertIn(response.status_code, (200, 503))
if response.status_code == 200:
for url in ("/", "/static/index.html", "/static/app.js"):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers["cache-control"], "no-store")
self.assertEqual(response.headers["x-content-type-options"], "nosniff")
self.assertIn("frame-ancestors 'none'", response.headers["content-security-policy"])
for url in ("/", "/static/index.html"):
response = self.client.get(url)
self.assertIn("text/html", response.headers["content-type"])
self.assertEqual(response.headers["x-content-type-options"], "nosniff")
self.assertIn("frame-ancestors 'none'", response.headers["content-security-policy"])
response = self.client.get("/login", follow_redirects=False)
self.assertEqual(response.status_code, 303)
self.assertEqual(response.headers["location"], "/")
def test_cli_help_and_factory_do_not_import_qt_or_open_private_state(self):
project = Path(__file__).resolve().parents[2]