Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check behavior of PRIVMSG when banned #226

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 56 additions & 3 deletions irctest/server_tests/chmodes/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
"""

from irctest import cases, runner
from irctest.numerics import ERR_BANNEDFROMCHAN, RPL_BANLIST, RPL_ENDOFBANLIST
from irctest.numerics import (
ERR_BANNEDFROMCHAN,
ERR_CANNOTSENDTOCHAN,
RPL_BANLIST,
RPL_ENDOFBANLIST,
)
from irctest.patma import ANYSTR, StrRe


class BanModeTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
def testBan(self):
"""Basic ban operation"""
def testBanJoin(self):
self.connectClient("chanop", name="chanop")
self.joinChannel("chanop", "#chan")
self.getMessages("chanop")
Expand All @@ -32,6 +36,55 @@ def testBan(self):
self.sendLine("bar", "JOIN #chan")
self.assertMessageMatch(self.getMessage("bar"), command="JOIN")

@cases.mark_specifications("Modern")
def testBanPrivmsg(self):
"""
TODO: this checks the following quote is false:

"If `<target>` is a channel name and the client is [banned](#ban-channel-mode)
and not covered by a [ban exception](#ban-exception-channel-mode), the
message will not be delivered and the command will silently fail."
-- https://modern.ircdocs.horse/#privmsg-message

to check https://github.com/ircdocs/modern-irc/pull/201
"""
self.connectClient("chanop", name="chanop")
self.joinChannel("chanop", "#chan")
self.getMessages("chanop")

self.connectClient("Bar", name="bar")
self.getMessages("bar")
self.sendLine("bar", "JOIN #chan")
self.getMessages("bar")
self.getMessages("chanop")

self.sendLine("chanop", "MODE #chan +b bar!*@*")
self.assertMessageMatch(self.getMessage("chanop"), command="MODE")
self.getMessages("chanop")
self.getMessages("bar")

self.sendLine("bar", "PRIVMSG #chan :hello world")
self.assertMessageMatch(
self.getMessage("bar"),
command=ERR_CANNOTSENDTOCHAN,
params=["Bar", "#chan", ANYSTR],
)
self.assertEqual(self.getMessages("bar"), [])
self.assertEqual(self.getMessages("chanop"), [])

self.sendLine("chanop", "MODE #chan -b bar!*@*")
self.assertMessageMatch(self.getMessage("chanop"), command="MODE")
self.getMessages("chanop")
self.getMessages("bar")

self.sendLine("bar", "PRIVMSG #chan :hello again")
self.assertEqual(self.getMessages("bar"), [])
self.assertMessageMatch(
self.getMessage("chanop"),
command="PRIVMSG",
params=["#chan", "hello again"],
)

@cases.mark_specifications("Modern")
def testBanList(self):
"""`RPL_BANLIST <https://modern.ircdocs.horse/#rplbanlist-367>`_"""
Expand Down