diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-09-10 14:55:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 14:55:25 -0400 |
commit | b86764662b6058dc53dd7cef923b806dc28f3a53 (patch) | |
tree | 95aecaacde9a89fec3da0885c1d0d7c03f686028 /tests/federation | |
parent | Remove shared rooms info from upgrade/workers doc as it's still experimental ... (diff) | |
download | synapse-b86764662b6058dc53dd7cef923b806dc28f3a53.tar.xz |
Fix the exception that is raised when invalid JSON is encountered. (#8291)
Diffstat (limited to 'tests/federation')
-rw-r--r-- | tests/federation/test_federation_server.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/federation/test_federation_server.py b/tests/federation/test_federation_server.py index 296dc887be..da933ecd75 100644 --- a/tests/federation/test_federation_server.py +++ b/tests/federation/test_federation_server.py @@ -15,6 +15,8 @@ # limitations under the License. import logging +from parameterized import parameterized + from synapse.events import make_event_from_dict from synapse.federation.federation_server import server_matches_acl_event from synapse.rest import admin @@ -23,6 +25,37 @@ from synapse.rest.client.v1 import login, room from tests import unittest +class FederationServerTests(unittest.FederatingHomeserverTestCase): + + servlets = [ + admin.register_servlets, + room.register_servlets, + login.register_servlets, + ] + + @parameterized.expand([(b"",), (b"foo",), (b'{"limit": Infinity}',)]) + def test_bad_request(self, query_content): + """ + Querying with bad data returns a reasonable error code. + """ + u1 = self.register_user("u1", "pass") + u1_token = self.login("u1", "pass") + + room_1 = self.helper.create_room_as(u1, tok=u1_token) + self.inject_room_member(room_1, "@user:other.example.com", "join") + + "/get_missing_events/(?P<room_id>[^/]*)/?" + + request, channel = self.make_request( + "POST", + "/_matrix/federation/v1/get_missing_events/%s" % (room_1,), + query_content, + ) + self.render(request) + self.assertEquals(400, channel.code, channel.result) + self.assertEqual(channel.json_body["errcode"], "M_NOT_JSON") + + class ServerACLsTestCase(unittest.TestCase): def test_blacklisted_server(self): e = _create_acl_event({"allow": ["*"], "deny": ["evil.com"]}) |