summary refs log tree commit diff
path: root/tests/rest
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2020-02-12 18:14:10 +0000
committerGitHub <noreply@github.com>2020-02-12 18:14:10 +0000
commitd8994942f28f5028e560f6aba52512fae3ca1a6a (patch)
tree7f2dcaab240436d3d0850fac778787469b6388c9 /tests/rest
parentMerge branch 'master' into develop (diff)
downloadsynapse-d8994942f28f5028e560f6aba52512fae3ca1a6a.tar.xz
Return a 404 for admin api user lookup if user not found (#6901)
Diffstat (limited to 'tests/rest')
-rw-r--r--tests/rest/admin/test_user.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py
index 3b5169b38d..490ce8f55d 100644
--- a/tests/rest/admin/test_user.py
+++ b/tests/rest/admin/test_user.py
@@ -401,6 +401,22 @@ class UserRestTestCase(unittest.HomeserverTestCase):
         self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
         self.assertEqual("You are not a server admin", channel.json_body["error"])
 
+    def test_user_does_not_exist(self):
+        """
+        Tests that a lookup for a user that does not exist returns a 404
+        """
+        self.hs.config.registration_shared_secret = None
+
+        request, channel = self.make_request(
+            "GET",
+            "/_synapse/admin/v2/users/@unknown_person:test",
+            access_token=self.admin_user_tok,
+        )
+        self.render(request)
+
+        self.assertEqual(404, channel.code, msg=channel.json_body)
+        self.assertEqual("M_NOT_FOUND", channel.json_body["errcode"])
+
     def test_requester_is_admin(self):
         """
         If the user is a server admin, a new user is created.