support task-selectable SIP trunks

This commit is contained in:
2026-09-17 15:23:46 +08:00
parent 84d86319a3
commit e65cfbe3af
15 changed files with 452 additions and 39 deletions
+31
View File
@@ -308,6 +308,37 @@ class AsteriskTests(unittest.TestCase):
self.assertIn("context=deny-inbound", files["pjsip.conf"])
self.assertIn("strictrtp=yes", files["rtp.conf"])
def test_renders_arbitrary_task_selectable_trunks(self):
cfg = self.cfg()
cfg.pop("primary")
cfg.pop("backup")
cfg["trunks"] = [
{
"trunk_id": "provider-first",
"host": "61.132.228.221",
"auth_mode": "ip",
"caller_id": "BD93205882",
"codec_profile": {"allowed": ["PCMA"], "preferred": "PCMA"},
},
{
"trunk_id": "provider-second",
"host": "60.171.24.90",
"auth_mode": "ip",
"codec_profile": {"allowed": ["PCMA"], "preferred": "PCMA"},
},
{
"trunk_id": "provider-third",
"host": "160.202.254.79",
"auth_mode": "ip",
"codec_profile": {"allowed": ["PCMA"], "preferred": "PCMA"},
},
]
files = ast.render(cfg, {"ARI_PASSWORD": "x" * 32})
for trunk_id in ("provider-first", "provider-second", "provider-third"):
self.assertIn(f"[{trunk_id}]", files["pjsip.conf"])
self.assertNotIn("provider-backup", files["pjsip.conf"])
self.assertIn("PJSIP/${EXTEN}@provider-first", files["extensions.conf"])
def test_preserves_explicit_caller_mapping(self):
cfg = self.cfg()
cfg["primary"].update(