Skip to content

Commit

Permalink
sable: Rely on SASL PLAIN instead of NickServ to check for services a…
Browse files Browse the repository at this point in the history
…vailability
  • Loading branch information
progval committed Dec 8, 2024
1 parent c97753d commit b843581
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions irctest/controllers/sable.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
NotImplementedByController,
)
from irctest.cases import BaseServerTestCase
from irctest.client_mock import ClientMock
from irctest.exceptions import NoMessageException
from irctest.patma import ANYSTR

Expand Down Expand Up @@ -554,6 +555,42 @@ class SableServicesController(BaseServicesController):

faketime_cmd: Sequence[str]

def wait_for_services(self) -> None:
"""Overrides the default implementation, as it relies on
``PRIVMSG NickServ: HELP``, which always succeeds on Sable.
Instead, this relies on SASL PLAIN availability."""
if self.services_up:
# Don't check again if they are already available
return
self.server_controller.wait_for_port()

c = ClientMock(name="chkSASL", show_io=True)
c.connect(self.server_controller.hostname, self.server_controller.port)

def wait() -> None:
while True:
c.sendLine("CAP LS 302")
for msg in c.getMessages(synchronize=False):
if msg.command == "CAP":
assert msg.params[-2] == "LS", msg
for cap in msg.params[-1].split():
if cap.startswith("sasl="):
mechanisms = cap.split("=", 1)[1].split(",")
if "PLAIN" in mechanisms:
return
else:
if msg.params[0] == "*":
# End of CAP LS
time.sleep(self.server_controller.sync_sleep_time)

wait()

c.sendLine("QUIT")
c.getMessages()
c.disconnect()
self.services_up = True

def run(self, protocol: str, server_hostname: str, server_port: int) -> None:
assert protocol == "sable"
assert self.server_controller.directory is not None
Expand Down

0 comments on commit b843581

Please sign in to comment.