2022-04-10 12:51:14 +00:00
|
|
|
|
"""
|
|
|
|
|
`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
|
|
|
|
|
2021-07-01 14:58:20 +00:00
|
|
|
|
@cases.mark_services
|
2020-03-11 10:51:23 +00:00
|
|
|
|
class ConfusablesTestCase(cases.BaseServerTestCase):
|
2021-02-17 21:43:37 +00:00
|
|
|
|
@staticmethod
|
2021-02-28 12:40:08 +00:00
|
|
|
|
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"}}
|
2021-02-17 21:43:37 +00:00
|
|
|
|
)
|
2021-02-28 12:40:08 +00:00
|
|
|
|
)
|
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)
|
|
|
|
|
|
2021-06-26 22:46:00 +00:00
|
|
|
|
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)
|