mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 06:49:47 +00:00
Run utf8 tests on servers which advertise UTF8ONLY (#185)
This commit is contained in:
@ -1,36 +1,21 @@
|
||||
"""
|
||||
`Ergo <https://ergo.chat/>`_-specific tests of non-Unicode filtering
|
||||
|
||||
TODO: turn this into a test of `IRCv3 UTF8ONLY
|
||||
<https://ircv3.net/specs/extensions/utf8-only>`_
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest import cases, runner
|
||||
from irctest.patma import ANYSTR
|
||||
|
||||
|
||||
class Utf8TestCase(cases.BaseServerTestCase):
|
||||
@cases.mark_specifications("Ergo")
|
||||
def testUtf8Validation(self):
|
||||
def testNonUtf8Filtering(self):
|
||||
self.connectClient(
|
||||
"bar",
|
||||
capabilities=["batch", "echo-message", "labeled-response"],
|
||||
)
|
||||
self.joinChannel(1, "#qux")
|
||||
self.sendLine(1, "PRIVMSG #qux hi")
|
||||
ms = self.getMessages(1)
|
||||
self.assertMessageMatch(
|
||||
[m for m in ms if m.command == "PRIVMSG"][0], params=["#qux", "hi"]
|
||||
)
|
||||
|
||||
self.sendLine(1, b"PRIVMSG #qux hi\xaa")
|
||||
self.assertMessageMatch(
|
||||
self.getMessage(1),
|
||||
command="FAIL",
|
||||
params=["PRIVMSG", "INVALID_UTF8", ANYSTR],
|
||||
tags={},
|
||||
)
|
||||
|
||||
self.sendLine(1, b"@label=xyz PRIVMSG #qux hi\xaa")
|
||||
self.assertMessageMatch(
|
||||
self.getMessage(1),
|
||||
@ -38,3 +23,25 @@ class Utf8TestCase(cases.BaseServerTestCase):
|
||||
params=["PRIVMSG", "INVALID_UTF8", ANYSTR],
|
||||
tags={"label": "xyz"},
|
||||
)
|
||||
|
||||
@cases.mark_isupport("UTF8ONLY")
|
||||
def testUtf8Validation(self):
|
||||
self.connectClient("foo")
|
||||
self.connectClient("bar")
|
||||
|
||||
if "UTF8ONLY" not in self.server_support:
|
||||
raise runner.IsupportTokenNotSupported("UTF8ONLY")
|
||||
|
||||
self.sendLine(1, "PRIVMSG bar hi")
|
||||
ms = self.getMessages(2)
|
||||
self.assertMessageMatch(
|
||||
[m for m in ms if m.command == "PRIVMSG"][0], params=["bar", "hi"]
|
||||
)
|
||||
|
||||
self.sendLine(1, b"PRIVMSG bar hi\xaa")
|
||||
|
||||
m = self.getMessage(1)
|
||||
assert m.command in ("FAIL", "WARN", "ERROR")
|
||||
|
||||
if m.command in ("FAIL", "WARN"):
|
||||
self.assertMessageMatch(m, params=["PRIVMSG", "INVALID_UTF8", ANYSTR])
|
||||
|
@ -56,6 +56,7 @@ class IsupportTokens(enum.Enum):
|
||||
MONITOR = "MONITOR"
|
||||
STATUSMSG = "STATUSMSG"
|
||||
TARGMAX = "TARGMAX"
|
||||
UTF8ONLY = "UTF8ONLY"
|
||||
WHOX = "WHOX"
|
||||
|
||||
@classmethod
|
||||
|
@ -38,6 +38,7 @@ markers =
|
||||
PREFIX
|
||||
STATUSMSG
|
||||
TARGMAX
|
||||
UTF8ONLY
|
||||
WHOX
|
||||
|
||||
python_classes = *TestCase Test*
|
||||
|
Reference in New Issue
Block a user