diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/handlers/test_register.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py index 5ffba2ca7a..b2aa5c2478 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py @@ -20,6 +20,7 @@ from twisted.internet import defer from synapse.api.constants import UserTypes from synapse.api.errors import ResourceLimitError, SynapseError from synapse.handlers.register import RegistrationHandler +from synapse.rest.client.v2_alpha.register import _map_email_to_displayname from synapse.types import RoomAlias, UserID, create_requester from .. import unittest @@ -235,3 +236,30 @@ class RegistrationTestCase(unittest.HomeserverTestCase): self.handler.register(localpart=invalid_user_id), SynapseError ) + + def test_email_to_displayname_mapping(self): + """Test that custom emails are mapped to new user displaynames correctly""" + self._check_mapping( + "jack-phillips.rivers@big-org.com", + "Jack-Phillips Rivers [Big-Org]", + ) + + self._check_mapping( + "bob.jones@matrix.org", + "Bob Jones [Tchap Admin]", + ) + + self._check_mapping( + "bob-jones.blabla@gouv.fr", + "Bob-Jones Blabla [Gouv]", + ) + + # Multibyte unicode characters + self._check_mapping( + u"j\u030a\u0065an-poppy.seed@example.com", + u"J\u030a\u0065an-Poppy Seed [Example]", + ) + + def _check_mapping(self, i, expected): + result = _map_email_to_displayname(i) + self.assertEqual(result, expected) |