summary refs log tree commit diff
path: root/tests/rest/admin
diff options
context:
space:
mode:
authorHanadi <hanadi.tamimi@gmail.com>2023-09-18 16:37:51 +0200
committerGitHub <noreply@github.com>2023-09-18 15:37:51 +0100
commiteef2b9e34418e902baab1e730eb805eb56034cc2 (patch)
treecfc6a8b7648b9256b4d2bfd2fcc7da1e5a7e4347 /tests/rest/admin
parentMake cached account data/tags/admin types immutable (#16325) (diff)
downloadsynapse-eef2b9e34418e902baab1e730eb805eb56034cc2.tar.xz
Filter locked users in the admin API (#16328)
Co-authored-by: Hanadi Tamimi <hanadi.tamimi@sdui.de>
Diffstat (limited to 'tests/rest/admin')
-rw-r--r--tests/rest/admin/test_user.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py
index 761871b933..b326ad2c90 100644
--- a/tests/rest/admin/test_user.py
+++ b/tests/rest/admin/test_user.py
@@ -1146,6 +1146,32 @@ class UsersListTestCase(unittest.HomeserverTestCase):
         users = {user["name"]: user for user in channel.json_body["users"]}
         self.assertIs(users[user_id]["erased"], True)
 
+    def test_filter_locked(self) -> None:
+        # Create a new user.
+        user_id = self.register_user("lockme", "lockme")
+
+        # Lock them
+        self.get_success(self.store.set_user_locked_status(user_id, True))
+
+        # Locked user should appear in list users API
+        channel = self.make_request(
+            "GET",
+            self.url + "?locked=true",
+            access_token=self.admin_user_tok,
+        )
+        users = {user["name"]: user for user in channel.json_body["users"]}
+        self.assertIn(user_id, users)
+        self.assertTrue(users[user_id]["locked"])
+
+        # Locked user should not appear in list users API
+        channel = self.make_request(
+            "GET",
+            self.url + "?locked=false",
+            access_token=self.admin_user_tok,
+        )
+        users = {user["name"]: user for user in channel.json_body["users"]}
+        self.assertNotIn(user_id, users)
+
     def _order_test(
         self,
         expected_user_list: List[str],