Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Hitting a rate-limit on find accounts should not send emails.

Alex Vandiver48ba2e7cc677
diff --git a/zerver/tests/test_external.py b/zerver/tests/test_external.py
index 51b17dff2de..b27571667da 100644
--- a/zerver/tests/test_external.py
+++ b/zerver/tests/test_external.py
@@ -228,6 +228,22 @@ class RateLimitTests(ZulipTestCase):
is_json=False,
)
+ # If I submit with 3 emails and the rate-limit is 2, I should get
+ # a 429 and not send any emails.
+ @rate_limit_rule(1, 2, domain="sends_email_by_ip")
+ def test_find_account_rate_limiting_multiple_one_request(self) -> None:
+ emails = [
+ ]
+ resp = self.client_post("/accounts/find/", {"emails": ",".join(emails)})
+ self.assertEqual(resp.status_code, 429)
+
+ from django.core.mail import outbox
+
+ self.assert_length(outbox, 0)
+
@rate_limit_rule(1, 5, domain="sends_email_by_ip")
def test_combined_ip_limits(self) -> None:
# Alternate requests to /new/ and /accounts/find/