irctest/irctest/controllers/girc.py

39 lines
1.1 KiB
Python
Raw Normal View History

2016-12-01 09:43:30 +00:00
import subprocess
from typing import Optional, Type
2016-12-01 09:43:30 +00:00
from irctest import authentication, tls
from irctest.basecontrollers import (
BaseClientController,
DirectoryBasedController,
NotImplementedByController,
)
2016-12-01 09:43:30 +00:00
2021-02-22 18:02:13 +00:00
class GircController(BaseClientController, DirectoryBasedController):
2021-02-22 18:02:13 +00:00
software_name = "gIRC"
supported_sasl_mechanisms = {"PLAIN"}
def run(
self,
hostname: str,
port: int,
auth: Optional[authentication.Authentication],
tls_config: Optional[tls.TlsConfig] = None,
) -> None:
2016-12-01 09:43:30 +00:00
if tls_config:
print(tls_config)
2021-02-22 18:02:13 +00:00
raise NotImplementedByController("TLS options")
args = ["--host", hostname, "--port", str(port), "--quiet"]
2016-12-01 09:43:30 +00:00
if auth and auth.username and auth.password:
2021-02-22 18:02:13 +00:00
args += ["--sasl-name", auth.username]
args += ["--sasl-pass", auth.password]
args += ["--sasl-fail-is-ok"]
2016-12-01 09:43:30 +00:00
# Runs a client with the config given as arguments
2021-02-22 18:02:13 +00:00
self.proc = subprocess.Popen(["girc_test", "connect"] + args)
2016-12-01 09:43:30 +00:00
def get_irctest_controller_class() -> Type[GircController]:
2016-12-01 09:43:30 +00:00
return GircController