-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e484803
commit fa25949
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,6 +1307,23 @@ def test_cant_reset_more_than_six_times(self): | |
# Six emails should be sent, seventh should not | ||
self.assertEqual(len(mail.outbox), 6) | ||
|
||
def test_is_rate_limited_on_email_not_ip(self): | ||
set_instance_setting("EMAIL_HOST", "localhost") | ||
|
||
for email in ["[email protected]", "[email protected]"]: | ||
for i in range(7): | ||
with self.settings(CELERY_TASK_ALWAYS_EAGER=True, SITE_URL="https://my.posthog.net"): | ||
response = self.client.post("/api/users/@me/request_password_reset/", {"email": email}) | ||
if i < 6: | ||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) | ||
else: | ||
# Fourth request should fail | ||
self.assertEqual(response.status_code, status.HTTP_429_TOO_MANY_REQUESTS) | ||
self.assertDictContainsSubset( | ||
{"attr": None, "code": "throttled", "type": "throttled_error"}, | ||
response.json(), | ||
) | ||
|
||
# Token validation | ||
|
||
def test_can_validate_token(self): | ||
|