test_ratelimiting.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright 2019 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 synapse.config.homeserver import HomeServerConfig
  15. from tests.unittest import TestCase
  16. from tests.utils import default_config
  17. class RatelimitConfigTestCase(TestCase):
  18. def test_parse_rc_federation(self) -> None:
  19. config_dict = default_config("test")
  20. config_dict["rc_federation"] = {
  21. "window_size": 20000,
  22. "sleep_limit": 693,
  23. "sleep_delay": 252,
  24. "reject_limit": 198,
  25. "concurrent": 7,
  26. }
  27. config = HomeServerConfig()
  28. config.parse_config_dict(config_dict, "", "")
  29. config_obj = config.ratelimiting.rc_federation
  30. self.assertEqual(config_obj.window_size, 20000)
  31. self.assertEqual(config_obj.sleep_limit, 693)
  32. self.assertEqual(config_obj.sleep_delay, 252)
  33. self.assertEqual(config_obj.reject_limit, 198)
  34. self.assertEqual(config_obj.concurrent, 7)