Commit 9879579a authored by Ivan Tyagov's avatar Ivan Tyagov

Add alarm test for expired events (authentication).

parent b0ff42f9
......@@ -581,6 +581,42 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
response = self.publish(path)
self.assertTrue('Welcome to ERP5' in response.getBody())
def test_06_ExpireOldAuthenticationEventList(self):
"""
Check that expiring old Authentication Event list works.
"""
portal = self.getPortal()
person = portal.portal_catalog.getResultValue(portal_type = 'Person',
reference = 'test')
preference = portal.portal_catalog.getResultValue(portal_type = 'System Preference',
title = 'Authentication',)
# file some failures so we should detect and block account
person.notifyLoginFailure()
person.notifyLoginFailure()
person.notifyLoginFailure()
self.stepTic()
# should be blocked
self.assertTrue(person.isLoginBlocked())
# set 0 check interval
preference.setPreferredAuthenticationFailureCheckDuration(0)
self.stepTic()
self._clearCache()
time.sleep(1) # we need to give a moment
self.assertFalse(person.isLoginBlocked())
# expire manually old
portal.system_event_module.SystemEventModule_expireAuthenticationEventList()
self.stepTic()
self.assertEqual(3, len(portal.portal_catalog(portal_type ="Authentication Event",
default_destination_uid = person.getUid(),
validation_state = "expired")))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestAuthenticationPolicy))
......
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