summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-03-23 17:12:09 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-03-23 17:12:09 +0000
commit1dbb4305e30024618e4d2ac374dda09885c3d95e (patch)
tree9fbb60ee5f1892d5e153dd7206f7707bba9e04e9 /tests
parentfilter out m.room.aliases from /sync state blocks (#6884) (diff)
parentReject device display names that are too long (#6882) (diff)
downloadsynapse-1dbb4305e30024618e4d2ac374dda09885c3d95e.tar.xz
Reject device display names that are too long (#6882)
* commit 'a92e703ab':
  Reject device display names that are too long (#6882)
Diffstat (limited to 'tests')
-rw-r--r--tests/handlers/test_device.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/handlers/test_device.py b/tests/handlers/test_device.py
index a3aa0a1cf2..62b47f6574 100644
--- a/tests/handlers/test_device.py
+++ b/tests/handlers/test_device.py
@@ -160,6 +160,24 @@ class DeviceTestCase(unittest.HomeserverTestCase):
         res = self.get_success(self.handler.get_device(user1, "abc"))
         self.assertEqual(res["display_name"], "new display")
 
+    def test_update_device_too_long_display_name(self):
+        """Update a device with a display name that is invalid (too long)."""
+        self._record_users()
+
+        # Request to update a device display name with a new value that is longer than allowed.
+        update = {
+            "display_name": "a"
+            * (synapse.handlers.device.MAX_DEVICE_DISPLAY_NAME_LEN + 1)
+        }
+        self.get_failure(
+            self.handler.update_device(user1, "abc", update),
+            synapse.api.errors.SynapseError,
+        )
+
+        # Ensure the display name was not updated.
+        res = self.get_success(self.handler.get_device(user1, "abc"))
+        self.assertEqual(res["display_name"], "display 2")
+
     def test_update_unknown_device(self):
         update = {"display_name": "new_display"}
         res = self.handler.update_device("user_id", "unknown_device_id", update)