From ce3ad2ef3fc1e9e9c9fd3f5c4e58c29d934c3718 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 14 Jun 2022 01:41:06 +0100 Subject: [PATCH] Test the endpoint does actually return 400 --- tests/rest/client/test_profile.py | 6 ++++++ 1 file changed, 6 insertions(+) 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",