mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:46:01 -04:00
Reject device display names that are too long (#6882)
* Reject device display names that are too long. Too long is currently defined as 100 characters in length. * Add a regression test for rejecting a too long device display name.
This commit is contained in:
parent
3a3118f4ec
commit
a92e703ab9
3 changed files with 32 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue