Skip to content

Commit

Permalink
update ergo unicode tests (progval#245)
Browse files Browse the repository at this point in the history
* `casemapping: ascii` is now default
* test that non-ascii nicks are rejected by default
* test that non-ascii nicks are accepted under `casemapping: precis`
  • Loading branch information
slingamn committed Dec 21, 2023
1 parent 62a0394 commit 032d0e3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions irctest/controllers/ergo.py
Expand Up @@ -14,6 +14,7 @@
"name": "My.Little.Server",
"listeners": {},
"max-sendq": "16k",
"casemapping": "ascii",
"connection-limits": {
"enabled": True,
"cidr-len-ipv4": 32,
Expand Down
4 changes: 2 additions & 2 deletions irctest/server_tests/confusables.py
Expand Up @@ -12,8 +12,8 @@ class ConfusablesTestCase(cases.BaseServerTestCase):
@staticmethod
def config() -> cases.TestCaseControllerConfig:
return cases.TestCaseControllerConfig(
ergo_config=lambda config: config["accounts"].update(
{"nick-reservation": {"enabled": True, "method": "strict"}}
ergo_config=lambda config: config["server"].update(
{"casemapping": "precis"},
)
)

Expand Down
35 changes: 35 additions & 0 deletions irctest/server_tests/utf8.py
Expand Up @@ -5,6 +5,7 @@
"""

from irctest import cases, runner
from irctest.numerics import ERR_ERRONEUSNICKNAME
from irctest.patma import ANYSTR


Expand Down Expand Up @@ -81,3 +82,37 @@ def testNonutf8Username(self):
)
self.sendLine(2, "WHOIS foo")
self.getMessages(2)


class ErgoUtf8NickEnabledTestCase(cases.BaseServerTestCase):
@staticmethod
def config() -> cases.TestCaseControllerConfig:
return cases.TestCaseControllerConfig(
ergo_config=lambda config: config["server"].update(
{"casemapping": "precis"},
)
)

@cases.mark_specifications("Ergo")
def testUtf8NonAsciiNick(self):
"""Ergo accepts certain non-ASCII UTF8 nicknames if PRECIS is enabled."""
self.connectClient("Işıl")
self.joinChannel(1, "#test")

self.connectClient("Claire")
self.joinChannel(2, "#test")

self.sendLine(1, "PRIVMSG #test :hi there")
self.assertMessageMatch(
self.getMessage(2), nick="Işıl", params=["#test", "hi there"]
)


class ErgoUtf8NickDisabledTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("Ergo")
def testUtf8NonAsciiNick(self):
"""Ergo rejects non-ASCII nicknames in its default configuration."""
self.addClient(1)
self.sendLine(1, "USER u s e r")
self.sendLine(1, "NICK Işıl")
self.assertMessageMatch(self.getMessage(1), command=ERR_ERRONEUSNICKNAME)

0 comments on commit 032d0e3

Please sign in to comment.