1
0

test_ratelimiting.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from synapse.config.homeserver import HomeServerConfig
  16. from tests.unittest import TestCase
  17. from tests.utils import default_config
  18. class RatelimitConfigTestCase(TestCase):
  19. def test_parse_rc_federation(self):
  20. config_dict = default_config("test")
  21. config_dict["rc_federation"] = {
  22. "window_size": 20000,
  23. "sleep_limit": 693,
  24. "sleep_delay": 252,
  25. "reject_limit": 198,
  26. "concurrent": 7,
  27. }
  28. config = HomeServerConfig()
  29. config.parse_config_dict(config_dict, "", "")
  30. config_obj = config.rc_federation
  31. self.assertEqual(config_obj.window_size, 20000)
  32. self.assertEqual(config_obj.sleep_limit, 693)
  33. self.assertEqual(config_obj.sleep_delay, 252)
  34. self.assertEqual(config_obj.reject_limit, 198)
  35. self.assertEqual(config_obj.concurrent, 7)