[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests - test_zopepolicy.py:1.13.24.1

Jim Fulton jim at zope.com
Mon Sep 8 15:22:17 EDT 2003


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

Modified Files:
      Tag: parentgeddon-branch
	test_zopepolicy.py 
Log Message:
Checking in work in progress on parentgeddon-branch so Fred can help
me to get the tests passing.  Specific log entries will be provided
when we merge this into the head.


=== Zope3/src/zope/app/security/tests/test_zopepolicy.py 1.13 => 1.13.24.1 ===
--- Zope3/src/zope/app/security/tests/test_zopepolicy.py:1.13	Sat Jun  7 01:46:06 2003
+++ Zope3/src/zope/app/security/tests/test_zopepolicy.py	Mon Sep  8 14:21:46 2003
@@ -26,7 +26,6 @@
 from zope.app.interfaces.security import IRoleService
 from zope.app.interfaces.security import IAuthenticationService
 
-from zope.app.context import ContextWrapper
 from zope.component import getService
 from zope.app.services.servicenames import Roles, Permissions, Adapters
 from zope.app.services.servicenames import Authentication
@@ -193,15 +192,15 @@
             IPrincipalRoleManager, AnnotationPrincipalRoleManager)
 
         ob1 = TestClass()
-        ob2 = TestClass()
-        ob3 = TestClass()
-        ob  = ContextWrapper(ob3, ContextWrapper(ob2, ob1))
+        ob2 = TestClass(); ob2.__parent__ = ob1
+        ob3 = TestClass(); ob3.__parent__ = ob2
+        
         self.failIf(self.policy.checkPermission(
-            self.write, ob, Context(self.jim)))
-        AnnotationPrincipalRoleManager(ob).assignRoleToPrincipal(
+            self.write, ob3, Context(self.jim)))
+        AnnotationPrincipalRoleManager(ob3).assignRoleToPrincipal(
             self.manager, self.jim.getId())
         self.failUnless(self.policy.checkPermission(
-            self.write, ob, Context(self.jim)))
+            self.write, ob3, Context(self.jim)))
 
 
     def testPlayfulRolePermissions(self):
@@ -213,35 +212,33 @@
         test = test.getId()
 
         ob1 = TestClass()
-        ob2 = TestClass()
-        ob3 = TestClass()
+        ob2 = TestClass(); ob2.__parent__ = ob1
+        ob3 = TestClass(); ob3.__parent__ = ob2
 
-        ob  = ContextWrapper(ob3, ContextWrapper(ob2, ob1))
-
-        self.failIf(self.policy.checkPermission(test, ob, Context(self.tim)))
-        self.__assertPermissions(self.tim, ['read', 'write'], ob)
+        self.failIf(self.policy.checkPermission(test, ob3, Context(self.tim)))
+        self.__assertPermissions(self.tim, ['read', 'write'], ob3)
 
         ARPM(ob2).grantPermissionToRole(test, self.manager)
-        self.failUnless(self.policy.checkPermission(test, ob,
+        self.failUnless(self.policy.checkPermission(test, ob3,
                                                     Context(self.tim)))
-        self.__assertPermissions(self.tim, ['read', 'test', 'write'], ob)
+        self.__assertPermissions(self.tim, ['read', 'test', 'write'], ob3)
 
-        self.failIf(self.policy.checkPermission(test, ob, Context(self.jim)))
-        self.__assertPermissions(self.jim, ['create', 'read'], ob)
+        self.failIf(self.policy.checkPermission(test, ob3, Context(self.jim)))
+        self.__assertPermissions(self.jim, ['create', 'read'], ob3)
 
 
         ARPM(ob3).grantPermissionToRole(test, self.peon)
         self.failUnless(self.policy.checkPermission(
-            test, ob, Context(self.jim)))
-        self.__assertPermissions(self.jim, ['create', 'read', 'test'], ob)
+            test, ob3, Context(self.jim)))
+        self.__assertPermissions(self.jim, ['create', 'read', 'test'], ob3)
 
 
 
         principalPermissionManager.denyPermissionToPrincipal(
             test, self.jim.getId())
         self.failIf(self.policy.checkPermission(
-            test, ob, Context(self.jim)))
-        self.__assertPermissions(self.jim, ['create', 'read'], ob)
+            test, ob3, Context(self.jim)))
+        self.__assertPermissions(self.jim, ['create', 'read'], ob3)
 
         principalPermissionManager.unsetPermissionForPrincipal(
             test, self.jim.getId())
@@ -254,12 +251,12 @@
         new = principalRegistry.definePrincipal('new', 'Newbie',
                                                 'Newbie User', 'new', '098')
         principalRoleManager.assignRoleToPrincipal(self.arole, new.getId())
-        self.failUnless(self.policy.checkPermission(test, ob, Context(new)))
-        self.__assertPermissions(new, ['test'], ob)
+        self.failUnless(self.policy.checkPermission(test, ob3, Context(new)))
+        self.__assertPermissions(new, ['test'], ob3)
 
         principalRoleManager.assignRoleToPrincipal(self.peon, new.getId())
-        self.failIf(self.policy.checkPermission(test, ob, Context(new)))
-        self.__assertPermissions(new, ['read'], ob)
+        self.failIf(self.policy.checkPermission(test, ob3, Context(new)))
+        self.__assertPermissions(new, ['read'], ob3)
 
     def testPlayfulPrinciplePermissions(self):
         APPM = AnnotationPrincipalPermissionManager
@@ -267,47 +264,46 @@
                        IPrincipalPermissionManager, APPM)
 
         ob1 = TestClass()
-        ob2 = TestClass()
-        ob3 = TestClass()
+        ob2 = TestClass(); ob2.__parent__ = ob1
+        ob3 = TestClass(); ob3.__parent__ = ob2
 
         test = permissionRegistry.definePermission('test', 'Test', '')
         test = test.getId()
 
-        ob  = ContextWrapper(ob3, ContextWrapper(ob2, ob1))
-        self.failIf(self.policy.checkPermission(test, ob, Context(self.tim)))
+        self.failIf(self.policy.checkPermission(test, ob3, Context(self.tim)))
 
-        self.__assertPermissions(self.tim, ['read', 'write'], ob)
+        self.__assertPermissions(self.tim, ['read', 'write'], ob3)
 
         APPM(ob2).grantPermissionToPrincipal(test, self.tim.getId())
-        self.failUnless(self.policy.checkPermission(test, ob,
+        self.failUnless(self.policy.checkPermission(test, ob3,
                                                     Context(self.tim)))
-        self.__assertPermissions(self.tim, ['read', 'test', 'write'], ob)
+        self.__assertPermissions(self.tim, ['read', 'test', 'write'], ob3)
 
         APPM(ob3).denyPermissionToPrincipal(test, self.tim.getId())
-        self.failIf(self.policy.checkPermission(test, ob,
+        self.failIf(self.policy.checkPermission(test, ob3,
                                                 Context(self.tim)))
-        self.__assertPermissions(self.tim, ['read', 'write'], ob)
+        self.__assertPermissions(self.tim, ['read', 'write'], ob3)
 
         APPM(ob1).denyPermissionToPrincipal(test, self.jim.getId())
         APPM(ob3).grantPermissionToPrincipal(test, self.jim.getId())
-        self.failUnless(self.policy.checkPermission(test, ob,
+        self.failUnless(self.policy.checkPermission(test, ob3,
                                                     Context(self.jim)))
-        self.__assertPermissions(self.jim, ['create', 'read', 'test'], ob)
+        self.__assertPermissions(self.jim, ['create', 'read', 'test'], ob3)
 
 
         APPM(ob3).unsetPermissionForPrincipal(test, self.jim.getId())
-        self.failIf(self.policy.checkPermission(test, ob,
+        self.failIf(self.policy.checkPermission(test, ob3,
                                                 Context(self.jim)))
-        self.__assertPermissions(self.jim, ['create', 'read'], ob)
+        self.__assertPermissions(self.jim, ['create', 'read'], ob3)
 
         # make sure placeless principal permissions override placeful ones
-        APPM(ob).grantPermissionToPrincipal(test, self.tim.getId())
+        APPM(ob3).grantPermissionToPrincipal(test, self.tim.getId())
         principalPermissionManager.denyPermissionToPrincipal(
             test, self.tim.getId())
-        self.failIf(self.policy.checkPermission(test, ob,
+        self.failIf(self.policy.checkPermission(test, ob3,
                                                 Context(self.tim)))
 
-        self.__assertPermissions(self.tim, ['read', 'write'], ob)
+        self.__assertPermissions(self.tim, ['read', 'write'], ob3)
 
 
 class ITest(IAttributeAnnotatable):




More information about the Zope3-Checkins mailing list