mirror of https://github.com/progval/irctest.git
Add tests for PRIVMSG to a server mask
https://github.com/ircdocs/modern-irc/pull/134 A bunch of tests are failing, we need to work this out in the Modern PR Note: it needs the following patch to plexus4 to be relevant: ```diff diff --git a/modules/core/m_message.c b/modules/core/m_message.c index adf0821..7568f20 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -575,7 +575,7 @@ handle_special(int p_or_n, const char *command, struct Client *client_p, return; } - if (MyClient(source_p) && !HasUMode(source_p, UMODE_NETADMIN) && !HasFlag(source_p, FLAGS_SERVICE) && strcmp(nick + 1, me.name)) + if (false) { sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, source_p->name); return; ``` (I'm too lazy to figure out how to become a netadmin)
This commit is contained in:
parent
59a8a3e270
commit
7b273443ef
|
@ -22,7 +22,7 @@ TEMPLATE_CONFIG = """
|
||||||
<class
|
<class
|
||||||
name="ServerOperators"
|
name="ServerOperators"
|
||||||
commands="WALLOPS GLOBOPS"
|
commands="WALLOPS GLOBOPS"
|
||||||
privs="channels/auspex users/auspex channels/auspex servers/auspex"
|
privs="channels/auspex users/auspex channels/auspex servers/auspex users/mass-message"
|
||||||
>
|
>
|
||||||
<type
|
<type
|
||||||
name="NetAdmin"
|
name="NetAdmin"
|
||||||
|
|
|
@ -3,8 +3,8 @@ Section 3.2 of RFC 2812
|
||||||
<https://tools.ietf.org/html/rfc2812#section-3.3>
|
<https://tools.ietf.org/html/rfc2812#section-3.3>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from irctest import cases
|
from irctest import cases, runner
|
||||||
from irctest.numerics import ERR_INPUTTOOLONG
|
from irctest.numerics import ERR_INPUTTOOLONG, ERR_NOPRIVILEGES, ERR_NOSUCHNICK
|
||||||
|
|
||||||
|
|
||||||
class PrivmsgTestCase(cases.BaseServerTestCase):
|
class PrivmsgTestCase(cases.BaseServerTestCase):
|
||||||
|
@ -34,6 +34,97 @@ class PrivmsgTestCase(cases.BaseServerTestCase):
|
||||||
self.assertIn(msg.command, ("401", "403", "404"))
|
self.assertIn(msg.command, ("401", "403", "404"))
|
||||||
|
|
||||||
|
|
||||||
|
class PrivmsgServermaskTestCase(cases.BaseServerTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
self.connectClient("chk", "chk")
|
||||||
|
self.sendLine("chk", "PRIVMSG $my.little.server :hello there")
|
||||||
|
msg = self.getMessage("chk")
|
||||||
|
if msg.command == ERR_NOSUCHNICK:
|
||||||
|
raise runner.NotImplementedByController("PRIVMSG to server mask")
|
||||||
|
|
||||||
|
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
|
||||||
|
def testPrivmsgServermask(self):
|
||||||
|
"""
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc1459#section-4.4.1>
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc2812>
|
||||||
|
<https://github.com/ircdocs/modern-irc/pull/134>
|
||||||
|
"""
|
||||||
|
self.connectClient("sender", "sender")
|
||||||
|
self.connectClient("user", "user")
|
||||||
|
|
||||||
|
self.sendLine("sender", "OPER operuser operpassword")
|
||||||
|
self.getMessages("sender")
|
||||||
|
|
||||||
|
self.sendLine("sender", "PRIVMSG $*.server :hello there")
|
||||||
|
self.getMessages("sender")
|
||||||
|
self.assertMessageMatch(
|
||||||
|
self.getMessage("user"),
|
||||||
|
command="PRIVMSG",
|
||||||
|
params=["$*.server", "hello there"],
|
||||||
|
)
|
||||||
|
|
||||||
|
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
|
||||||
|
def testPrivmsgServermaskNoMatch(self):
|
||||||
|
"""
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc1459#section-4.4.1>
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc2812>
|
||||||
|
<https://github.com/ircdocs/modern-irc/pull/134>
|
||||||
|
"""
|
||||||
|
self.connectClient("sender", "sender")
|
||||||
|
self.connectClient("user", "user")
|
||||||
|
|
||||||
|
self.sendLine("sender", "OPER operuser operpassword")
|
||||||
|
self.getMessages("sender")
|
||||||
|
|
||||||
|
self.sendLine("sender", "PRIVMSG $*.foobar :hello there")
|
||||||
|
messages = self.getMessages("sender")
|
||||||
|
self.assertEqual(len(messages), 0, messages)
|
||||||
|
messages = self.getMessages("user")
|
||||||
|
self.assertEqual(len(messages), 0, messages)
|
||||||
|
|
||||||
|
@cases.mark_specifications("Modern")
|
||||||
|
def testPrivmsgServermaskStar(self):
|
||||||
|
"""
|
||||||
|
<https://github.com/ircdocs/modern-irc/pull/134>
|
||||||
|
|
||||||
|
Note: 1459 and 2812 explicitly forbid "$*" as target.
|
||||||
|
"""
|
||||||
|
self.connectClient("sender", "sender")
|
||||||
|
self.connectClient("user", "user")
|
||||||
|
|
||||||
|
self.sendLine("sender", "OPER operuser operpassword")
|
||||||
|
self.getMessages("sender")
|
||||||
|
|
||||||
|
self.connectClient("user", "user")
|
||||||
|
|
||||||
|
self.sendLine("sender", "OPER operuser operpassword")
|
||||||
|
self.getMessages("sender")
|
||||||
|
|
||||||
|
self.sendLine("sender", "PRIVMSG $* :hello there")
|
||||||
|
self.getMessages("sender")
|
||||||
|
self.assertMessageMatch(
|
||||||
|
self.getMessage("user"), command="PRIVMSG", params=["$*", "hello there"]
|
||||||
|
)
|
||||||
|
|
||||||
|
@cases.mark_specifications("RFC1459", "RFC2812", "Modern")
|
||||||
|
def testPrivmsgServermaskNotOper(self):
|
||||||
|
"""
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc1459#section-4.4.1>
|
||||||
|
<https://datatracker.ietf.org/doc/html/rfc2812>
|
||||||
|
<https://github.com/ircdocs/modern-irc/pull/134>
|
||||||
|
"""
|
||||||
|
self.connectClient("sender", "sender")
|
||||||
|
self.connectClient("user", "user")
|
||||||
|
|
||||||
|
self.sendLine("sender", "PRIVMSG $*.foobar :hello there")
|
||||||
|
self.assertMessageMatch(self.getMessage("sender"), command=ERR_NOPRIVILEGES)
|
||||||
|
|
||||||
|
pms = [msg for msg in self.getMessages("user") if msg.command == "PRIVMSG"]
|
||||||
|
self.assertEqual(len(pms), 0)
|
||||||
|
|
||||||
|
|
||||||
class NoticeTestCase(cases.BaseServerTestCase):
|
class NoticeTestCase(cases.BaseServerTestCase):
|
||||||
@cases.mark_specifications("RFC1459", "RFC2812")
|
@cases.mark_specifications("RFC1459", "RFC2812")
|
||||||
def testNotice(self):
|
def testNotice(self):
|
||||||
|
|
Loading…
Reference in New Issue