summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2019-12-02 15:10:23 +0000
committerGitHub <noreply@github.com>2019-12-02 15:10:23 +0000
commitb69732705d4b2bf4cb467da7df7f283905c7d7eb (patch)
treeb9f454389c30b3451eb0572cbe023d435d15d21d /tests
parentMerge pull request #16 from matrix-org/babolivier/dinsic-state-retrieval (diff)
downloadsynapse-b69732705d4b2bf4cb467da7df7f283905c7d7eb.tar.xz
Capatilise letters after a - in new user displaynames (#14)
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/test_register.py28
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)