diff --git a/irctest/server_tests/chmodes/ban.py b/irctest/server_tests/chmodes/ban.py index d0f4829..0dd204e 100644 --- a/irctest/server_tests/chmodes/ban.py +++ b/irctest/server_tests/chmodes/ban.py @@ -7,14 +7,18 @@ and ban exception (`Modern ` 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.assertMessageMatch( + self.getMessage("chanop"), + command="PRIVMSG", + params=["#chan", "hello again"], + ) + self.assertEqual(self.getMessages("bar"), []) + @cases.mark_specifications("Modern") def testBanList(self): """`RPL_BANLIST `_"""