[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - TestModuleHookup.py:1.1.2.2 testProtectClass.py:1.1.2.9 testPublicClass.py:1.1.2.9

Jim Fulton jim@zope.com
Tue, 5 Mar 2002 20:57:26 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	TestModuleHookup.py testProtectClass.py testPublicClass.py 
Log Message:
Fixed bug in protectClass.

Protecting by interface didn't cover base-interface methods.


=== Zope3/lib/python/Zope/App/Security/tests/TestModuleHookup.py 1.1.2.1 => 1.1.2.2 ===
 
 class I2(I):
-    def m3():
+    def m4():
         pass
     
 


=== Zope3/lib/python/Zope/App/Security/tests/testProtectClass.py 1.1.2.8 => 1.1.2.9 ===
             def m3(self):
                 return "m3"
+            def m4(self):
+                return "m4"
         TestModule.test_class = C
         TestModule.test_instance = C()
         self.assertState()
@@ -225,6 +227,16 @@
                        % (PREFIX+"test_class", 'bad'))
         self.assertRaises(UndefinedPermissionError, self.assertDeclaration,
                           declaration, instP='bad')
+
+
+    def testSubInterfaces(self):
+        declaration = ("""<security:protectClass 
+                              name="%s" permission_id="%s" interface="%s" />"""
+                       % (PREFIX+"test_class", P1, PREFIX+"I2"))
+        # 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 apply_declaration(declaration):


=== Zope3/lib/python/Zope/App/Security/tests/testPublicClass.py 1.1.2.8 => 1.1.2.9 ===
             def m3(self):
                 return "m3"
+            def m4(self):
+                return "m4"
         TestModule.test_class = C
         TestModule.test_instance = C()
         self.assertState()
@@ -106,6 +108,15 @@
         self.assertDeclaration(declaration,
                                instP=PublicPermission, m1P=PublicPermission,
                                m2P=PublicPermission)
+
+    def testSubInterfaces(self):
+        declaration = ("""<security:publicClass 
+                              name="%s" interface="%s" />"""
+                       % (PREFIX+"test_class", PREFIX+"I2"))
+        # m1 and m2 are in the interface, so should be set, and m3 should not:
+        self.assertDeclaration(declaration,
+                               instP=PublicPermission,
+                               m1P=PublicPermission, m2P=PublicPermission)
 
 def apply_declaration(declaration):
     """Apply the xmlconfig machinery."""