diff --git a/irctest/server_tests/utf8.py b/irctest/server_tests/utf8.py
index ccd8156..14cb1dc 100644
--- a/irctest/server_tests/utf8.py
+++ b/irctest/server_tests/utf8.py
@@ -1,36 +1,21 @@
"""
`Ergo `_-specific tests of non-Unicode filtering
-TODO: turn this into a test of `IRCv3 UTF8ONLY
`_
"""
-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])
diff --git a/irctest/specifications.py b/irctest/specifications.py
index 99e0646..35510c0 100644
--- a/irctest/specifications.py
+++ b/irctest/specifications.py
@@ -56,6 +56,7 @@ class IsupportTokens(enum.Enum):
MONITOR = "MONITOR"
STATUSMSG = "STATUSMSG"
TARGMAX = "TARGMAX"
+ UTF8ONLY = "UTF8ONLY"
WHOX = "WHOX"
@classmethod
diff --git a/pytest.ini b/pytest.ini
index 9b5d071..138bd43 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -38,6 +38,7 @@ markers =
PREFIX
STATUSMSG
TARGMAX
+ UTF8ONLY
WHOX
python_classes = *TestCase Test*