- Timestamp:
- 20 Oct 2016, 21:13:17 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/mandates/tests.py
r12816 r14221 89 89 # Add and execute a mandate with missing parameters. 90 90 mandate = PasswordMandate() 91 IUserAccount(customer).setPassword('old_pw') 91 92 self.app['mandates'].addMandate(mandate) 92 msg= mandate.execute()93 (msg, redirect_path) = mandate.execute() 93 94 self.assertEqual(msg, u'Wrong mandate parameters.') 94 95 # Add and execute an expired mandate. 95 96 mandate = PasswordMandate(days=0) 97 mandate.params['user'] = customer 98 mandate.params['password'] = 'mypwd1' 96 99 self.app['mandates'].addMandate(mandate) 97 msg= mandate.execute()100 (msg, redirect_path) = mandate.execute() 98 101 self.assertEqual(msg, u'Mandate expired.') 102 self.assertEqual(redirect_path, '') 103 # Password has not been set 104 self.assertTrue(IUserAccount(customer).checkPassword('old_pw')) 99 105 # Add and execute a perfect mandate 100 106 mandate = PasswordMandate() … … 102 108 mandate.params['password'] = 'mypwd1' 103 109 self.app['mandates'].addMandate(mandate) 104 msg= mandate.execute()110 (msg, redirect_path) = mandate.execute() 105 111 # Password has been set. 106 112 self.assertEqual(msg, 'Password has been successfully set. Login with your new password.') … … 120 126 mandate.params['password'] = 'mypwd1' 121 127 self.app['mandates'].addMandate(mandate) 122 msg= mandate.execute()128 (msg, redirect_path) = mandate.execute() 123 129 # Password has been set. 124 130 self.assertEqual(msg, 'Password has been successfully set. Login with your new password.') … … 142 148 self.assertEqual(len(self.app['mandates'].keys()), 1) 143 149 self.assertEqual([i for i in self.app['mandates'].keys()], [u'23456']) 150 logfile = os.path.join( 151 self.app['datacenter'].storage, 'logs', 'main.log') 152 logcontent = open(logfile).read() 153 self.assertTrue('system - 1 mandates purged' in logcontent) 154 155 def test_purge_mandates(self): 156 # mandate1 is an old mandate which just expired. 157 mandate1 = PasswordMandate(days=0) 158 self.app['mandates'].addMandate(mandate1) 159 # mandate2 is a new mandate with default time delta. 160 mandate2 = PasswordMandate(mandate_id='23456') 161 self.app['mandates'].addMandate(mandate2) 162 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 163 self.browser.open('http://localhost/app/configuration') 164 self.assertEqual(self.app['mandates'].count, (1, 1, 2)) 165 self.assertTrue('<span>expired</span>' in self.browser.contents) 166 self.browser.getControl("Purge mandates").click() 167 self.assertTrue('1 mandate(s) were purged' in self.browser.contents) 168 self.assertEqual(self.app['mandates'].count, (1, 0, 1)) 169 return 144 170 145 171 def test_browser(self):
Note: See TracChangeset for help on using the changeset viewer.