[Zope3-checkins] CVS: Zope3/src/zope/app/securitypolicy/tests - test_annotationprincipalpermissionmanager.py:1.2 test_annotationprincipalrolemanager.py:1.2 test_annotationrolepermissionmanager.py:1.2 test_principalpermissionmanager.py:1.2 test_principalrolemanager.py:1.2 test_rolepermissionmanager.py:1.2 test_securitydirectives.py:1.2 test_zopepolicy.py:1.2 test_rolecontents.py:NONE test_roleregistry.py:NONE test_roleservice.py:NONE

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Mar 5 13:39:10 EST 2004


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

Modified Files:
	test_annotationprincipalpermissionmanager.py 
	test_annotationprincipalrolemanager.py 
	test_annotationrolepermissionmanager.py 
	test_principalpermissionmanager.py 
	test_principalrolemanager.py test_rolepermissionmanager.py 
	test_securitydirectives.py test_zopepolicy.py 
Removed Files:
	test_rolecontents.py test_roleregistry.py test_roleservice.py 
Log Message:


Make all the security code use role utilities and the new fields instead of
the methods.


=== Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py	Fri Mar  5 13:39:09 2004
@@ -11,22 +11,22 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Test handler for AnnotationPrincipalPermissionManager module."""
+"""Test handler for AnnotationPrincipalPermissionManager module.
 
+$Id$
+"""
 import unittest
 
 from zope.interface import implements
-from zope.component import getService
 
 from zope.app.tests import ztapi
+from zope.app.attributeannotations import AttributeAnnotations
 from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.services.servicenames import Adapters
 from zope.app.interfaces.annotation import IAnnotations
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.security.registries.permissionregistry \
-    import permissionRegistry as permregistry
-from zope.app.security.registries.principalregistry \
-    import principalRegistry as prinregistry
+from zope.app.security.registries.permissionregistry import \
+     permissionRegistry as permregistry
+from zope.app.security.registries.principalregistry import \
+     principalRegistry as prinregistry
 from zope.app.security.settings import Allow, Deny, Unset
 from zope.app.tests.placelesssetup import PlacelessSetup
 


=== Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py	Fri Mar  5 13:39:09 2004
@@ -11,29 +11,37 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Test handler for PrincipalRoleManager module."""
+"""Test handler for PrincipalRoleManager module.
 
+$Id$
+"""
 import unittest
 from zope.interface import implements
 from zope.component import getService
 
 from zope.app.tests import ztapi
+from zope.app.attributeannotations import AttributeAnnotations
 from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.services.servicenames import Adapters
 from zope.app.interfaces.annotation import IAnnotations
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.security.registries.principalregistry \
-     import principalRegistry as pregistry
+from zope.app.services.servicenames import Adapters
+from zope.app.security.registries.principalregistry import \
+     principalRegistry as pregistry
 from zope.app.security.settings import Allow, Deny
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 
-from zope.app.securitypolicy.roleregistry import roleRegistry as rregistry
-from zope.app.securitypolicy.principalrole \
-        import AnnotationPrincipalRoleManager
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
+from zope.app.securitypolicy.principalrole import \
+     AnnotationPrincipalRoleManager
 
 class Manageable:
     implements(IAttributeAnnotatable)
 
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
+
 class Test(PlacefulSetup, unittest.TestCase):
 
     def setUp(self):
@@ -56,15 +64,16 @@
 
     def testUnboundPrincipalRole(self):
         principalRoleManager = self._make_roleManager()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
-        self.assertEqual(principalRoleManager.getPrincipalsForRole(role), [])
-        self.assertEqual(principalRoleManager.getRolesForPrincipal(principal),
-                         [])
+        self.assertEqual(
+            principalRoleManager.getPrincipalsForRole(role), [])
+        self.assertEqual(
+            principalRoleManager.getRolesForPrincipal(principal), [])
 
     def testPrincipalRoleAllow(self):
         principalRoleManager = self._make_roleManager()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.assignRoleToPrincipal(role, principal)
         self.assertEqual(principalRoleManager.getPrincipalsForRole(role),
@@ -74,7 +83,7 @@
 
     def testPrincipalRoleDeny(self):
         principalRoleManager = self._make_roleManager()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.removeRoleFromPrincipal(role, principal)
         self.assertEqual(principalRoleManager.getPrincipalsForRole(role),
@@ -84,7 +93,7 @@
 
     def testPrincipalRoleUnset(self):
         principalRoleManager = self._make_roleManager()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.removeRoleFromPrincipal(role, principal)
         principalRoleManager.unsetRoleForPrincipal(role, principal)
@@ -95,8 +104,8 @@
 
     def testManyRolesOnePrincipal(self):
         principalRoleManager = self._make_roleManager()
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
-        role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+        role1 = defineRole('Role One', 'Role #1').id
+        role2 = defineRole('Role Two', 'Role #2').id
         prin1 = self._make_principal()
         principalRoleManager.assignRoleToPrincipal(role1, prin1)
         principalRoleManager.assignRoleToPrincipal(role2, prin1)
@@ -107,7 +116,7 @@
 
     def testManyPrincipalsOneRole(self):
         principalRoleManager = self._make_roleManager()
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+        role1 = defineRole('Role One', 'Role #1').id
         prin1 = self._make_principal()
         prin2 = self._make_principal('Principal 2', 'Principal Two')
         principalRoleManager.assignRoleToPrincipal(role1, prin1)
@@ -121,8 +130,8 @@
         principalRoleManager = self._make_roleManager()
         principalsAndRoles = principalRoleManager.getPrincipalsAndRoles()
         self.assertEqual(len(principalsAndRoles), 0)
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
-        role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+        role1 = defineRole('Role One', 'Role #1').id
+        role2 = defineRole('Role Two', 'Role #2').id
         prin1 = self._make_principal()
         prin2 = self._make_principal('Principal 2', 'Principal Two')
         principalRoleManager.assignRoleToPrincipal(role1, prin1)


=== Zope3/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py	Fri Mar  5 13:39:09 2004
@@ -11,42 +11,44 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Test handler for Annotation Role Permission Manager.
+
 $Id$
 """
-
+import unittest
 from zope.interface import implements
-from zope.component import getServiceManager, getService
 
+from zope.app import zapi
 from zope.app.tests import ztapi
+from zope.app.attributeannotations import AttributeAnnotations
 from zope.app.interfaces.annotation import IAttributeAnnotatable
 from zope.app.interfaces.annotation import IAnnotations
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.services.servicenames import Permissions, Adapters
 from zope.app.interfaces.security import IPermissionService
 from zope.app.security.registries.permissionregistry import permissionRegistry
 from zope.app.security.settings import Allow, Deny
+from zope.app.services.servicenames import Permissions, Adapters
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 
-from zope.app.securitypolicy.interfaces import IRoleService
-from zope.app.securitypolicy.roleregistry import roleRegistry
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
      import AnnotationRolePermissionManager
 
-import unittest
-
 class Manageable:
     implements(IAttributeAnnotatable)
 
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
+
 class Test(PlacefulSetup, unittest.TestCase):
 
     def setUp(self):
         PlacefulSetup.setUp(self)
-        defineService=getServiceManager(None).defineService
-        provideService=getServiceManager(None).provideService
-        defineService('Roles', IRoleService)
+        defineService = zapi.getServiceManager(None).defineService
+        provideService = zapi.getServiceManager(None).provideService
         defineService(Permissions, IPermissionService)
-        provideService('Roles', roleRegistry)
         provideService(Permissions, permissionRegistry)
         ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                              AttributeAnnotations)
@@ -57,11 +59,11 @@
         write = permissionRegistry.definePermission('write', 'Write Something')
         self.write = write.getId()
 
-        peon = roleRegistry.defineRole('peon', 'Poor Slob')
-        self.peon = peon.getId()
+        peon = defineRole('peon', 'Poor Slob')
+        self.peon = peon.id
 
-        manager = roleRegistry.defineRole('manager', 'Supreme Being')
-        self.manager = manager.getId()
+        manager = defineRole('manager', 'Supreme Being')
+        self.manager = manager.id
 
     def testNormal(self):
         obj = Manageable()


=== Zope3/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py	Fri Mar  5 13:39:09 2004
@@ -15,7 +15,6 @@
 
 $Id$
 """
-
 import unittest
 
 from zope.component.service import serviceManager as services


=== Zope3/src/zope/app/securitypolicy/tests/test_principalrolemanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_principalrolemanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_principalrolemanager.py	Fri Mar  5 13:39:09 2004
@@ -17,28 +17,30 @@
 """
 import unittest
 
-from zope.component.service import serviceManager as services
-from zope.testing.cleanup import CleanUp
-
+from zope.app import zapi
+from zope.app.tests import ztapi
+from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.interfaces.security import IAuthenticationService
 from zope.app.services.servicenames import Authentication
 
 from zope.app.security.settings import Allow, Deny
 from zope.app.security.registries.principalregistry \
      import principalRegistry as pregistry
-from zope.app.securitypolicy.roleregistry \
-     import roleRegistry as rregistry
 
-from zope.app.securitypolicy.interfaces import IRoleService
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.principalrole import principalRoleManager
 
-class Test(CleanUp, unittest.TestCase):
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
 
-    def setUp(self):
-        CleanUp.setUp(self)
+class Test(PlacelessSetup, unittest.TestCase):
 
-        services.defineService('Roles', IRoleService)
-        services.provideService('Roles', rregistry)
+    def setUp(self):
+        super(Test, self).setUp()
+        services = zapi.getServiceManager(None)
 
         services.defineService(Authentication, IAuthenticationService)
         services.provideService(Authentication, pregistry)
@@ -51,14 +53,14 @@
         return p.getId()
 
     def testUnboundPrincipalRole(self):
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         self.assertEqual(principalRoleManager.getPrincipalsForRole(role), [])
         self.assertEqual(principalRoleManager.getRolesForPrincipal(principal),
                          [])
 
     def testPrincipalRoleAllow(self):
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.assignRoleToPrincipal(role, principal)
         self.assertEqual(principalRoleManager.getPrincipalsForRole(role),
@@ -67,7 +69,7 @@
                          [(role, Allow)])
 
     def testPrincipalRoleDeny(self):
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.removeRoleFromPrincipal(role, principal)
         self.assertEqual(principalRoleManager.getPrincipalsForRole(role),
@@ -76,7 +78,7 @@
                          [(role, Deny)])
 
     def testPrincipalRoleUnset(self):
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         principal = self._make_principal()
         principalRoleManager.removeRoleFromPrincipal(role, principal)
         principalRoleManager.unsetRoleForPrincipal(role, principal)
@@ -90,7 +92,7 @@
         self.assertRaises(ValueError,
                           principalRoleManager.assignRoleToPrincipal,
                           'role1', 'prin1')
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+        role1 = defineRole('Role One', 'Role #1').id
         self.assertRaises(ValueError,
                           principalRoleManager.assignRoleToPrincipal,
                           role1, 'prin1')
@@ -103,8 +105,8 @@
         
 
     def testManyRolesOnePrincipal(self):
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
-        role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+        role1 = defineRole('Role One', 'Role #1').id
+        role2 = defineRole('Role Two', 'Role #2').id
         prin1 = self._make_principal()
         principalRoleManager.assignRoleToPrincipal(role1, prin1)
         principalRoleManager.assignRoleToPrincipal(role2, prin1)
@@ -114,7 +116,7 @@
         self.failUnless((role2, Allow) in roles)
 
     def testManyPrincipalsOneRole(self):
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+        role1 = defineRole('Role One', 'Role #1').id
         prin1 = self._make_principal()
         prin2 = self._make_principal('Principal 2', 'Principal Two')
         principalRoleManager.assignRoleToPrincipal(role1, prin1)
@@ -125,8 +127,8 @@
         self.failUnless((prin2, Allow) in principals)
 
     def testPrincipalsAndRoles(self):
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
-        role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+        role1 = defineRole('Role One', 'Role #1').id
+        role2 = defineRole('Role Two', 'Role #2').id
         prin1 = self._make_principal()
         prin2 = self._make_principal('Principal 2', 'Principal Two')
         principalRoleManager.assignRoleToPrincipal(role1, prin1)
@@ -137,6 +139,7 @@
         self.failUnless((role1, prin1, Allow) in principalsAndRoles)
         self.failUnless((role1, prin2, Allow) in principalsAndRoles)
         self.failUnless((role2, prin1, Allow) in principalsAndRoles)
+
 
 def test_suite():
     loader=unittest.TestLoader()


=== Zope3/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py	Fri Mar  5 13:39:09 2004
@@ -15,45 +15,47 @@
 
 $Id$
 """
-
 import unittest
 
-from zope.component.service import serviceManager as services
-from zope.testing.cleanup import CleanUp
+from zope.app.tests.placelesssetup import PlacelessSetup
 
+from zope.app import zapi
+from zope.app.tests import ztapi
 from zope.app.services.servicenames import Permissions
 from zope.app.interfaces.security import IPermissionService
-from zope.app.securitypolicy.interfaces import IRoleService
 
 from zope.app.security.registries.permissionregistry \
         import permissionRegistry as pregistry
 from zope.app.security.settings import Allow, Deny
 
-from zope.app.securitypolicy.roleregistry \
-        import roleRegistry as rregistry
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
         import rolePermissionManager as manager
 
-class Test(CleanUp, unittest.TestCase):
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
+
+class Test(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
-        CleanUp.setUp(self)
+        super(Test, self).setUp()
+        services = zapi.getServiceManager(None)
 
         services.defineService(Permissions, IPermissionService)
         services.provideService(Permissions, pregistry)
 
-        services.defineService("Roles", IRoleService)
-        services.provideService("Roles", rregistry)
-
     def testUnboundRolePermission(self):
         permission = pregistry.definePermission('APerm', 'aPerm title').getId()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         self.assertEqual(manager.getRolesForPermission(permission), [])
         self.assertEqual(manager.getPermissionsForRole(role), [])
 
     def testRolePermission(self):
         permission = pregistry.definePermission('APerm', 'aPerm title').getId()
-        role = rregistry.defineRole('ARole', 'A Role').getId()
+        role = defineRole('ARole', 'A Role').id
         manager.grantPermissionToRole(permission, role)
         self.assertEqual(manager.getRolesForPermission(permission),
                                                         [(role,Allow)])
@@ -64,7 +66,7 @@
         perm1 = pregistry.definePermission('Perm One', 'P1').getId()
         perm2 = pregistry.definePermission('Perm Two', 'P2').getId()
         perm3 = pregistry.definePermission('Perm Three', 'P3').getId()
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+        role1 = defineRole('Role One', 'Role #1').id
         perms = manager.getPermissionsForRole(role1)
         self.assertEqual(len(perms), 0)
         manager.grantPermissionToRole(perm1, role1)
@@ -83,8 +85,8 @@
 
     def testManyRolesOnePermission(self):
         perm1 = pregistry.definePermission('Perm One', 'title').getId()
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
-        role2 = rregistry.defineRole('Role Two', 'Role #2').getId()
+        role1 = defineRole('Role One', 'Role #1').id
+        role2 = defineRole('Role Two', 'Role #2').id
         roles = manager.getRolesForPermission(perm1)
         self.assertEqual(len(roles), 0)
         manager.grantPermissionToRole(perm1, role1)
@@ -111,7 +113,7 @@
                           )
 
     def test_invalidPerm(self):
-        role1 = rregistry.defineRole('Role One', 'Role #1').getId()
+        role1 = defineRole('Role One', 'Role #1').id
         self.assertRaises(ValueError,
                           manager.grantPermissionToRole, 'perm1', role1
                           )


=== Zope3/src/zope/app/securitypolicy/tests/test_securitydirectives.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_securitydirectives.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_securitydirectives.py	Fri Mar  5 13:39:09 2004
@@ -17,14 +17,15 @@
 """
 import unittest
 
-from zope.component.service import serviceManager as services
+from zope.app import zapi
+from zope.app.tests import ztapi
 from zope.app.services.servicenames import Permissions, Authentication
 from zope.app.interfaces.security import IPermissionService
 from zope.app.interfaces.security import IAuthenticationService
 
 from zope.configuration.config import ConfigurationConflictError
 from zope.configuration import xmlconfig
-from zope.testing.cleanup import CleanUp
+from zope.app.tests.placelesssetup import PlacelessSetup
 
 import zope.app.securitypolicy.tests
 import zope.app.securitypolicy.tests
@@ -33,8 +34,8 @@
 from zope.app.security.registries.permissionregistry \
         import permissionRegistry as pregistry
 
-from zope.app.securitypolicy.interfaces import IRoleService
-from zope.app.securitypolicy.roleregistry import roleRegistry as rregistry
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.rolepermission \
         import rolePermissionManager as role_perm_mgr
 from zope.app.securitypolicy.principalpermission \
@@ -43,17 +44,21 @@
     import principalRoleManager as principal_role_mgr
 
 
-class TestBase(CleanUp):
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
+
+
+class TestBase(PlacelessSetup):
 
     def setUp(self):
-        CleanUp.setUp(self)
+        super(TestBase, self).setUp()
+        services = zapi.getServiceManager(None)
     
         services.defineService(Permissions, IPermissionService)
         services.provideService(Permissions, pregistry)
     
-        services.defineService("Roles", IRoleService)
-        services.provideService("Roles", rregistry)
-    
         services.defineService(Authentication, IAuthenticationService)
         services.provideService(Authentication, principalRegistry)
 
@@ -64,10 +69,10 @@
         context = xmlconfig.file("role.zcml",
                                  zope.app.securitypolicy.tests)
 
-        role = rregistry.getRole("zope.Everyperson")
-        self.failUnless(role.getId().endswith('Everyperson'))
-        self.assertEqual(role.getTitle(), 'Tout le monde')
-        self.assertEqual(role.getDescription(),
+        role = zapi.getUtility(None, IRole, name="zope.Everyperson")
+        self.failUnless(role.id.endswith('Everyperson'))
+        self.assertEqual(role.title, 'Tout le monde')
+        self.assertEqual(role.description,
                          'The common man, woman, person, or thing')
 
     def testDuplicationRegistration(self):
@@ -79,9 +84,9 @@
 class TestSecurityMapping(TestBase, unittest.TestCase):
 
     def setUp(self):
-        TestBase.setUp(self)
+        super(TestSecurityMapping, self).setUp()
         pregistry.definePermission("zope.Foo", '', '')
-        rregistry.defineRole("zope.Bar", '', '')
+        defineRole("zope.Bar", '', '')
         principalRegistry.definePrincipal("zope.Blah", '', '')
         self.context = xmlconfig.file("mapping.zcml",
                                       zope.app.securitypolicy.tests)


=== Zope3/src/zope/app/securitypolicy/tests/test_zopepolicy.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/tests/test_zopepolicy.py:1.1	Fri Feb 27 07:46:33 2004
+++ Zope3/src/zope/app/securitypolicy/tests/test_zopepolicy.py	Fri Mar  5 13:39:09 2004
@@ -15,33 +15,31 @@
 
 $Id$
 """
-
 import unittest
 
 from zope.interface import implements
-from zope.component.service import serviceManager as services
-from zope.component import getService
 
 from zope.app.interfaces.security import IPermissionService
 from zope.app.interfaces.security import IAuthenticationService
 
-from zope.app.tests import ztapi
-from zope.app.services.servicenames import Permissions, Adapters
-from zope.app.services.servicenames import Authentication
+from zope.app import zapi
+from zope.app.attributeannotations import AttributeAnnotations
+from zope.app.interfaces.annotation import IAttributeAnnotatable
+from zope.app.interfaces.annotation import IAnnotations
 from zope.app.security.registries.permissionregistry import permissionRegistry
 from zope.app.security.registries.principalregistry import principalRegistry
 from zope.app.security.registries.principalregistry import PrincipalBase
-from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.interfaces.annotation import IAnnotations
-from zope.app.attributeannotations import AttributeAnnotations
+from zope.app.services.servicenames import Permissions, Adapters
+from zope.app.services.servicenames import Authentication
 from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.tests import ztapi
 
-from zope.app.securitypolicy.interfaces import IRoleService
+from zope.app.securitypolicy.interfaces import IRole
 from zope.app.securitypolicy.interfaces import IRolePermissionManager
 from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
 
+from zope.app.securitypolicy.role import Role
 from zope.app.securitypolicy.zopepolicy import permissionsOfPrincipal
-from zope.app.securitypolicy.roleregistry import roleRegistry
 from zope.app.securitypolicy.principalpermission \
      import principalPermissionManager
 from zope.app.securitypolicy.rolepermission import rolePermissionManager
@@ -65,23 +63,24 @@
     pass
 
 
+def defineRole(id, title=None, description=None):
+    role = Role(id, title, description)
+    ztapi.provideUtility(IRole, role, name=role.id)
+    return role
+
+
 class Test(PlacefulSetup, unittest.TestCase):
 
     def setUp(self):
         PlacefulSetup.setUp(self)
-
+        services = zapi.getServiceManager(None)
 
         services.defineService(Permissions, IPermissionService)
         services.provideService(Permissions, permissionRegistry)
 
-        services.defineService("Roles", IRoleService)
-        services.provideService("Roles", roleRegistry)
-
         services.defineService(Authentication, IAuthenticationService)
         services.provideService(Authentication, principalRegistry)
 
-
-
         ztapi.provideAdapter(
             IAttributeAnnotatable, IAnnotations,
             AttributeAnnotations)
@@ -111,14 +110,16 @@
         self.update = update.getId()
 
         # ... and some roles...
-        peon = roleRegistry.defineRole('Peon', 'Site Peon')
-        self.peon = peon.getId()
+        defineRole("zope.Anonymous", "Everybody",
+                   "All users have this role implicitly")
+        peon = defineRole('Peon', 'Site Peon')
+        self.peon = peon.id
 
-        manager = roleRegistry.defineRole('Manager', 'Site Manager')
-        self.manager = manager.getId()
+        manager = defineRole('Manager', 'Site Manager')
+        self.manager = manager.id
 
-        arole = roleRegistry.defineRole('Another', 'Another Role')
-        self.arole = arole.getId()
+        arole = defineRole('Another', 'Another Role')
+        self.arole = arole.id
 
         # grant and deny some permissions to a principal
         principalPermissionManager.grantPermissionToPrincipal(self.create,
@@ -140,7 +141,6 @@
         self.policy = self._makePolicy()
 
     def _makePolicy(self):
-
         from zope.app.securitypolicy.zopepolicy import ZopeSecurityPolicy
         return ZopeSecurityPolicy()
 

=== Removed File Zope3/src/zope/app/securitypolicy/tests/test_rolecontents.py ===

=== Removed File Zope3/src/zope/app/securitypolicy/tests/test_roleregistry.py ===

=== Removed File Zope3/src/zope/app/securitypolicy/tests/test_roleservice.py ===




More information about the Zope3-Checkins mailing list