[Zope-CVS] CVS: Products/CookieCrumbler/tests - testCookieCrumbler.py:1.3
Shane Hathaway
shane@zope.com
Fri, 13 Jun 2003 12:40:05 -0400
Update of /cvs-repository/Products/CookieCrumbler/tests
In directory cvs.zope.org:/tmp/cvs-serv19217/tests
Modified Files:
testCookieCrumbler.py
Log Message:
New test that verifies CC chooses login over resume
=== Products/CookieCrumbler/tests/testCookieCrumbler.py 1.2 => 1.3 ===
--- Products/CookieCrumbler/tests/testCookieCrumbler.py:1.2 Tue Jun 10 13:44:46 2003
+++ Products/CookieCrumbler/tests/testCookieCrumbler.py Fri Jun 13 12:40:04 2003
@@ -54,12 +54,13 @@
root = Folder()
self.root = root
root.isTopLevelPrincipiaApplicationObject = 1 # User folder needs this
- root.getPhysicalPath = lambda: ()
+ root.getPhysicalPath = lambda: () # hack
root._View_Permission = ('Anonymous',)
users = UserFolder()
users._setId('acl_users')
users._doAddUser('abraham', 'pass-w', ('Patriarch',), ())
+ users._doAddUser('isaac', 'pass-w', ('Son',), ())
root._setObject(users.id, users)
cc = CookieCrumbler()
@@ -266,6 +267,20 @@
self.root.cookie_authentication.unauth_page = 'login_form'
self.req.cookies['__ac'] = self.credentials
self.assertRaises('Redirect', self.req.traverse, '/protected')
+
+
+ def testLoginRatherThanResume(self):
+ # When the user presents both a session resume and new
+ # credentials, choose the new credentials (so that it's
+ # possible to log in without logging out)
+ self.req.cookies['__ac_name'] = 'isaac'
+ self.req.cookies['__ac_password'] = 'pass-w'
+ self.req.cookies['__ac'] = self.credentials
+ self.req.traverse('/')
+
+ self.assert_(self.req.has_key('AUTHENTICATED_USER'))
+ self.assertEqual(self.req['AUTHENTICATED_USER'].getUserName(),
+ 'isaac')
if __name__ == '__main__':