summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorTravis Ralston <travpc@gmail.com>2021-02-02 04:16:29 -0700
committerGitHub <noreply@github.com>2021-02-02 11:16:29 +0000
commitb60bb28bbc3d916586a913970298baba483efc1f (patch)
tree88a337a12cd293a98dc89158de859e800604b92f /tests
parentPut SAML callback URI under /_synapse/client. (#9289) (diff)
downloadsynapse-b60bb28bbc3d916586a913970298baba483efc1f.tar.xz
Add an admin API to get the current room state (#9168)
This could arguably replace the existing admin API for `/members`, however that is out of scope of this change.

This sort of endpoint is ideal for moderation use cases as well as other applications, such as needing to retrieve various bits of information about a room to perform a task (like syncing power levels between two places). This endpoint exposes nothing more than an admin would be able to access with a `select *` query on their database.
Diffstat (limited to 'tests')
-rw-r--r--tests/rest/admin/test_room.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/rest/admin/test_room.py b/tests/rest/admin/test_room.py
index a0f32c5512..7c47aa7e0a 100644
--- a/tests/rest/admin/test_room.py
+++ b/tests/rest/admin/test_room.py
@@ -1180,6 +1180,21 @@ class RoomTestCase(unittest.HomeserverTestCase):
         )
         self.assertEqual(channel.json_body["total"], 3)
 
+    def test_room_state(self):
+        """Test that room state can be requested correctly"""
+        # Create two test rooms
+        room_id = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok)
+
+        url = "/_synapse/admin/v1/rooms/%s/state" % (room_id,)
+        channel = self.make_request(
+            "GET", url.encode("ascii"), access_token=self.admin_user_tok,
+        )
+        self.assertEqual(200, channel.code, msg=channel.json_body)
+        self.assertIn("state", channel.json_body)
+        # testing that the state events match is painful and not done here. We assume that
+        # the create_room already does the right thing, so no need to verify that we got
+        # the state events it created.
+
 
 class JoinAliasRoomTestCase(unittest.HomeserverTestCase):