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

Add test for mode +C ('no ctcp') #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions irctest/controllers/inspircd.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<module name="monitor">
<module name="m_muteban"> # for testing mute extbans
<module name="namesx"> # For multi-prefix
<module name="noctcp">
<module name="sasl">

# HELP/HELPOP
Expand Down
69 changes: 69 additions & 0 deletions irctest/server_tests/chmodes/noctcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from irctest import cases, runner
from irctest.numerics import ERR_CANNOTSENDTOCHAN
from irctest.patma import ANYSTR


class NoctcpModeTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("Modern")
def testNoctcpMode(self):
"""
"This mode is used in almost all IRC software today. The standard mode letter
used for it is `"+C"`.
When this mode is set, should not send [CTCP](/ctcp.html) messages, except
CTCP Action (also known as `/me`) to the channel.
When blocking a message because of this mode, servers SHOULD use
ERR_CANNOTSENDTOCHAN"
-- TODO add link
"""
self.connectClient("chanop")

if "C" not in self.server_support.get("CHANMODES", ""):
raise runner.NotImplementedByController("+C (noctcp) channel mode")

# Both users join:

self.sendLine(1, "JOIN #chan")
self.getMessages(1) # synchronize

self.connectClient("user")
self.sendLine(2, "JOIN #chan")
self.getMessages(2)
self.getMessages(1)

# Send ACTION and PING, both should go through:

self.sendLine(2, "PRIVMSG #chan :\x01ACTION is testing\x01")
self.sendLine(2, "PRIVMSG #chan :\x01PING 12345\x01")
self.assertEqual(self.getMessages(2), [])

self.assertEqual(
[(m.command, m.params[1]) for m in self.getMessages(1)],
[
("PRIVMSG", "\x01ACTION is testing\x01"),
("PRIVMSG", "\x01PING 12345\x01"),
],
)

# Set mode +C:

self.sendLine(1, "MODE #chan +C")
self.getMessages(1)
self.getMessages(2)

# Send ACTION and PING, only ACTION should go through:

self.sendLine(2, "PRIVMSG #chan :\x01ACTION is testing\x01")
self.assertEqual(self.getMessages(2), [])
self.sendLine(2, "PRIVMSG #chan :\x01PING 12345\x01")
self.assertMessageMatch(
self.getMessage(2),
command=ERR_CANNOTSENDTOCHAN,
params=["user", "#chan", ANYSTR],
)

self.assertEqual(
[(m.command, m.params[1]) for m in self.getMessages(1)],
[
("PRIVMSG", "\x01ACTION is testing\x01"),
],
)
Loading