fix: ios 16
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user