summary refs log tree commit diff
path: root/tests/rest/client/test_profile.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-06-14 18:28:26 +0100
committerGitHub <noreply@github.com>2022-06-14 18:28:26 +0100
commitc99b511db950bff5129e717a225de78b95b9b5ad (patch)
treedade8b69e8bf3abf52f1a6f7824f2aa08f79e280 /tests/rest/client/test_profile.py
parentUp complement time outs (#13048) (diff)
downloadsynapse-c99b511db950bff5129e717a225de78b95b9b5ad.tar.xz
Fix `destination_is` errors seen in sentry. (#13041)
* Rename test_fedclient to match its source file
* Require at least one destination to be truthy
* Explicitly validate user ID in profile endpoint GETs
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Diffstat (limited to 'tests/rest/client/test_profile.py')
-rw-r--r--tests/rest/client/test_profile.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/rest/client/test_profile.py b/tests/rest/client/test_profile.py
index 77c3ced42e..29bed0e872 100644
--- a/tests/rest/client/test_profile.py
+++ b/tests/rest/client/test_profile.py
@@ -13,6 +13,8 @@
 # limitations under the License.
 
 """Tests REST events for /profile paths."""
+import urllib.parse
+from http import HTTPStatus
 from typing import Any, Dict, Optional
 
 from twisted.test.proto_helpers import MemoryReactor
@@ -49,6 +51,12 @@ class ProfileTestCase(unittest.HomeserverTestCase):
         res = self._get_displayname()
         self.assertEqual(res, "owner")
 
+    def test_get_displayname_rejects_bad_username(self) -> None:
+        channel = self.make_request(
+            "GET", f"/profile/{urllib.parse.quote('@alice:')}/displayname"
+        )
+        self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
+
     def test_set_displayname(self) -> None:
         channel = self.make_request(
             "PUT",