Commit 2c557347 authored by Ivan Tyagov's avatar Ivan Tyagov

Test calculation of early password expiration warning.

parent 495bf49e
...@@ -376,6 +376,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase): ...@@ -376,6 +376,8 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
Test password expire. Test password expire.
""" """
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST
self.assertTrue(portal.ERP5Site_isAuthenticationPolicyEnabled()) self.assertTrue(portal.ERP5Site_isAuthenticationPolicyEnabled())
person = portal.portal_catalog.getResultValue(portal_type = 'Person', person = portal.portal_catalog.getResultValue(portal_type = 'Person',
...@@ -387,6 +389,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase): ...@@ -387,6 +389,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
self.stepTic() self.stepTic()
self._clearCache() self._clearCache()
self.assertFalse(person.isPasswordExpired()) self.assertFalse(person.isPasswordExpired())
self.assertFalse(request['is_user_account_password_expired'])
# set older last password modification date just for test # set older last password modification date just for test
now = DateTime() now = DateTime()
...@@ -394,12 +397,30 @@ class TestAuthenticationPolicy(ERP5TypeTestCase): ...@@ -394,12 +397,30 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
self.stepTic() self.stepTic()
self._clearCache() self._clearCache()
self.assertTrue(person.isPasswordExpired()) self.assertTrue(person.isPasswordExpired())
self.assertTrue(request['is_user_account_password_expired'])
# set longer password validity interval # set longer password validity interval
preference.setPreferredMaxPasswordLifetimeDuration(4*24) person.setLastPasswordModificationDate(now)
preference.setPreferredMaxPasswordLifetimeDuration(4*24) # password expire in 4 days
self.stepTic()
self._clearCache()
self.assertFalse(person.isPasswordExpired())
self.assertFalse(request['is_user_account_password_expired'])
# test early warning password expire notification is detected
preference.setPreferredPasswordLifetimeExpireWarningDuration(4*24) # password expire notification appear immediately
self.stepTic() self.stepTic()
self._clearCache() self._clearCache()
self.assertFalse(person.isPasswordExpired()) self.assertFalse(person.isPasswordExpired())
self.assertTrue(request['is_user_account_password_expired_warning_on'])
# test early warning password expire notification is detected
preference.setPreferredPasswordLifetimeExpireWarningDuration(4*24-24) # password expire notification appear 3 days befor time
self.stepTic()
self._clearCache()
self.assertFalse(person.isPasswordExpired())
#import pdb; pdb.set_trace()
self.assertFalse(request['is_user_account_password_expired_warning_on'])
def test_suite(): def test_suite():
......
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