Skip to content

Commit 81d4edf

Browse files
authored
Merge pull request #11265 from antkryt/fix/ENG-8656
[ENG-8656] Clean up password reset throttle error
2 parents 7a03e98 + 7a53306 commit 81d4edf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api_tests/users/views/test_user_settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
UserFactory,
1111
)
1212
from django.middleware import csrf
13+
from django.core.cache import cache
1314
from osf.models import Email, NotableDomain
1415
from framework.auth.views import auth_email_logout
1516
from website import mails, settings
@@ -189,6 +190,10 @@ def url(self):
189190
def csrf_token(self):
190191
return csrf._mask_cipher_secret(csrf._get_new_csrf_string())
191192

193+
@pytest.fixture(autouse=True)
194+
def clear_throttle_cache(self):
195+
cache.clear()
196+
192197
def test_get(self, app, url, user_one):
193198
encoded_email = urllib.parse.quote(user_one.email)
194199
url = f'{url}?email={encoded_email}'
@@ -275,7 +280,7 @@ def test_post_invalid_password(self, app, url, user_one, csrf_token):
275280
res = app.post_json_api(url, payload, expect_errors=True, headers={'X-THROTTLE-TOKEN': 'test-token', 'X-CSRFToken': csrf_token})
276281
assert res.status_code == 400
277282

278-
def test_throrrle(self, app, url, user_one):
283+
def test_throttle(self, app, url, user_one):
279284
encoded_email = urllib.parse.quote(user_one.email)
280285
url = f'{url}?email={encoded_email}'
281286
res = app.get(url)
@@ -290,10 +295,11 @@ def test_throrrle(self, app, url, user_one):
290295
}
291296
}
292297

293-
res = app.post_json_api(url, payload, expect_errors=True)
294-
assert res.status_code == 429
298+
res = app.post_json_api(url, payload, expect_errors=False)
299+
assert res.status_code == 200
295300

296301
res = app.get(url, expect_errors=True)
302+
assert res.status_code == 429
297303
assert res.json['message'] == 'You have recently requested to change your password. Please wait a few minutes before trying again.'
298304

299305

0 commit comments

Comments
 (0)