[Checkins] SVN: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/ LP #789858: don't allow conflicting login name in 'updateUser'.
Tres Seaver
tseaver at palladion.com
Mon May 30 12:53:48 EDT 2011
Log message for revision 121835:
LP #789858: don't allow conflicting login name in 'updateUser'.
Changed:
U Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt
U Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/ZODBUserManager.py
U Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/tests/test_ZODBUserManager.py
-=-
Modified: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt
===================================================================
--- Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt 2011-05-30 14:27:46 UTC (rev 121834)
+++ Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/doc/CHANGES.txt 2011-05-30 16:53:48 UTC (rev 121835)
@@ -4,6 +4,8 @@
PluggableAuthService 1.5.5 (unreleased)
---------------------------------------
+- Launchpad #789858: don't allow conflicting login name in 'updateUser'.
+
- Fixed broken markup.
- Don't fail on users defined in multiple user sources on the ZODBGroupManager
Modified: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/ZODBUserManager.py
===================================================================
--- Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/ZODBUserManager.py 2011-05-30 14:27:46 UTC (rev 121834)
+++ Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/ZODBUserManager.py 2011-05-30 16:53:48 UTC (rev 121835)
@@ -1,4 +1,4 @@
-##############################################################################
+#############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors
# Reserved.
@@ -296,10 +296,15 @@
# The following raises a KeyError if the user_id is invalid
old_login = self.getLoginForUserId(user_id)
- del self._login_to_userid[old_login]
- self._login_to_userid[login_name] = user_id
- self._userid_to_login[user_id] = login_name
+ if old_login != login_name:
+ if self._login_to_userid.get(login_name) is not None:
+ raise ValueError('Login name not available: %s' % login_name)
+
+ del self._login_to_userid[old_login]
+ self._login_to_userid[login_name] = user_id
+ self._userid_to_login[user_id] = login_name
+
security.declarePrivate( 'removeUser' )
def removeUser( self, user_id ):
Modified: Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/tests/test_ZODBUserManager.py
===================================================================
--- Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/tests/test_ZODBUserManager.py 2011-05-30 14:27:46 UTC (rev 121834)
+++ Products.PluggableAuthService/branches/1.5/Products/PluggableAuthService/plugins/tests/test_ZODBUserManager.py 2011-05-30 16:53:48 UTC (rev 121835)
@@ -440,6 +440,17 @@
self.assertEqual(user_id, 'user1')
self.assertEqual(login, 'user1 at foobar.com')
+ def test_updateUser_login_name_conflicts(self):
+ # See https://bugs.launchpad.net/zope-pas/+bug/789858
+ zum = self._makeOne()
+
+ # Create a user and make sure we can authenticate with it
+ zum.addUser( 'user1', 'user1 at example.com', 'password' )
+ zum.addUser( 'user2', 'user2 at example.com', 'other' )
+
+ self.assertRaises(ValueError,
+ zum.updateUser, 'user1', 'user2 at example.com')
+
def test_enumerateUsersWithOptionalMangling(self):
zum = self._makeOne()
More information about the checkins
mailing list