Changeset 11975 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Timestamp:
- 16 Nov 2014, 23:05:04 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r11974 r11975 446 446 'K1000000 - account activated' in logcontent) 447 447 448 449 def test_login_as_customer(self): 450 # CustomerImpersonators can login as customer 451 # Create clearance officer 452 self.app['users'].addUser('mrofficer', 'mrofficersecret') 453 self.app['users']['mrofficer'].email = 'mrofficer@foo.ng' 454 self.app['users']['mrofficer'].title = 'Harry Actor' 455 prmglobal = IPrincipalRoleManager(self.app) 456 prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer') 457 prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer') 458 # Login as customer impersonator 459 self.browser.open(self.login_path) 460 self.browser.getControl(name="form.login").value = 'mrofficer' 461 self.browser.getControl(name="form.password").value = 'mrofficersecret' 462 self.browser.getControl("Login").click() 463 self.assertMatches('...You logged in...', self.browser.contents) 464 self.browser.open(self.customer_path) 465 self.browser.getLink("Login as").click() 466 self.browser.getControl("Set password now").click() 467 temp_password = self.browser.getControl(name='form.password').value 468 self.browser.getControl("Login now").click() 469 self.assertMatches( 470 '...You successfully logged in as...', self.browser.contents) 471 # We are logged in as customer and can see the 'My Data' tab 472 self.assertMatches( 473 '...<a href="#" class="dropdown-toggle" data-toggle="dropdown">...', 474 self.browser.contents) 475 self.assertMatches( 476 '...My Data...', 477 self.browser.contents) 478 self.browser.getLink("Logout").click() 479 # The customer can't login with the original password ... 480 self.browser.open(self.login_path) 481 self.browser.getControl(name="form.login").value = self.customer_id 482 self.browser.getControl(name="form.password").value = 'spwd' 483 self.browser.getControl("Login").click() 484 self.assertMatches( 485 '...Your account has been temporarily deactivated...', 486 self.browser.contents) 487 # ... but with the temporary password 488 self.browser.open(self.login_path) 489 self.browser.getControl(name="form.login").value = self.customer_id 490 self.browser.getControl(name="form.password").value = temp_password 491 self.browser.getControl("Login").click() 492 self.assertMatches('...You logged in...', self.browser.contents) 493 # Creation of temp_password is properly logged 494 logfile = os.path.join( 495 self.app['datacenter'].storage, 'logs', 'customers.log') 496 logcontent = open(logfile).read() 497 self.assertTrue( 498 'mrofficer - customers.browser.LoginAsCustomerStep1 - K1000000 - ' 499 'temp_password generated: %s' % temp_password in logcontent)
Note: See TracChangeset for help on using the changeset viewer.