Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class Meta:
class UserResetPasswordSerializer(BaseAPISerializer):
uid = ser.CharField(write_only=True, required=True)
token = ser.CharField(write_only=True, required=True)
password = ser.CharField(write_only=True, required=True)
password = ser.CharField(write_only=True, required=True, max_length=255)

class Meta:
type_ = 'user_reset_password'
Expand Down
22 changes: 22 additions & 0 deletions api_tests/users/views/test_user_settings_reset_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ def test_post_invalid_password(self, app, url, user_one, csrf_token):
res = app.post_json_api(url, payload, expect_errors=True, headers={'X-THROTTLE-TOKEN': 'test-token', 'X-CSRFToken': csrf_token})
assert res.status_code == 400

def test_post_password_too_long(self, app, url, user_one, csrf_token):
app.set_cookie(CSRF_COOKIE_NAME, csrf_token)
encoded_email = urllib.parse.quote(user_one.email)
url = f'{url}?email={encoded_email}'
from tests.utils import capture_notifications

with capture_notifications():
res = app.get(url)
user_one.reload()
payload = {
'data': {
'attributes': {
'uid': user_one._id,
'token': user_one.verification_key_v2['token'],
'password': 'a' * 256,
}
}
}

res = app.post_json_api(url, payload, expect_errors=True, headers={'X-THROTTLE-TOKEN': 'test-token', 'X-CSRFToken': csrf_token})
assert res.status_code == 400 and res.json['errors'][0]['detail'] == 'Ensure this field has no more than 255 characters.'

def test_throttle(self, app, url, throttle_user, csrf_token):
app.set_cookie(CSRF_COOKIE_NAME, csrf_token)
encoded_email = urllib.parse.quote(throttle_user.email)
Expand Down