feat: make all operational constants configurable via bouncer.toml
Replace hardcoded values across network, captcha, email, and cert modules with BouncerConfig fields. All values have safe defaults and are overridable in the [bouncer] section of the config file. Configurable: probation_seconds, backoff_steps, nick_timeout, rejoin_delay, http_timeout, captcha_poll_interval/timeout, email_poll_interval/max_polls/request_timeout, cert_validity_days. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,7 @@ def _make_router(*networks: MagicMock) -> MagicMock:
|
||||
router.add_network = AsyncMock()
|
||||
router.remove_network = AsyncMock(return_value=True)
|
||||
router.config = MagicMock()
|
||||
router.config.bouncer.cert_validity_days = 3650
|
||||
return router
|
||||
|
||||
|
||||
@@ -143,7 +144,7 @@ class TestInfo:
|
||||
host="user/fabesune", channels={"#test", "#dev"})
|
||||
router = _make_router(net)
|
||||
router.backlog.list_nickserv_creds.return_value = [
|
||||
("libera", "fabesune", "test@mail.tm", "user/fabesune", 1700000000.0, "verified"),
|
||||
("libera", "fabesune", "test@mail.tm", "user/fabesune", 1700000000.0, "verified", ""),
|
||||
]
|
||||
client = _make_client()
|
||||
lines = await commands.dispatch("INFO libera", router, client)
|
||||
@@ -218,14 +219,15 @@ class TestCreds:
|
||||
net = _make_network("libera", State.READY)
|
||||
router = _make_router(net)
|
||||
router.backlog.list_nickserv_creds.return_value = [
|
||||
("libera", "fabesune", "test@mail.tm", "user/fabesune", 1700000000.0, "verified"),
|
||||
("libera", "oldnick", "old@mail.tm", "old/host", 1699000000.0, "pending"),
|
||||
("libera", "fabesune", "test@mail.tm", "user/fabesune", 1700000000.0, "verified", ""),
|
||||
("libera", "oldnick", "old@mail.tm", "old/host", 1699000000.0, "pending", "https://example.com/verify/abc"),
|
||||
]
|
||||
client = _make_client()
|
||||
lines = await commands.dispatch("CREDS libera", router, client)
|
||||
assert lines[0] == "[CREDS]"
|
||||
assert any("+" in line and "fabesune" in line and "verified" in line for line in lines)
|
||||
assert any("~" in line and "oldnick" in line and "pending" in line for line in lines)
|
||||
assert any("verify: https://example.com/verify/abc" in line for line in lines)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_creds_unknown_network(self) -> None:
|
||||
@@ -758,8 +760,8 @@ class TestDropCreds:
|
||||
net = _make_network("libera", State.READY)
|
||||
router = _make_router(net)
|
||||
router.backlog.list_nickserv_creds.return_value = [
|
||||
("libera", "nick1", "a@b.c", "", 0.0, "verified"),
|
||||
("libera", "nick2", "d@e.f", "", 0.0, "pending"),
|
||||
("libera", "nick1", "a@b.c", "", 0.0, "verified", ""),
|
||||
("libera", "nick2", "d@e.f", "", 0.0, "pending", ""),
|
||||
]
|
||||
client = _make_client()
|
||||
lines = await commands.dispatch("DROPCREDS libera", router, client)
|
||||
|
||||
Reference in New Issue
Block a user