From fce1924b4a6374d0a27ba78f8cc2bca43a3c1c83 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Mon, 16 Dec 2024 13:45:16 -0800 Subject: [PATCH] test --- tests/rest/admin/test_room.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/rest/admin/test_room.py b/tests/rest/admin/test_room.py index 95ed7364510..ef89600579c 100644 --- a/tests/rest/admin/test_room.py +++ b/tests/rest/admin/test_room.py @@ -2035,6 +2035,34 @@ def test_room_state(self) -> None: # the create_room already does the right thing, so no need to verify that we got # the state events it created. + def test_room_state_param(self) -> None: + """Test that filtering by state event type works when requesting state""" + room_id = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok) + + channel = self.make_request( + "GET", + f"/_synapse/admin/v1/rooms/{room_id}/state?type=m.room.member", + access_token=self.admin_user_tok, + ) + self.assertEqual(200, channel.code) + state = channel.json_body["state"] + # only one member has joined so there should be one membership event + self.assertEqual(1, len(state)) + event = state[0] + self.assertEqual(event["type"], "m.room.member") + self.assertEqual(event["state_key"], self.admin_user) + + def test_room_state_bad_param(self) -> None: + """Test that request with param not conforming to 'm.room.*' will be rejected""" + room_id = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok) + + channel = self.make_request( + "GET", + f"/_synapse/admin/v1/rooms/{room_id}/state?type=m.something.else", + access_token=self.admin_user_tok, + ) + self.assertEqual(400, channel.code) + def _set_canonical_alias( self, room_id: str, test_alias: str, admin_user_tok: str ) -> None: