[Checkins] SVN: PluggableAuthService/branches/1.4/ Issue #59: fix barf in '_findMathces' when no default policy has been created.

Tres Seaver tseaver at palladion.com
Mon Sep 17 16:09:53 EDT 2007


Log message for revision 79722:
  Issue #59:  fix barf in '_findMathces' when no default policy has been created.

Changed:
  U   PluggableAuthService/branches/1.4/doc/CHANGES.txt
  U   PluggableAuthService/branches/1.4/plugins/DomainAuthHelper.py
  U   PluggableAuthService/branches/1.4/plugins/tests/test_DomainAuthHelper.py
  U   PluggableAuthService/branches/1.4/version.txt

-=-
Modified: PluggableAuthService/branches/1.4/doc/CHANGES.txt
===================================================================
--- PluggableAuthService/branches/1.4/doc/CHANGES.txt	2007-09-17 16:07:57 UTC (rev 79721)
+++ PluggableAuthService/branches/1.4/doc/CHANGES.txt	2007-09-17 20:09:52 UTC (rev 79722)
@@ -1,5 +1,14 @@
 PluggableAuthService changelog
 
+  After PluggableAuthService 1.4.2
+
+    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.4.2 (2007/04/24)
 
     Bugs Fixed

Modified: PluggableAuthService/branches/1.4/plugins/DomainAuthHelper.py
===================================================================
--- PluggableAuthService/branches/1.4/plugins/DomainAuthHelper.py	2007-09-17 16:07:57 UTC (rev 79721)
+++ PluggableAuthService/branches/1.4/plugins/DomainAuthHelper.py	2007-09-17 20:09:52 UTC (rev 79722)
@@ -166,18 +166,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.4/plugins/tests/test_DomainAuthHelper.py
===================================================================
--- PluggableAuthService/branches/1.4/plugins/tests/test_DomainAuthHelper.py	2007-09-17 16:07:57 UTC (rev 79721)
+++ PluggableAuthService/branches/1.4/plugins/tests/test_DomainAuthHelper.py	2007-09-17 20:09:52 UTC (rev 79722)
@@ -87,9 +87,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.4/version.txt
===================================================================
--- PluggableAuthService/branches/1.4/version.txt	2007-09-17 16:07:57 UTC (rev 79721)
+++ PluggableAuthService/branches/1.4/version.txt	2007-09-17 20:09:52 UTC (rev 79722)
@@ -1 +1 @@
-PluggableAuthService-1.4.2
+PluggableAuthService-1.4.2+



More information about the Checkins mailing list