diff --git a/tests/unit/accounts/test_forms.py b/tests/unit/accounts/test_forms.py index a5df0332c9a8..acf6a7187c5a 100644 --- a/tests/unit/accounts/test_forms.py +++ b/tests/unit/accounts/test_forms.py @@ -433,7 +433,7 @@ def test_validate(self, metrics): "new_password": "mysupersecurepassword1!", "password_confirm": "mysupersecurepassword1!", "email": "foo@bar.com", - "captcha_reponse": "", + "g_recaptcha_reponse": "", } ), user_service=user_service, @@ -634,12 +634,12 @@ def test_recaptcha_disabled(self): assert not form.validate() # there shouldn't be any errors for the recaptcha field if it's # disabled - assert not form.captcha_response.errors + assert not form.g_recaptcha_response.errors def test_recaptcha_required_error(self): form = forms.RegistrationForm( request=pretend.stub(), - formdata=MultiDict({"captcha_response": ""}), + formdata=MultiDict({"g_recaptcha_response": ""}), user_service=pretend.stub(), captcha_service=pretend.stub( enabled=True, @@ -648,12 +648,12 @@ def test_recaptcha_required_error(self): breach_service=pretend.stub(check_password=lambda pw, tags=None: False), ) assert not form.validate() - assert form.captcha_response.errors.pop() == "Captcha error." + assert form.g_recaptcha_response.errors.pop() == "Captcha error." def test_recaptcha_error(self): form = forms.RegistrationForm( request=pretend.stub(), - formdata=MultiDict({"captcha_response": "asd"}), + formdata=MultiDict({"g_recaptcha_response": "asd"}), user_service=pretend.stub(), captcha_service=pretend.stub( verify_response=pretend.raiser(recaptcha.RecaptchaError), @@ -662,7 +662,7 @@ def test_recaptcha_error(self): breach_service=pretend.stub(check_password=lambda pw, tags=None: False), ) assert not form.validate() - assert form.captcha_response.errors.pop() == "Captcha error." + assert form.g_recaptcha_response.errors.pop() == "Captcha error." def test_username_exists(self, pyramid_config): form = forms.RegistrationForm( diff --git a/tests/unit/accounts/test_views.py b/tests/unit/accounts/test_views.py index ddc6e76f7761..d1c89a35789f 100644 --- a/tests/unit/accounts/test_views.py +++ b/tests/unit/accounts/test_views.py @@ -1752,7 +1752,7 @@ def _find_service(service=None, name=None, context=None): "password_confirm": "MyStr0ng!shP455w0rd", "email": "foo@bar.com", "full_name": "full_name", - "captcha_response": "captchavalue", + "g_recaptcha_response": "captchavalue", } ) diff --git a/warehouse/accounts/forms.py b/warehouse/accounts/forms.py index 9c7cefeb9a93..af62a61952de 100644 --- a/warehouse/accounts/forms.py +++ b/warehouse/accounts/forms.py @@ -407,7 +407,7 @@ class RegistrationForm( # type: ignore[misc] PreventNullBytesValidator(), ] ) - captcha_response = wtforms.StringField() + g_recaptcha_response = wtforms.StringField() def __init__(self, *args, captcha_service, user_service, **kwargs): super().__init__(*args, **kwargs) @@ -415,7 +415,7 @@ def __init__(self, *args, captcha_service, user_service, **kwargs): self.user_id = None self.captcha_service = captcha_service - def validate_captcha_response(self, field): + def validate_g_recaptcha_response(self, field): # do required data validation here due to enabled flag being required if self.captcha_service.enabled and not field.data: raise wtforms.validators.ValidationError("Captcha error.") diff --git a/warehouse/templates/includes/input-captcha.html b/warehouse/templates/includes/input-captcha.html index 5255ec20c7d0..df109a54ebe5 100644 --- a/warehouse/templates/includes/input-captcha.html +++ b/warehouse/templates/includes/input-captcha.html @@ -4,9 +4,9 @@ {% if captcha_svc.enabled %}
- {% if form.captcha_response.errors %} + {% if form.g_recaptcha_response.errors %} {% endif %} {% endif %}