重写为多协议管理器: 6 协议, CLI + curses TUI, 用户级 systemd
This commit is contained in:
1 parent
c43ab4a16e
commit
237b958e41
71 files changed
+4599
-1171
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from sbp import net
|
||||
|
||||
ASSETS = [
|
||||
{"name": "sing-box-1.14.4-linux-amd64-musl.tar.gz"},
|
||||
{"name": "sing-box-1.14.4-linux-amd64.tar.gz"},
|
||||
{"name": "sing-box-1.14.4-linux-arm64.tar.gz"},
|
||||
{"name": "sing-box-1.14.4-linux-amd64.deb"},
|
||||
]
|
||||
|
||||
|
||||
def pick(machine: str, libc: tuple[str, str]) -> str:
|
||||
with mock.patch("platform.machine", return_value=machine), mock.patch(
|
||||
"platform.libc_ver", return_value=libc
|
||||
):
|
||||
return net.asset_for(ASSETS, "v1.14.4")["name"]
|
||||
|
||||
|
||||
class AssetTest(unittest.TestCase):
|
||||
def test_glibc_prefers_plain_build(self) -> None:
|
||||
self.assertEqual(pick("x86_64", ("glibc", "2.36")), "sing-box-1.14.4-linux-amd64.tar.gz")
|
||||
|
||||
def test_musl_prefers_musl_build(self) -> None:
|
||||
self.assertEqual(
|
||||
pick("x86_64", ("musl", "1.2")), "sing-box-1.14.4-linux-amd64-musl.tar.gz"
|
||||
)
|
||||
|
||||
def test_arm64_maps_to_arm64(self) -> None:
|
||||
self.assertEqual(pick("aarch64", ("glibc", "2.36")), "sing-box-1.14.4-linux-arm64.tar.gz")
|
||||
|
||||
def test_unknown_arch_fails(self) -> None:
|
||||
with self.assertRaises(Exception):
|
||||
pick("riscv64", ("glibc", "2.36"))
|
||||
|
||||
|
||||
class DigestTest(unittest.TestCase):
|
||||
def test_missing_digest_is_not_verified(self) -> None:
|
||||
self.assertFalse(net.verify_digest(__file__, {}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user