irctest/irctest/server_tests/test_confusables.py

33 lines
1.1 KiB
Python
Raw Normal View History

2020-03-11 10:51:23 +00:00
from irctest import cases
from irctest.numerics import RPL_WELCOME, ERR_NICKNAMEINUSE
2021-02-22 18:02:13 +00:00
2020-03-11 10:51:23 +00:00
class ConfusablesTestCase(cases.BaseServerTestCase):
@staticmethod
def config():
return {
2021-02-22 18:02:13 +00:00
"oragono_config": lambda config: config["accounts"].update(
{"nick-reservation": {"enabled": True, "method": "strict"}}
)
2020-03-11 10:51:23 +00:00
}
2021-02-22 18:02:13 +00:00
@cases.SpecificationSelector.requiredBySpecification("Oragono")
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-02-22 18:02:13 +00:00
self.connectClient("evan", name="evan", password="sesame")
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)