[Zope3-checkins] CVS: Zope3/src/zope/app/services/pluggableauth/tests - test_pluggableauth.py:1.8

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:06:52 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/services/pluggableauth/tests
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/services/pluggableauth/tests

Modified Files:
	test_pluggableauth.py 
Log Message:


Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.




=== Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py:1.7	Fri Nov 21 12:12:13 2003
+++ Zope3/src/zope/app/services/pluggableauth/tests/test_pluggableauth.py	Mon Mar  8 07:06:21 2004
@@ -11,14 +11,17 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Pluggable Auth Tests
+
 $Id$
 """
-
 from unittest import TestCase, TestSuite, main, makeSuite
+from zope.testing.doctestunit import DocTestSuite
+from zope.interface.verify import verifyObject
+
+from zope.app import zapi
 from zope.app.tests import ztapi
 from zope.app.services.auth import User
-from zope.app.services.servicenames import Adapters
 from zope.app.services.tests import placefulsetup
 
 from zope.exceptions import NotFoundError
@@ -29,10 +32,11 @@
 from zope.app.services.pluggableauth import BTreePrincipalSource, \
      SimplePrincipal, PluggableAuthenticationService, \
      PrincipalAuthenticationView
+from zope.app.interfaces.services.pluggableauth import IPrincipalSource
 
 from zope.app.interfaces.services.pluggableauth import IUserSchemafied
-from zope.app.interfaces.security import IPrincipal
-from zope.interface.verify import verifyObject
+from zope.app.security.interfaces import IPrincipal, ILoginPassword
+from zope.app.security.basicauthadapter import BasicAuthAdapter
 
 from zope.publisher.browser import TestRequest as Request
 
@@ -44,19 +48,14 @@
 class Setup(placefulsetup.PlacefulSetup, TestCase):
 
     def setUp(self):
-        from zope.app.interfaces.services.pluggableauth import IPrincipalSource
         sm = placefulsetup.PlacefulSetup.setUp(self, site=True)
-        from zope.component import getService
-        from zope.app.security.basicauthadapter import BasicAuthAdapter
-        from zope.app.interfaces.security import ILoginPassword
-        ztapi.provideAdapter(
-            IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
+        ztapi.provideAdapter(IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
 
         ztapi.browserView(IPrincipalSource, "login",
                           (PrincipalAuthenticationView,))
 
         auth = setup.addService(sm, "TestPluggableAuthenticationService",
-                                 PluggableAuthenticationService())
+                                PluggableAuthenticationService())
 
         one = BTreePrincipalSource()
         two = BTreePrincipalSource()
@@ -125,7 +124,7 @@
 
     def testAuthServiceGetPrincipal(self):
         auth = self._auth
-        id = self._slinkp.getId()
+        id = self._slinkp.id
         self.assertEqual(self._slinkp, auth.getPrincipal(id))
         self.assertRaises(NotFoundError, self._fail_NoSourceId)
         self.assertRaises(NotFoundError, self._fail_BadIdType)
@@ -151,7 +150,7 @@
     def test_getPrincipal(self):
         one = self._one
         p = self._slinkp
-        self.assertEqual(p, one.getPrincipal(p.getId()))
+        self.assertEqual(p, one.getPrincipal(p.id))
 
 class PrincipalAuthenticationViewTest(Setup):
 
@@ -163,7 +162,6 @@
 
 def test_suite():
     t1 = makeSuite(AuthServiceTest)
-    from zope.testing.doctestunit import DocTestSuite
     t2 = DocTestSuite('zope.app.services.pluggableauth',
                       setUp=setUp, tearDown=tearDown)
     t3 = makeSuite(BTreePrincipalSourceTest)




More information about the Zope3-Checkins mailing list