Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Split out test_find_account_rate_limiting_multiple.
Alex Vandiver272e78de8bd4
diff --git a/zerver/tests/test_external.py b/zerver/tests/test_external.pyindex 6ba69a751c6..4796fbb3107 100644--- a/zerver/tests/test_external.py+++ b/zerver/tests/test_external.py@@ -204,29 +204,32 @@ class RateLimitTests(ZulipTestCase):assert_func=assert_func,)+ @rate_limit_rule(1, 5, domain="find_account_by_ip")def test_find_account_rate_limiting(self) -> None:def assert_func(result: HttpResponse) -> None:self.assertEqual(result.status_code, 429)self.assert_in_response("Rate limit exceeded.", result)- with rate_limit_rule(1, 5, domain="find_account_by_ip"):- RateLimitedIPAddr("127.0.0.1", domain="find_account_by_ip").clear_history()- self.do_test_hit_ratelimits(- lambda: self.client_post("/accounts/find/", {"emails": "[email protected]"}),- assert_func=assert_func,- )+ RateLimitedIPAddr("127.0.0.1", domain="find_account_by_ip").clear_history()+ self.do_test_hit_ratelimits(+ lambda: self.client_post("/accounts/find/", {"emails": "[email protected]"}),+ assert_func=assert_func,+ )- # Now test whether submitting multiple emails is handled correctly.- # The limit is set to 10 per second, so 5 requests with 2 emails- # submitted in each should be allowed.- with rate_limit_rule(1, 10, domain="find_account_by_ip"):- RateLimitedIPAddr("127.0.0.1", domain="find_account_by_ip").clear_history()- self.do_test_hit_ratelimits(- lambda: self.client_post(- "/accounts/find/", {"emails": "[email protected],[email protected]"}- ),- assert_func=assert_func,- )+ # Test whether submitting multiple emails is handled correctly.+ # The limit is set to 10 per second, so 5 requests with 2 emails+ # submitted in each should be allowed.+ @rate_limit_rule(1, 10, domain="find_account_by_ip")+ def test_find_account_rate_limiting_multiple(self) -> None:+ def assert_func(result: HttpResponse) -> None:+ self.assertEqual(result.status_code, 429)+ self.assert_in_response("Rate limit exceeded.", result)++ RateLimitedIPAddr("127.0.0.1", domain="find_account_by_ip").clear_history()+ self.do_test_hit_ratelimits(+ lambda: self.client_post("/accounts/find/", {"emails": "[email protected],[email protected]"}),+ assert_func=assert_func,+ )@skipUnless(settings.ZILENCER_ENABLED, "requires zilencer")@rate_limit_rule(1, 5, domain="api_by_remote_server")