Commit 7c650f38 authored by Jérome Perrin's avatar Jérome Perrin

testAuthenticationPolicy: add missing test for automatic password recovery

parent 5510c295
......@@ -534,6 +534,49 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
self.assertFalse(person.isPasswordExpired())
self.assertFalse(request['is_user_account_password_expired_expire_date'])
def test_SystemRecoverExpiredPassword(self):
"""
Test automatic system recover password
"""
portal = self.portal
request = self.app.REQUEST
self.assertTrue(portal.portal_preferences.isAuthenticationPolicyEnabled())
preference = portal.portal_catalog.getResultValue(portal_type = 'System Preference',
title = 'Authentication',)
preference.setPreferredMaxPasswordLifetimeDuration(0) # password expire immediatly
preference.setPreferredSystemRecoverExpiredPassword(True)
self._clearCache()
self.tic()
person = portal.person_module.newContent(
portal_type='Person',
reference=self.id(),
password='password')
person.newContent(portal_type='Assignment').open()
self.tic()
self._clearCache()
time.sleep(1)
self.assertTrue(person.isPasswordExpired())
# User cannot login
path = portal.absolute_url_path() + '/view?__ac_name=%s&__ac_password=%s' % (
self.id(), 'password')
response = self.publish(path)
self.assertTrue(response.getHeader("Location").endswith("login_form"))
self.tic()
# and a credential recovery is created automatically
credential_recovery, = person.getDestinationDecisionRelatedValueList(
portal_type='Credential Recovery')
# trying to login again does not create a new credential recovery
response = self.publish(path)
self.tic()
credential_recovery, = person.getDestinationDecisionRelatedValueList(
portal_type='Credential Recovery')
def test_05_HttpRequest(self):
"""
Check HTTP responses
......
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