summary refs log tree commit diff
path: root/tests/rest/client
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2023-02-14 15:50:59 +0000
committerGitHub <noreply@github.com>2023-02-14 15:50:59 +0000
commite9b1ff9f31f8ff093e7eaf9c54fa8f40a3b66aa8 (patch)
tree5fcff311aee38825d5a4eabf94bbc64f5efde7cf /tests/rest/client
parentMerge branch 'master' into develop (diff)
downloadsynapse-e9b1ff9f31f8ff093e7eaf9c54fa8f40a3b66aa8.tar.xz
Prevent clients from reporting nonexistent events. (#13779)
Diffstat (limited to 'tests/rest/client')
-rw-r--r--tests/rest/client/test_report_event.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/rest/client/test_report_event.py b/tests/rest/client/test_report_event.py
index 7cb1017a4a..1250685d39 100644
--- a/tests/rest/client/test_report_event.py
+++ b/tests/rest/client/test_report_event.py
@@ -73,6 +73,18 @@ class ReportEventTestCase(unittest.HomeserverTestCase):
         data = {"reason": None, "score": None}
         self._assert_status(400, data)
 
+    def test_cannot_report_nonexistent_event(self) -> None:
+        """
+        Tests that we don't accept event reports for events which do not exist.
+        """
+        channel = self.make_request(
+            "POST",
+            f"rooms/{self.room_id}/report/$nonsenseeventid:test",
+            {"reason": "i am very sad"},
+            access_token=self.other_user_tok,
+        )
+        self.assertEqual(404, channel.code, msg=channel.result["body"])
+
     def _assert_status(self, response_status: int, data: JsonDict) -> None:
         channel = self.make_request(
             "POST", self.report_path, data, access_token=self.other_user_tok