mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-11-29 17:21:30 -05:00
guard against accidental modification
This commit is contained in:
parent
617e8a4653
commit
898196f1cc
3 changed files with 30 additions and 3 deletions
|
|
@ -114,6 +114,26 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
def test_cannot_modify_event(self):
|
||||
"""cannot accidentally modify an event before it is persisted"""
|
||||
|
||||
# first patch the event checker so that it will try to modify the event
|
||||
async def check(ev: EventBase, state):
|
||||
ev.content = {"x": "y"}
|
||||
return True
|
||||
|
||||
current_rules_module().check_event_allowed = check
|
||||
|
||||
# now send the event
|
||||
request, channel = self.make_request(
|
||||
"PUT",
|
||||
"/_matrix/client/r0/rooms/%s/send/modifyme/1" % self.room_id,
|
||||
{"x": "x"},
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"500", channel.result)
|
||||
|
||||
def test_modify_event(self):
|
||||
"""The module can return a modified version of the event"""
|
||||
# first patch the event checker so that it will modify the event
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue