fix(wiki): proxy topology through public gateway

Co-Authored-By: OpenAI Codex <codex@openai.com>
This commit is contained in:
2026-07-15 10:53:18 +08:00
co-authored by OpenAI Codex
parent e3b3a16b10
commit 8d057dbfa3
9 changed files with 81 additions and 5 deletions
+2 -1
View File
@@ -37,7 +37,8 @@ class GuanghanTopologySourceTests(unittest.TestCase):
self.assertNotIn("未来西部十字结构", self.html)
def test_page_uses_same_origin_api(self) -> None:
self.assertIn("const API_BASE = ''", self.html)
self.assertIn("new URL('.', window.location.href).pathname", self.html)
self.assertIn("replace(/\\/$/, '')", self.html)
self.assertNotIn("http://localhost:5000", self.html)
def test_page_uses_database_presentation_payload(self) -> None:
+2 -1
View File
@@ -32,7 +32,8 @@ class TopologyApiServingTests(unittest.TestCase):
def test_page_uses_same_origin_api(self) -> None:
html = HTML_PATH.read_text(encoding="utf-8")
self.assertNotIn("http://localhost:5000", html)
self.assertIn("const API_BASE = ''", html)
self.assertIn("new URL('.', window.location.href).pathname", html)
self.assertIn("replace(/\\/$/, '')", html)
def test_config_has_no_default_password(self) -> None:
source = CONFIG_PATH.read_text(encoding="utf-8")
+29
View File
@@ -0,0 +1,29 @@
import unittest
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
DEMO_PATH = PROJECT_ROOT / "data" / "wiki" / "guanghan_topology_demo.html"
GHC05_PATH = PROJECT_ROOT / "data" / "wiki" / "guanghan_ghc05_zh.html"
class WikiTopologyProxyTests(unittest.TestCase):
def test_demo_derives_api_prefix_from_document_url(self):
html = DEMO_PATH.read_text(encoding="utf-8")
self.assertIn("new URL('.', window.location.href).pathname", html)
self.assertIn("replace(/\\/$/, '')", html)
def test_ghc05_embed_uses_public_proxy_instead_of_private_backend(self):
html = GHC05_PATH.read_text(encoding="utf-8")
public_url = (
"http://118.89.192.134:59100/topology/"
"guanghan_topology_demo.html?mission=GHC-05"
)
self.assertEqual(html.count(public_url), 2)
self.assertNotIn("192.168.195.241:38080", html)
if __name__ == "__main__":
unittest.main()