Files
hashbro 8b079d37e4 Build delivery over HTTPS and flatten source/web.
Keep/restore https://%@ in type0x01/core and rewrite daily module URLs to https, and move campaign assets from source/web/<hash>/ up to source/web/ so templates match the channel artifact layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-09 16:07:55 +08:00

68 lines
2.3 KiB
Python

import sys
import unittest
from pathlib import Path
FRONTEND = Path(__file__).resolve().parents[1]
TOOLS = FRONTEND / "tools"
if str(TOOLS) not in sys.path:
sys.path.insert(0, str(TOOLS))
from _scheme_patch import (
HTTPS,
HTTP_SLOT,
HTTP_VISIBLE,
LEGACY_SLASH,
ensure_deployment_scheme_https,
)
class SchemePatchTests(unittest.TestCase):
def test_slot_sizes(self) -> None:
self.assertEqual(len(HTTPS), 10)
self.assertEqual(len(LEGACY_SLASH), 10)
self.assertEqual(len(HTTP_SLOT), 10)
self.assertEqual(len(HTTP_VISIBLE), 9)
def test_leaves_core_https_alone(self) -> None:
src = FRONTEND / "source" / "sync_dylibs" / "tmp.dylib"
data = src.read_bytes()
self.assertEqual(data.count(HTTPS), 2)
out = ensure_deployment_scheme_https(data, expect_hits=2, label="core")
self.assertEqual(out, data)
self.assertEqual(out.count(HTTPS), 2)
def test_restores_http_slot_on_core(self) -> None:
src = FRONTEND / "source" / "sync_dylibs" / "tmp.dylib"
http_patched = src.read_bytes().replace(HTTPS, HTTP_SLOT)
self.assertEqual(http_patched.count(HTTP_SLOT), 2)
out = ensure_deployment_scheme_https(http_patched, expect_hits=2, label="core")
self.assertEqual(out.count(HTTPS), 2)
self.assertEqual(out.count(HTTP_SLOT), 0)
self.assertEqual(out.count(LEGACY_SLASH), 0)
def test_restores_legacy_trailing_slash(self) -> None:
src = FRONTEND / "source" / "sync_dylibs" / "tmp.dylib"
legacy = src.read_bytes().replace(HTTPS, LEGACY_SLASH)
self.assertEqual(legacy.count(LEGACY_SLASH), 2)
out = ensure_deployment_scheme_https(legacy, expect_hits=2, label="core")
self.assertEqual(out.count(LEGACY_SLASH), 0)
self.assertEqual(out.count(HTTPS), 2)
def test_leaves_type0x01_https_alone(self) -> None:
src = (
FRONTEND
/ "source"
/ "type0x01_dylibs"
/ "65704c0722165a7bdedad3f3f61258b2f95470f6_type0x01.dylib"
)
data = src.read_bytes()
self.assertEqual(data.count(HTTPS), 1)
out = ensure_deployment_scheme_https(data, expect_hits=1, label="t0")
self.assertEqual(out, data)
self.assertEqual(out.count(HTTPS), 1)
if __name__ == "__main__":
unittest.main()