- Bug: Demangling user prefix could not deal with non-string user
ids, which may appear in certain cases. (https://bugs.launchpad.net/bugs/586931) git-svn-id: http://svn.dataflake.org/svn/Products.LDAPMultiPlugins/trunk@1969 835909ba-7c00-0410-bfa4-884f43845301
This commit is contained in:
parent
724e730fc5
commit
aa514ba896
|
@ -6,6 +6,10 @@ To see earlier changes please see HISTORY.txt.
|
|||
2.0 (unreleased)
|
||||
----------------
|
||||
|
||||
- Bug: Demangling user prefix could not deal with non-string user
|
||||
ids, which may appear in certain cases.
|
||||
(https://bugs.launchpad.net/bugs/586931)
|
||||
|
||||
- Bug: Added GenericSetup magic to fully provide the INode interface
|
||||
for the exporter and importer classes, making it easier to nest
|
||||
within other importers.
|
||||
|
|
|
@ -153,6 +153,10 @@ class LDAPPluginBase(Folder, BasePlugin, Cacheable):
|
|||
|
||||
security.declarePrivate('_demangle')
|
||||
def _demangle(self, princid):
|
||||
# Sanity check
|
||||
if not isinstance(princid, basestring):
|
||||
return None
|
||||
|
||||
# User must start with our prefix (which is likely to be blank anyway)
|
||||
if not princid.startswith(self.prefix):
|
||||
return None
|
||||
|
|
|
@ -17,25 +17,26 @@ $Id$
|
|||
|
||||
import unittest
|
||||
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IUserEnumerationPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IGroupsPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IGroupEnumerationPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IRoleEnumerationPlugin
|
||||
|
||||
from Products.LDAPMultiPlugins.interfaces import ILDAPMultiPlugin
|
||||
|
||||
|
||||
class LMPBaseTests(unittest.TestCase):
|
||||
|
||||
def _makeOne(self):
|
||||
return self._getTargetClass()('testplugin')
|
||||
|
||||
def _getTargetClass(self):
|
||||
from Products.LDAPMultiPlugins.LDAPPluginBase import LDAPPluginBase
|
||||
return LDAPPluginBase
|
||||
|
||||
def test_interfaces(self):
|
||||
from Products.LDAPMultiPlugins.interfaces import ILDAPMultiPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IUserEnumerationPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IGroupsPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IGroupEnumerationPlugin
|
||||
from Products.PluggableAuthService.interfaces.plugins import \
|
||||
IRoleEnumerationPlugin
|
||||
from zope.interface.verify import verifyClass
|
||||
|
||||
verifyClass(ILDAPMultiPlugin, self._getTargetClass())
|
||||
|
@ -45,6 +46,14 @@ class LMPBaseTests(unittest.TestCase):
|
|||
verifyClass(IGroupEnumerationPlugin, self._getTargetClass())
|
||||
verifyClass(IRoleEnumerationPlugin, self._getTargetClass())
|
||||
|
||||
def test_demangle_invalid_userid(self):
|
||||
plugin = self._makeOne()
|
||||
plugin.prefix = 'prefix_'
|
||||
|
||||
self.assertEquals(plugin._demangle(None), None)
|
||||
self.assertEquals(plugin._demangle('incorrectprefix'), None)
|
||||
self.assertEquals(plugin._demangle('prefix_user1'), 'user1')
|
||||
|
||||
|
||||
class ADMPTests(LMPBaseTests):
|
||||
|
||||
|
|
Reference in New Issue