diff --git a/tests/rest/client/test_profile.py b/tests/rest/client/test_profile.py index 77c3ced42ec1..9920e3260bff 100644 --- a/tests/rest/client/test_profile.py +++ b/tests/rest/client/test_profile.py @@ -13,6 +13,7 @@ # limitations under the License. """Tests REST events for /profile paths.""" +from http import HTTPStatus from typing import Any, Dict, Optional from twisted.test.proto_helpers import MemoryReactor @@ -49,6 +50,11 @@ def test_get_displayname(self) -> None: res = self._get_displayname() self.assertEqual(res, "owner") + def test_get_displayname_rejects_bad_username(self) -> None: + # Note: probably ought to urlencode the userid here, since it contains an `@` + channel = self.make_request("GET", "/profile/notanmxid@example.com/displayname") + self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result) + def test_set_displayname(self) -> None: channel = self.make_request( "PUT",