echo/testing/fedserv_services.py
Jean 7929f5f9f4
Fix InspIRCd UID and message-tag parsing; add irctest controller
The UID introduction omitted the second user field (insp sends both a real and a
displayed user), and the parser didn't strip IRCv3 message-tag prefixes, so
tagged PRIVMSGs addressed to a service were dropped. With both fixed a service
links to a real insp4 uplink and answers commands. Adds an irctest services
controller so this is verified against an isolated, throwaway ircd.
2026-07-11 19:59:47 +00:00

57 lines
1.7 KiB
Python

"""irctest controller for fedserv.
Copy (or symlink) this file into irctest's ``irctest/controllers/`` directory,
then run the services tests against an isolated InspIRCd + fedserv:
FEDSERV_BIN=/path/to/federated-services/target/release/fedserv \\
PATH=/path/to/inspircd/run/bin:$PATH \\
python -m pytest \\
--controller=irctest.controllers.inspircd \\
--services-controller=irctest.controllers.fedserv_services \\
irctest/server_tests/account_registration.py
irctest spawns its own ircd + services on random ports, so this never touches a
real network. See https://github.com/progval/irctest
"""
import os
import shutil
from typing import Type
from irctest.basecontrollers import BaseServicesController, DirectoryBasedController
CONFIG = """\
[uplink]
host = "{server_hostname}"
port = {server_port}
password = "password"
[server]
name = "My.Little.Services"
sid = "42S"
description = "Federated Services"
protocol = 1206
"""
class FedservController(BaseServicesController, DirectoryBasedController):
software_name = "fedserv"
saslserv = "NickServ"
def run(self, protocol: str, server_hostname: str, server_port: int) -> None:
self.create_config()
assert protocol in ("inspircd", "inspircd3"), f"fedserv speaks inspircd, not {protocol}"
binary = (
os.environ.get("FEDSERV_BIN")
or shutil.which("fedserv")
or "target/release/fedserv"
)
with self.open_file("config.toml") as fd:
fd.write(CONFIG.format(server_hostname=server_hostname, server_port=server_port))
self.proc = self.execute([binary, "config.toml"], cwd=self.directory)
def get_irctest_controller_class() -> Type[FedservController]:
return FedservController