This commit is contained in:
hashbro
2026-08-24 07:19:10 +08:00
parent cd07fe62fd
commit 2c11a46f17
4 changed files with 60 additions and 4 deletions
@@ -65,6 +65,38 @@ class BuildTest(unittest.TestCase):
)
self.assertEqual((host, port, origin), ("lab.example", 8443, "https://lab.example:8443"))
def test_origin_rewrites_lab_template_config(self) -> None:
(self.source / "config.js").write_text(
'window.NEWS2_CONFIG = {\n'
' exfil: {\n'
' host: "192.168.31.130",\n'
' domain: "192.168.31.130",\n'
' http_port: 8000,\n'
' https_port: 8000,\n'
' tls: false,\n'
' prefer_https: false,\n'
' },\n'
' redirectUrl: "https://ab.ux600.com",\n'
'};\n',
encoding="utf-8",
)
build.build(
self.source,
self.dest,
"c2.example.com",
443,
"https://c2.example.com",
)
published = (self.dest / "config.js").read_text(encoding="utf-8")
self.assertIn('host: "c2.example.com"', published)
self.assertIn('domain: "c2.example.com"', published)
self.assertIn("http_port: 443", published)
self.assertIn("https_port: 443", published)
self.assertIn("tls: true", published)
self.assertIn("https://c2.example.com/?landed=1", published)
self.assertNotIn("192.168.31.130", published)
self.assertNotIn("ab.ux600.com", published)
if __name__ == "__main__":
unittest.main()