Commit f56572ef authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_core: fix variables in formatted strings

parent 97e63f46
...@@ -434,6 +434,32 @@ class TestPasswordTool(ERP5TypeTestCase): ...@@ -434,6 +434,32 @@ class TestPasswordTool(ERP5TypeTestCase):
# But no mail has been sent # But no mail has been sent
self.stepCheckNoMailSent() self.stepCheckNoMailSent()
def test_unreachable_email_on_person(self):
person = self.portal.person_module.newContent(
portal_type="Person",
reference="user",
default_email_text="user@example.invalid",
)
person.getDefaultEmailValue().declareUnreachable()
assignment = person.newContent(portal_type='Assignment')
assignment.open()
login = person.newContent(
portal_type='ERP5 Login',
reference='user-login',
password='password',
)
login.validate()
self.tic()
self.logout()
ret = self.portal.portal_password.mailPasswordResetRequest(
user_login='user-login', REQUEST=self.portal.REQUEST)
# For security reasons, the message should always be the same
self.assertTrue("portal_status_message=An+email+has+been+sent+to+you." in str(ret))
# But no mail has been sent
self.stepCheckNoMailSent()
def test_acquired_email_on_person(self): def test_acquired_email_on_person(self):
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
......
...@@ -161,7 +161,7 @@ class PasswordTool(BaseTool): ...@@ -161,7 +161,7 @@ class PasswordTool(BaseTool):
error_encountered = True error_encountered = True
LOG( LOG(
'ERP5.PasswordTool', INFO, 'ERP5.PasswordTool', INFO,
"User ${user} does not exist.".format(user=user_login) "User {user} does not exist.".format(user=user_login)
) )
else: else:
# We use checked_permission to prevent errors when trying to acquire # We use checked_permission to prevent errors when trying to acquire
...@@ -174,13 +174,19 @@ class PasswordTool(BaseTool): ...@@ -174,13 +174,19 @@ class PasswordTool(BaseTool):
if email_value is None or not email_value.asText(): if email_value is None or not email_value.asText():
if credential_request_exists: if credential_request_exists:
raise RuntimeError( raise RuntimeError(
"User ${user} does not have an email address, " "User {user} does not have an email address, "
"please contact site administrator directly".format(user=user_login) "please contact site administrator directly".format(user=user_login)
) )
error_encountered = True error_encountered = True
LOG( LOG(
'ERP5.PasswordTool', INFO, 'ERP5.PasswordTool', INFO,
"User ${user} does not have an email address".format(user=user_login) "User {user} does not have an email address".format(user=user_login)
)
elif email_value.getValidationState() != "reachable":
error_encountered = True
LOG(
'ERP5.PasswordTool', INFO,
"User {user} does not have a valid email address".format(user=user_login)
) )
if error_encountered: if error_encountered:
if batch: if batch:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment