[Checkins] SVN: PluggableAuthService/branches/1.5/ Issue #59: fix
barf in '_findMathces' when no default policy has been created.
Tres Seaver
tseaver at palladion.com
Mon Sep 17 16:12:05 EDT 2007
Log message for revision 79723:
Issue #59: fix barf in '_findMathces' when no default policy has been created.
Changed:
U PluggableAuthService/branches/1.5/doc/CHANGES.txt
U PluggableAuthService/branches/1.5/plugins/DomainAuthHelper.py
U PluggableAuthService/branches/1.5/plugins/tests/test_DomainAuthHelper.py
U PluggableAuthService/branches/1.5/version.txt
-=-
Modified: PluggableAuthService/branches/1.5/doc/CHANGES.txt
===================================================================
--- PluggableAuthService/branches/1.5/doc/CHANGES.txt 2007-09-17 20:09:52 UTC (rev 79722)
+++ PluggableAuthService/branches/1.5/doc/CHANGES.txt 2007-09-17 20:12:04 UTC (rev 79723)
@@ -1,5 +1,14 @@
PluggableAuthService changelog
+ After PluggableAuthService 1.5.1
+
+ Bugs fixed
+
+ - DomainAuthHelper plugin: fix glitch for plugins which have never
+ configured any "default" policy: 'authenticateCredentials' and
+ 'getRolesForPrincipal' would raise ValueError.
+ (http://www.zope.org/Collectors/PAS/59)
+
PluggableAuthService 1.5.1 (2007/09/11)
Bugs fixed
Modified: PluggableAuthService/branches/1.5/plugins/DomainAuthHelper.py
===================================================================
--- PluggableAuthService/branches/1.5/plugins/DomainAuthHelper.py 2007-09-17 20:09:52 UTC (rev 79722)
+++ PluggableAuthService/branches/1.5/plugins/DomainAuthHelper.py 2007-09-17 20:12:04 UTC (rev 79723)
@@ -172,18 +172,18 @@
return tuple(matches)
all_info = list(self._domain_map.get(login, []))
- all_info.extend(self._domain_map.get(''))
+ all_info.extend(self._domain_map.get('', []))
if not r_host:
try:
r_host = socket.gethostbyaddr(r_address)[0]
- except socket.herror:
+ except socket.error:
pass
if not r_address:
try:
r_address = socket.gethostbyname(r_host)
- except socket.herror :
+ except socket.error :
pass
if not r_host and not r_address:
Modified: PluggableAuthService/branches/1.5/plugins/tests/test_DomainAuthHelper.py
===================================================================
--- PluggableAuthService/branches/1.5/plugins/tests/test_DomainAuthHelper.py 2007-09-17 20:09:52 UTC (rev 79722)
+++ PluggableAuthService/branches/1.5/plugins/tests/test_DomainAuthHelper.py 2007-09-17 20:12:04 UTC (rev 79723)
@@ -105,9 +105,60 @@
{'remote_host': 'foo',
'remote_address': ''})
- # TODO add tests for authenticateCredentials, getRolesForPrincipal, etc.
+ def test_authenticateCredentials_empty_mapping_empty_creds(self):
+ creds = {}
+ helper = self._makeOne()
+ self.assertEqual(helper.authenticateCredentials(creds), (None, None))
+ def test_authenticateCredentials_empty_mapping_nonesuch_remote_host(self):
+ creds = {'remote_host': 'foo'}
+ helper = self._makeOne()
+ self.assertEqual(helper.authenticateCredentials(creds), (None, None))
+ def test_authenticateCredentials_empty_mapping_nonesuch_remote_addr(self):
+ creds = {'remote_address': 'bam'}
+ helper = self._makeOne()
+ self.assertEqual(helper.authenticateCredentials(creds), (None, None))
+
+ def test_authenticateCredentials_w_mapping_known_remote_host(self):
+ from Products.PluggableAuthService.plugins.DomainAuthHelper \
+ import _MATCH_EQUALS
+
+ creds = {'login': 'qux', 'remote_host': 'bam'}
+ helper = self._makeOne()
+ helper.manage_addMapping(match_type=_MATCH_EQUALS, match_string='bam')
+
+ self.assertEqual(helper.authenticateCredentials(creds), ('qux', 'qux'))
+
+ def test_authenticateCredentials_w_mapping_known_remote_addr(self):
+ from Products.PluggableAuthService.plugins.DomainAuthHelper \
+ import _MATCH_ENDSWITH
+
+ creds = {'login': 'qux', 'remote_address': 'baz'}
+ helper = self._makeOne()
+ helper.manage_addMapping(match_type=_MATCH_ENDSWITH,
+ match_string='z',
+ username='foo',
+ )
+
+ self.assertEqual(helper.authenticateCredentials(creds), ('qux', 'qux'))
+
+ def test_authenticateCredentials_w_mapping_no_login_known_remote_host(self):
+ from Products.PluggableAuthService.plugins.DomainAuthHelper \
+ import _MATCH_EQUALS
+
+ creds = {'remote_host': 'baz'}
+ helper = self._makeOne()
+ helper.manage_addMapping(match_type=_MATCH_EQUALS,
+ match_string='baz',
+ username='foo',
+ )
+
+ self.assertEqual(helper.authenticateCredentials(creds), ('foo', 'foo'))
+
+ # TODO add tests for getRolesForPrincipal, etc.
+
+
if __name__ == "__main__":
unittest.main()
Modified: PluggableAuthService/branches/1.5/version.txt
===================================================================
--- PluggableAuthService/branches/1.5/version.txt 2007-09-17 20:09:52 UTC (rev 79722)
+++ PluggableAuthService/branches/1.5/version.txt 2007-09-17 20:12:04 UTC (rev 79723)
@@ -1 +1 @@
-PluggableAuthService-1.5.1
+PluggableAuthService-1.5.1+
More information about the Checkins
mailing list