website_membership_signup_required: fix reset_password form
This commit is contained in:
parent
c439607ce1
commit
40d7cc8772
3 changed files with 48 additions and 3 deletions
|
|
@ -137,7 +137,6 @@ class TestMembershipSignup(TransactionCase):
|
|||
"""Signup must be rejected if the legal terms checkbox is not
|
||||
checked (`accepted_terms` missing or not 'accepted').
|
||||
"""
|
||||
import unittest
|
||||
controller = AuthSignupHome()
|
||||
base_qcontext = {
|
||||
"login": "no.terms@example.com",
|
||||
|
|
@ -161,6 +160,41 @@ class TestMembershipSignup(TransactionCase):
|
|||
values = controller._prepare_signup_values(qcontext)
|
||||
self.assertEqual(values.get("firstname"), "No")
|
||||
|
||||
def test_07c_prepare_signup_values_reset_password_allows_missing_terms(self):
|
||||
"""Password reset (`/web/reset_password`) reuses core's
|
||||
`_prepare_signup_values`. The reset form intentionally does not
|
||||
include the legal terms checkbox, so our override must not reject
|
||||
the submission when `accepted_terms` is absent.
|
||||
"""
|
||||
controller = AuthSignupHome()
|
||||
base_qcontext = {
|
||||
"login": "reset.me@example.com",
|
||||
"password": "newverystrongpwd",
|
||||
"confirm_password": "newverystrongpwd",
|
||||
"firstname": "Reset",
|
||||
"lastname": "User",
|
||||
"token": "dummy-reset-token",
|
||||
}
|
||||
# Missing `accepted_terms` on the reset path must NOT raise.
|
||||
with MockRequest(
|
||||
self.env, website=self.website, path="/web/reset_password"
|
||||
) as mock_request:
|
||||
# The helper accepts `path=` but the underlying httprequest mock
|
||||
# also exposes the path attribute; double-check alignment.
|
||||
self.assertEqual(mock_request.httprequest.path, "/web/reset_password")
|
||||
values = controller._prepare_signup_values(dict(base_qcontext))
|
||||
self.assertEqual(values.get("firstname"), "Reset")
|
||||
self.assertEqual(values.get("lastname"), "User")
|
||||
self.assertIn("name", values)
|
||||
# Same protection when the qcontext exposes the core reset flag.
|
||||
qcontext_flag = {
|
||||
key: value for key, value in base_qcontext.items() if key != "token"
|
||||
}
|
||||
qcontext_flag["reset_password"] = True
|
||||
with MockRequest(self.env, website=self.website, path="/web/signup"):
|
||||
values = controller._prepare_signup_values(qcontext_flag)
|
||||
self.assertEqual(values.get("firstname"), "Reset")
|
||||
|
||||
# -- RF-08 -------------------------------------------------------------
|
||||
|
||||
def test_08_backend_sale_order_with_membership_product_without_user(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue