mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 14:59:49 +00:00
Add test for ban exception mode (+e) (#162)
This commit is contained in:
@ -60,6 +60,7 @@ TEMPLATE_CONFIG = """
|
||||
target="services.example.org">
|
||||
|
||||
# Protocol:
|
||||
<module name="banexception">
|
||||
<module name="botmode">
|
||||
<module name="cap">
|
||||
<module name="inviteexception">
|
||||
|
@ -3,9 +3,10 @@ Channel ban (`RFC 1459
|
||||
<https://datatracker.ietf.org/doc/html/rfc1459#section-4.2.3.1>`__,
|
||||
`RFC 2812 <https://datatracker.ietf.org/doc/html/rfc2812#section-3.2.3>`__,
|
||||
`Modern <https://modern.ircdocs.horse/#ban-channel-mode>`__)
|
||||
and ban exception (`Modern <https://modern.ircdocs.horse/#exception-channel-mode>`__)
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest import cases, runner
|
||||
from irctest.numerics import ERR_BANNEDFROMCHAN, RPL_BANLIST, RPL_ENDOFBANLIST
|
||||
from irctest.patma import ANYSTR, StrRe
|
||||
|
||||
@ -33,7 +34,7 @@ class BanModeTestCase(cases.BaseServerTestCase):
|
||||
|
||||
@cases.mark_specifications("Modern")
|
||||
def testBanList(self):
|
||||
"""`RPL_BANLIST <https://modern.ircdocs.horse/#rplbanlist-367>`"""
|
||||
"""`RPL_BANLIST <https://modern.ircdocs.horse/#rplbanlist-367>`_"""
|
||||
self.connectClient("chanop")
|
||||
self.joinChannel(1, "#chan")
|
||||
self.getMessages(1)
|
||||
@ -77,6 +78,65 @@ class BanModeTestCase(cases.BaseServerTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
@cases.mark_specifications("Modern")
|
||||
def testBanException(self):
|
||||
"""`Exception mode <https://modern.ircdocs.horse/#exception-channel-mode`_,
|
||||
detected using `ISUPPORT EXCEPTS
|
||||
<https://modern.ircdocs.horse/#excepts-parameter>`_ and checked against
|
||||
`ISUPPORT CHANMODES <https://modern.ircdocs.horse/#chanmodes-parameter>`_"""
|
||||
self.connectClient("chanop", name="chanop")
|
||||
|
||||
if "EXCEPTS" in self.server_support:
|
||||
mode = self.server_support["EXCEPTS"] or "e"
|
||||
if "CHANMODES" in self.server_support:
|
||||
self.assertIn(
|
||||
mode,
|
||||
self.server_support["CHANMODES"],
|
||||
fail_msg="ISUPPORT EXCEPTS is present, but '{item}' is missing "
|
||||
"from 'CHANMODES={list}'",
|
||||
)
|
||||
self.assertIn(
|
||||
mode,
|
||||
self.server_support["CHANMODES"].split(",")[0],
|
||||
fail_msg="ISUPPORT EXCEPTS is present, but '{item}' is not "
|
||||
"in group A",
|
||||
)
|
||||
else:
|
||||
mode = "e"
|
||||
if "CHANMODES" in self.server_support:
|
||||
if "e" not in self.server_support["CHANMODES"]:
|
||||
raise runner.OptionalExtensionNotSupported(
|
||||
"Ban exception (or mode letter is not +e)"
|
||||
)
|
||||
self.assertIn(
|
||||
mode,
|
||||
self.server_support["CHANMODES"].split(",")[0],
|
||||
fail_msg="Mode +e (assumed to be ban exception) is present, "
|
||||
"but 'e' is not in group A",
|
||||
)
|
||||
else:
|
||||
raise runner.OptionalExtensionNotSupported("ISUPPORT CHANMODES")
|
||||
|
||||
self.sendLine("chanop", "JOIN #chan")
|
||||
self.getMessages("chanop")
|
||||
self.sendLine("chanop", "MODE #chan +b ba*!*@*")
|
||||
self.getMessages("chanop")
|
||||
|
||||
# banned client cannot join
|
||||
self.connectClient("Bar", name="bar")
|
||||
self.sendLine("bar", "JOIN #chan")
|
||||
self.assertMessageMatch(self.getMessage("bar"), command=ERR_BANNEDFROMCHAN)
|
||||
|
||||
# chanop sets exception
|
||||
self.sendLine("chanop", "MODE #chan +e *ar!*@*")
|
||||
self.assertMessageMatch(self.getMessage("chanop"), command="MODE")
|
||||
|
||||
# client can now join
|
||||
self.sendLine("bar", "JOIN #chan")
|
||||
self.assertMessageMatch(self.getMessage("bar"), command="JOIN")
|
||||
|
||||
# TODO: Add testBanExceptionList, once the numerics are specified in Modern
|
||||
|
||||
@cases.mark_specifications("Ergo")
|
||||
def testCaseInsensitive(self):
|
||||
"""Some clients allow unsetting modes if their argument matches
|
||||
|
@ -198,7 +198,7 @@ class MuteExtbanTestCase(cases.BaseServerTestCase):
|
||||
self.getMessages(client)
|
||||
|
||||
# +e grants an exemption to +b
|
||||
self.sendLine("chanop", f"MODE #chan +e {prefix}{self.char()}:*!~evan@*")
|
||||
self.sendLine("chanop", f"MODE #chan +e {prefix}{self.char()}:*!*evan@*")
|
||||
replies = {msg.command for msg in self.getMessages("chanop")}
|
||||
self.assertIn("MODE", replies)
|
||||
self.assertNotIn(ERR_CHANOPRIVSNEEDED, replies)
|
||||
|
Reference in New Issue
Block a user