[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testProtectClass.py:1.1.2.12.4.2 testSecurityManagement.py:NONE testSecurityManager.py:NONE

Jim Fulton jim@zope.com
Sat, 27 Apr 2002 12:59:21 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv26931/lib/python/Zope/App/Security/tests

Modified Files:
      Tag: SecurityProxy-branch
	testProtectClass.py 
Removed Files:
      Tag: SecurityProxy-branch
	testSecurityManagement.py testSecurityManager.py 
Log Message:
Moved security management modules to Zope.Security.

Added like_unto attribute to protect class so you can say that a class
has the same protections as another class::

  <security:protectClass name=".RootFolder." like_unto=".Folder." />

Added some additional calls to removeAllProxies in some component
lookup code while debugging integration of new security model.

Added protections for BTree types.


=== Zope3/lib/python/Zope/App/Security/tests/testProtectClass.py 1.1.2.12.4.1 => 1.1.2.12.4.2 ===
        <directive namespace="http://namespaces.zope.org/security"
           name="protectClass"
-          attributes="name, permission, interface, methods"
+          attributes="name, permission, interface, methods, like_unto"
           handler="Zope.App.Security.protectClass.">
-          <subdirective  namespace="http://namespaces.zope.org/security"
-                         name="protect"
-                         attributes="permission, interface, methods" />
-          <subdirective  namespace="http://namespaces.zope.org/security"
-                         name="instances"
-                         attributes="permission" />
+          <subdirective namespace="http://namespaces.zope.org/security"
+                        name="protect"
+                        attributes="permission, interface, methods, like_unto"
+                        />
        </directive>
        <security:permission permission_id="extravagant" title="extravagant" />
        <security:permission permission_id="paltry" title="paltry" />
@@ -56,16 +54,18 @@
 
     def setUp(self):
         defineDirectives()
-        class C:
-            __implements__ = I
+        class B:
             def m1(self):
                 return "m1"
             def m2(self):
                 return "m2"
+        class C(B):
+            __implements__ = I
             def m3(self):
                 return "m3"
             def m4(self):
                 return "m4"
+        TestModule.test_base = B
         TestModule.test_class = C
         TestModule.test_instance = C()
         self.assertState()
@@ -204,6 +204,29 @@
         # m1 and m2 are in the interface, so should be set, and m3 should not:
         self.assertDeclaration(declaration,
                                instP=P1, m1P=P1, m2P=P1)
+
+
+    def testLikeUntoOnly(self):
+        declaration = ("""
+        <security:protectClass name="%s" names="m1,m2" permission_id="%s" />
+        <security:protectClass name="%s" like_unto="%s" />
+        """  % (PREFIX+"test_base", P1,
+                PREFIX+"test_class", PREFIX+"test_base"))
+        # m1 and m2 are in the interface, so should be set, and m3 should not:
+        self.assertDeclaration(declaration,
+                               m1P=P1, m2P=P1)
+        
+
+    def testLikeUntoAsDefault(self):
+        declaration = ("""
+        <security:protectClass name="%s" names="m1,m2" permission_id="%s" />
+        <security:protectClass name="%s" like_unto="%s"
+            names="m2,m3" permission_id="%s"/>
+        """  % (PREFIX+"test_base", P1,
+                PREFIX+"test_class", PREFIX+"test_base", P2))
+        # m1 and m2 are in the interface, so should be set, and m3 should not:
+        self.assertDeclaration(declaration,
+                               m1P=P1, m2P=P2, m3P=P2)
         
 
 

=== Removed File Zope3/lib/python/Zope/App/Security/tests/testSecurityManagement.py ===

=== Removed File Zope3/lib/python/Zope/App/Security/tests/testSecurityManager.py ===