[Zope3-checkins] CVS: Zope3/src/zope/app/publication/tests - test_zopepublication.py:1.9

Albertas Agejevas alga@codeworks.lt
Thu, 13 Mar 2003 11:28:48 -0500


Update of /cvs-repository/Zope3/src/zope/app/publication/tests
In directory cvs.zope.org:/tmp/cvs-serv11423/src/zope/app/publication/tests

Modified Files:
	test_zopepublication.py 
Log Message:
Made SecurityManager.getPrincipal() return a Principal object wrapped
in a context of its AuthenticationService.


=== Zope3/src/zope/app/publication/tests/test_zopepublication.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/publication/tests/test_zopepublication.py:1.8	Tue Feb 25 16:49:22 2003
+++ Zope3/src/zope/app/publication/tests/test_zopepublication.py	Thu Mar 13 11:28:16 2003
@@ -30,7 +30,7 @@
 from zope.publisher.http import IHTTPRequest, HTTPCharsets
 
 from zope.security import simplepolicies
-from zope.security.management import setSecurityPolicy
+from zope.security.management import setSecurityPolicy, getSecurityManager
 
 from zope.app.security.registries.principalregistry import principalRegistry
 from zope.app.interfaces.security import IUnauthenticatedPrincipal
@@ -45,6 +45,8 @@
 
 from zope.component.service import serviceManager
 
+from zope.proxy.context import getWrapperContext
+
 from transaction import get_transaction
 from cStringIO import StringIO
 
@@ -298,16 +300,27 @@
         publication = ZopePublication(self.db)
 
         publication.beforeTraversal(request)
+        user = getSecurityManager().getPrincipal()
+        self.assertEqual(user, request.user)
+        self.assertEqual(getWrapperContext(user), principalRegistry)
         self.assertEqual(request.user.getId(), 'anonymous')
+        self.assertEqual(getWrapperContext(request.user), principalRegistry)
         root = publication.getApplication(request)
         publication.callTraversalHooks(request, root)
         self.assertEqual(request.user.getId(), 'anonymous')
         ob = publication.traverseName(request, root, 'f1')
         publication.callTraversalHooks(request, ob)
         self.assertEqual(request.user.getId(), 'test.anonymous')
+        self.assertEqual(getWrapperContext(request.user).__class__,
+                         AuthService1)
         ob = publication.traverseName(request, ob, 'f2')
         publication.afterTraversal(request, ob)
         self.assertEqual(request.user.getId(), 'test.bob')
+        self.assertEqual(getWrapperContext(request.user).__class__,
+                         AuthService2)
+        user = getSecurityManager().getPrincipal()
+        self.assertEqual(user, request.user)
+        self.assertEqual(getWrapperContext(user).__class__, AuthService2)
 
 def test_suite():
     return unittest.TestSuite((