[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests - test_permissionfield.py:1.3 test_securitydirectives.py:1.3 test_zsp.py:1.3

Jim Fulton jim@zope.com
Thu, 26 Dec 2002 13:49:09 -0500


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

Modified Files:
	test_permissionfield.py test_securitydirectives.py test_zsp.py 
Log Message:
Added functions for checking validity of permission, role, and
principal ids.

Updated global grants to perform these chacks.

Renamed and consolidated a number of files in the ongoing quest to get
to single-line imports.



=== Zope3/src/zope/app/security/tests/test_permissionfield.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/tests/test_permissionfield.py:1.2	Wed Dec 25 09:13:18 2002
+++ Zope3/src/zope/app/security/tests/test_permissionfield.py	Thu Dec 26 13:49:09 2002
@@ -17,7 +17,7 @@
 """
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.security.permissionfield import PermissionField
+from zope.app.security.permission import PermissionField
 from zope.schema.interfaces import ValidationError
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.security.registries.permissionregistry import permissionRegistry


=== Zope3/src/zope/app/security/tests/test_securitydirectives.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/tests/test_securitydirectives.py:1.2	Wed Dec 25 09:13:18 2002
+++ Zope3/src/zope/app/security/tests/test_securitydirectives.py	Thu Dec 26 13:49:09 2002
@@ -19,6 +19,12 @@
 import unittest
 from StringIO import StringIO
 
+from zope.component.service import serviceManager as services
+
+from zope.app.interfaces.security import IPermissionService
+from zope.app.interfaces.security import IRoleService
+from zope.app.interfaces.security import IAuthenticationService
+
 from zope.configuration.xmlconfig import ZopeXMLConfigurationError
 from zope.configuration.xmlconfig import XMLConfig, xmlconfig
 
@@ -30,11 +36,11 @@
 from zope.app.security.registries.permissionregistry \
         import permissionRegistry as pregistry
 from zope.app.security.registries.roleregistry import roleRegistry as rregistry
-from zope.app.security.grants.rolepermissionmanager \
+from zope.app.security.grants.rolepermission \
         import rolePermissionManager as role_perm_mgr
-from zope.app.security.grants.principalpermissionmanager \
+from zope.app.security.grants.principalpermission \
     import principalPermissionManager as principal_perm_mgr
-from zope.app.security.grants.principalrolemanager \
+from zope.app.security.grants.principalrole \
     import principalRoleManager as principal_role_mgr
 
 
@@ -45,8 +51,24 @@
       </zopeConfigure>
       """ % s)
 
+def setUp(self):
+    CleanUp.setUp(self)
+    
+    services.defineService('Permissions', IPermissionService)
+    services.provideService('Permissions', pregistry)
+    
+    services.defineService('Roles', IRoleService)
+    services.provideService('Roles', rregistry)
+    
+    services.defineService('Authentication', IAuthenticationService)
+    services.provideService('Authentication', principalRegistry)
+    
+
 class TestPrincipalDirective(CleanUp, unittest.TestCase):
+
+
     def setUp(self):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testRegister(self):
@@ -76,6 +98,7 @@
 
 class TestPermissionDirective(CleanUp, unittest.TestCase):
     def setUp(self):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testRegister(self):
@@ -111,6 +134,7 @@
 
 class TestRoleDirective(CleanUp, unittest.TestCase):
     def setUp(self):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testRegister(self):
@@ -148,9 +172,12 @@
 class TestRolePermission(CleanUp, unittest.TestCase):
 
     def setUp( self ):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testMap( self ):
+        pregistry.definePermission("Foo", '', '')
+        rregistry.defineRole("Bar", '', '')
         f = configfile("""
  <grant
      permission="Foo"
@@ -171,9 +198,12 @@
 class TestPrincipalPermission(CleanUp, unittest.TestCase):
 
     def setUp( self ):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testMap( self ):
+        pregistry.definePermission("Foo", '', '')
+        principalRegistry.definePrincipal("Bar", '', '')
         f = configfile("""
  <grant
      permission="Foo"
@@ -194,9 +224,12 @@
 class TestPrincipalRole(CleanUp, unittest.TestCase):
 
     def setUp( self ):
+        setUp(self)
         XMLConfig('meta.zcml', zope.app.security)()
 
     def testMap( self ):
+        rregistry.defineRole("Foo", '', '')
+        principalRegistry.definePrincipal("Bar", '', '')
         f = configfile("""
  <grant
      role="Foo"


=== Zope3/src/zope/app/security/tests/test_zsp.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/security/tests/test_zsp.py:1.2	Wed Dec 25 09:13:18 2002
+++ Zope3/src/zope/app/security/tests/test_zsp.py	Thu Dec 26 13:49:09 2002
@@ -19,25 +19,28 @@
 
 import unittest
 
+from zope.component.service import serviceManager as services
+
+from zope.app.interfaces.security import IPermissionService
+from zope.app.interfaces.security import IRoleService
+from zope.app.interfaces.security import IAuthenticationService
+
 from zope.proxy.context import ContextWrapper
 from zope.component import getService
 from zope.app.interfaces.security import IRolePermissionManager
 from zope.app.security.registries.permissionregistry import permissionRegistry
 from zope.app.security.registries.principalregistry import principalRegistry
 from zope.app.security.registries.roleregistry import roleRegistry
-from zope.app.security.grants.principalpermissionmanager \
+from zope.app.security.grants.principalpermission \
      import principalPermissionManager
-from zope.app.security.grants.rolepermissionmanager \
-     import rolePermissionManager
-from zope.app.security.grants.principalrolemanager \
-     import principalRoleManager
-from zope.app.security.grants.annotationprincipalpermissionmanager \
+from zope.app.security.grants.rolepermission import rolePermissionManager
+from zope.app.security.grants.principalrole import principalRoleManager
+from zope.app.security.grants.principalpermission \
     import AnnotationPrincipalPermissionManager
-from zope.app.interfaces.security \
-    import IPrincipalPermissionManager
-from zope.app.security.grants.annotationprincipalrolemanager \
-    import AnnotationPrincipalRoleManager
-from zope.app.security.grants.annotationrolepermissionmanager \
+from zope.app.interfaces.security import IPrincipalPermissionManager
+from zope.app.security.grants.principalrole \
+     import AnnotationPrincipalRoleManager
+from zope.app.security.grants.rolepermission \
     import AnnotationRolePermissionManager
 from zope.app.interfaces.security import IPrincipalRoleManager
 from zope.app.interfaces.annotation import IAttributeAnnotatable
@@ -59,6 +62,19 @@
 
     def setUp(self):
         PlacefulSetup.setUp(self)
+
+    
+        services.defineService('Permissions', IPermissionService)
+        services.provideService('Permissions', permissionRegistry)
+        
+        services.defineService('Roles', IRoleService)
+        services.provideService('Roles', roleRegistry)
+        
+        services.defineService('Authentication', IAuthenticationService)
+        services.provideService('Authentication', principalRegistry)
+
+
+
         getService(None,"Adapters").provideAdapter(
                        IAttributeAnnotatable, IAnnotations,
                        AttributeAnnotations)
@@ -88,7 +104,7 @@
         self.create = create.getId()
         update = permissionRegistry.definePermission('update', 'Update',
                                                      'Update something')
-        self.update = update
+        self.update = update.getId()
 
         # ... and some roles...
         peon = roleRegistry.defineRole('Peon', 'Site Peon')