Ticket #5535 (closed Bug: fixed)
acl_users.getUser(owner) returns wrong user when users with similar login names exist
| Reported by: | mt | Owned by: | wichert |
|---|---|---|---|
| Priority: | major | Milestone: | 2.5 |
| Component: | Users/Groups | Keywords: | ZODBUserManager |
| Cc: |
Description (last modified by wichert) (diff)
PluggableAuthService with plugin ZODBUserManager returns an incorrect user when users with similar login names exist. e.g. system with two users 'editor' and 'copyeditor' PloneTool.py line 441
user = acl_users.getUser(owner)
will return the user 'copyeditor' when you enter 'editor' Appending the following test case to PluggableAuthService/plugins/tests/test_ZODBUserManager.py shows the test failing
def test_changeOwnership(self):
zum = self._makeOne()
zum.addUser('copyeditor', 'copyeditor', 'password')
zum.addUser('editor', 'editor', 'password')
info = zum.enumerateUsers(login='editor')
self.assertEqual(info[0]['login'], 'editor')
then
cd zopeinstance ./bin/zopectl test --dir Products/PluggableAuthService
note: info[0] is used in the test as this is what is used in the function _verifyUser (PluggableAuthService.py line 785)
Change History
comment:2 Changed 6 years ago by wichert
Can you retry with enumerateUsres(login='editor', exact=True) ?
comment:3 Changed 6 years ago by mt
Hi Wichert, If I rerun the test with
info = zum.enumerateUsers(login='editor', exact_match=True)
the test passes fine, however the same problem arises with the getUsers function,
acl_users.getUser(owner)
How do I make it obey exact_match ?

The correct formatting for the test above is
def test_changeOwnership(self): zum = self._makeOne() zum.addUser('copyeditor', 'copyeditor', 'password') zum.addUser('editor', 'editor', 'password') info = zum.enumerateUsers(login='editor') self.assertEqual(info[0]['login'], 'editor')