irctest/irctest/server_tests/confusables.py

41 lines
1.3 KiB
Python
Raw Normal View History

"""
`Ergo <https://ergo.chat/>`_-specific tests for nick collisions based on Unicode
confusable characters
"""
2020-03-11 10:51:23 +00:00
from irctest import cases
2021-02-22 18:04:23 +00:00
from irctest.numerics import ERR_NICKNAMEINUSE, RPL_WELCOME
2020-03-11 10:51:23 +00:00
2021-02-22 18:02:13 +00:00
@cases.mark_services
2020-03-11 10:51:23 +00:00
class ConfusablesTestCase(cases.BaseServerTestCase):
@staticmethod
def config() -> cases.TestCaseControllerConfig:
return cases.TestCaseControllerConfig(
2021-05-27 03:55:21 +00:00
ergo_config=lambda config: config["accounts"].update(
2021-02-22 18:02:13 +00:00
{"nick-reservation": {"enabled": True, "method": "strict"}}
)
)
2020-03-11 10:51:23 +00:00
2021-05-27 03:55:21 +00:00
@cases.mark_specifications("Ergo")
2020-03-11 10:51:23 +00:00
def testConfusableNicks(self):
2021-02-22 18:02:13 +00:00
self.controller.registerUser(self, "evan", "sesame")
2020-03-11 10:51:23 +00:00
self.addClient(1)
# U+0435 in place of e:
2021-02-22 18:02:13 +00:00
self.sendLine(1, "NICK еvan")
self.sendLine(1, "USER a 0 * a")
2020-03-11 10:51:23 +00:00
messages = self.getMessages(1)
commands = set(msg.command for msg in messages)
self.assertNotIn(RPL_WELCOME, commands)
self.assertIn(ERR_NICKNAMEINUSE, commands)
self.connectClient(
"evan", name="evan", password="sesame", capabilities=["sasl"]
)
2020-03-11 10:51:23 +00:00
# should be able to switch to the confusable nick
2021-02-22 18:02:13 +00:00
self.sendLine("evan", "NICK еvan")
messages = self.getMessages("evan")
2020-03-11 10:51:23 +00:00
commands = set(msg.command for msg in messages)
2021-02-22 18:02:13 +00:00
self.assertIn("NICK", commands)