iOS 1.0.3 source candidate only; no Apple build or installation acceptance
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
"""Exercise the source-audit boundary; these are not Swift runtime tests."""
|
||||
from contextlib import redirect_stdout
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import plistlib
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
SCRIPT = Path(__file__).resolve().parents[1] / "source-audit.py"
|
||||
spec = importlib.util.spec_from_file_location("ios_source_audit", SCRIPT)
|
||||
audit = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(audit)
|
||||
SOURCE = SCRIPT.parent.parent
|
||||
|
||||
|
||||
class SourceAuditTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temporary.cleanup)
|
||||
self.root = Path(self.temporary.name) / "ios"
|
||||
shutil.copytree(SOURCE, self.root,
|
||||
ignore=shutil.ignore_patterns(".git", "Vendor", "BuildArtifacts", "__pycache__"))
|
||||
self.original = audit.ROOT
|
||||
audit.ROOT = self.root
|
||||
self.addCleanup(setattr, audit, "ROOT", self.original)
|
||||
|
||||
def run_audit(self):
|
||||
output = io.StringIO()
|
||||
with redirect_stdout(output):
|
||||
result = audit.main()
|
||||
self.assertEqual(result, 0)
|
||||
return json.loads(output.getvalue())
|
||||
|
||||
def test_valid_source_reports_only_source_acceptance(self):
|
||||
report = self.run_audit()
|
||||
self.assertEqual(report["source_version"], "1.0.3")
|
||||
self.assertFalse(report["swift_compilation_executed"])
|
||||
self.assertFalse(report["xctest_executed"])
|
||||
self.assertFalse(report["ipa_generated"])
|
||||
self.assertFalse(report["device_installation_verified"])
|
||||
|
||||
def test_missing_shared_policy_stops_audit(self):
|
||||
(self.root / "Shared/ProxyTransportPolicy.swift").unlink()
|
||||
with self.assertRaisesRegex(RuntimeError, "ProxyTransportPolicy"):
|
||||
self.run_audit()
|
||||
|
||||
def test_unbundled_artwork_stops_audit(self):
|
||||
path = self.root / "Resources/Assets.xcassets/MountainLandscape.imageset/Contents.json"
|
||||
path.write_text('{"images":[]}', encoding="utf-8")
|
||||
with self.assertRaisesRegex(RuntimeError, "山水资源"):
|
||||
self.run_audit()
|
||||
|
||||
def test_modified_artwork_stops_audit(self):
|
||||
path = self.root / "Resources/Assets.xcassets/MountainLandscape.imageset/landscape-header-v1.png"
|
||||
path.write_bytes(b"replaced artwork")
|
||||
with self.assertRaisesRegex(RuntimeError, "山水图"):
|
||||
self.run_audit()
|
||||
|
||||
def test_missing_extension_entitlement_stops_audit(self):
|
||||
path = self.root / "PacketTunnel/PacketTunnel.entitlements"
|
||||
path.write_bytes(plistlib.dumps({}))
|
||||
with self.assertRaisesRegex(RuntimeError, "权限缺失"):
|
||||
self.run_audit()
|
||||
|
||||
def test_version_mismatch_stops_audit(self):
|
||||
path = self.root / "README.md"
|
||||
path.write_text(path.read_text(encoding="utf-8").replace("1.0.3", "1.0.2"), encoding="utf-8")
|
||||
with self.assertRaisesRegex(RuntimeError, "版本不一致"):
|
||||
self.run_audit()
|
||||
|
||||
def test_modified_vendor_archive_stops_audit(self):
|
||||
path = self.root / "Vendor/libxray-apple-cgo-v26.7.28.zip"
|
||||
path.parent.mkdir()
|
||||
path.write_bytes(b"untrusted binary")
|
||||
with self.assertRaisesRegex(RuntimeError, "libXray"):
|
||||
self.run_audit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user