1
0

test_server.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright 2020 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from tests import unittest
  15. from tests.unittest import DEBUG, override_config
  16. class RoomDirectoryFederationTests(unittest.FederatingHomeserverTestCase):
  17. @override_config({"allow_public_rooms_over_federation": False})
  18. def test_blocked_public_room_list_over_federation(self):
  19. """Test that unauthenticated requests to the public rooms directory 403 when
  20. allow_public_rooms_over_federation is False.
  21. """
  22. channel = self.make_signed_federation_request(
  23. "GET",
  24. "/_matrix/federation/v1/publicRooms",
  25. )
  26. self.assertEqual(403, channel.code)
  27. @override_config({"allow_public_rooms_over_federation": True})
  28. def test_open_public_room_list_over_federation(self):
  29. """Test that unauthenticated requests to the public rooms directory 200 when
  30. allow_public_rooms_over_federation is True.
  31. """
  32. channel = self.make_signed_federation_request(
  33. "GET",
  34. "/_matrix/federation/v1/publicRooms",
  35. )
  36. self.assertEqual(200, channel.code)
  37. @DEBUG
  38. def test_edu_debugging_doesnt_explode(self):
  39. """Sanity check incoming federation succeeds with `synapse.debug_8631` enabled.
  40. Remove this when we strip out issue_8631_logger.
  41. """
  42. channel = self.make_signed_federation_request(
  43. "PUT",
  44. "/_matrix/federation/v1/send/txn_id_1234/",
  45. content={
  46. "edus": [
  47. {"edu_type": "m.device_list_update", "content": {"foo": "bar"}}
  48. ],
  49. "pdus": [],
  50. },
  51. )
  52. self.assertEqual(200, channel.code)