summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlexander Fechler <141915399+afechler@users.noreply.github.com>2023-08-18 13:26:38 +0200
committerGitHub <noreply@github.com>2023-08-18 12:26:38 +0100
commit54317d34b76adb1e8f694acd91f631b3abe38947 (patch)
tree172fedb2e2460e569abf0a7ea5cc4e101954ae31 /tests
parentAdd response time metrics for introspection requests (#16131) (diff)
downloadsynapse-54317d34b76adb1e8f694acd91f631b3abe38947.tar.xz
Allow filtering for admins in the list accounts admin API (#16114)
Diffstat (limited to 'tests')
-rw-r--r--tests/rest/admin/test_user.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py
index 41a959b4d6..feb81844ae 100644
--- a/tests/rest/admin/test_user.py
+++ b/tests/rest/admin/test_user.py
@@ -879,6 +879,44 @@ class UsersListTestCase(unittest.HomeserverTestCase):
         self._order_test([self.admin_user, user1, user2], "creation_ts", "f")
         self._order_test([user2, user1, self.admin_user], "creation_ts", "b")
 
+    def test_filter_admins(self) -> None:
+        """
+        Tests whether the various values of the query parameter `admins` lead to the
+        expected result set.
+        """
+
+        # Register an additional non admin user
+        self.register_user("user", "pass", admin=False)
+
+        # Query all users
+        channel = self.make_request(
+            "GET",
+            f"{self.url}",
+            access_token=self.admin_user_tok,
+        )
+        self.assertEqual(200, channel.code, channel.result)
+        self.assertEqual(2, channel.json_body["total"])
+
+        # Query only admin users
+        channel = self.make_request(
+            "GET",
+            f"{self.url}?admins=true",
+            access_token=self.admin_user_tok,
+        )
+        self.assertEqual(200, channel.code, channel.result)
+        self.assertEqual(1, channel.json_body["total"])
+        self.assertEqual(1, channel.json_body["users"][0]["admin"])
+
+        # Query only non admin users
+        channel = self.make_request(
+            "GET",
+            f"{self.url}?admins=false",
+            access_token=self.admin_user_tok,
+        )
+        self.assertEqual(200, channel.code, channel.result)
+        self.assertEqual(1, channel.json_body["total"])
+        self.assertFalse(channel.json_body["users"][0]["admin"])
+
     @override_config(
         {
             "experimental_features": {