summary refs log tree commit diff
path: root/tests/rest/client/test_rooms.py
diff options
context:
space:
mode:
authorMo Balaa <thebalaa@users.noreply.github.com>2024-01-22 04:46:30 -0600
committerGitHub <noreply@github.com>2024-01-22 10:46:30 +0000
commitb99f6db0396629187b7c7e0e869e8ecc082154a5 (patch)
tree5dbd55692d832ef39c85d7267f79d259b8218193 /tests/rest/client/test_rooms.py
parentBump actions/cache from 3 to 4 (#16832) (diff)
downloadsynapse-b99f6db0396629187b7c7e0e869e8ecc082154a5.tar.xz
Handle wildcard type filters properly (#14984)
Diffstat (limited to 'tests/rest/client/test_rooms.py')
-rw-r--r--tests/rest/client/test_rooms.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py
index 0e71cdcd88..89b161dd0a 100644
--- a/tests/rest/client/test_rooms.py
+++ b/tests/rest/client/test_rooms.py
@@ -2155,6 +2155,33 @@ class RoomMessageListTestCase(RoomBase):
         self.assertEqual(len(chunk), 0, [event["content"] for event in chunk])
 
 
+class RoomMessageFilterTestCase(RoomBase):
+    """Tests /rooms/$room_id/messages REST events."""
+
+    user_id = "@sid1:red"
+
+    def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
+        self.room_id = self.helper.create_room_as(self.user_id)
+
+    def test_room_message_filter_wildcard(self) -> None:
+        # Send a first message in the room, which will be removed by the purge.
+        self.helper.send(self.room_id, "message 1", type="f.message.1")
+        self.helper.send(self.room_id, "message 1", type="f.message.2")
+        self.helper.send(self.room_id, "not returned in filter")
+        channel = self.make_request(
+            "GET",
+            "/rooms/%s/messages?access_token=x&dir=b&filter=%s"
+            % (
+                self.room_id,
+                json.dumps({"types": ["f.message.*"]}),
+            ),
+        )
+        self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body)
+
+        chunk = channel.json_body["chunk"]
+        self.assertEqual(len(chunk), 2, [event["content"] for event in chunk])
+
+
 class RoomSearchTestCase(unittest.HomeserverTestCase):
     servlets = [
         synapse.rest.admin.register_servlets_for_client_rest_resource,