[Zope3-checkins] CVS: Zope3/src/zope/app/security/tests -
test_securitydirectives.py:1.13 mapping.zcml:NONE
role.zcml:NONE role_duplicate.zcml:NONE test_zopepolicy.py:NONE
Chris McDonough
chrism at plope.com
Wed Jan 14 17:55:58 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/security/tests
In directory cvs.zope.org:/tmp/cvs-serv5558/src/zope/app/security/tests
Modified Files:
test_securitydirectives.py
Removed Files:
mapping.zcml role.zcml role_duplicate.zcml test_zopepolicy.py
Log Message:
Merge security policy refactoring:
- Moved all role- and grant-related functionality into
zope.products.securitypolicy (and out of zope.app.security.grant).
The zope.products.securitypolicy implementation is exactly
the same as the old implementation; no changes were made
to the actual mechanics of role-permission or principal-permission
grants. The only real difference is that all functionality
that is the purview of what we want a security policy to have
control of is now in that one place.
- Created new modulealias directive which can be used to provide
aliases to older modules (to not break existing ZODBs when
module locations change).
- Added minor feature: "make debug" launches a debug session in the
spirit of Zope 2's "zopectl debug".
=== Zope3/src/zope/app/security/tests/test_securitydirectives.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/security/tests/test_securitydirectives.py:1.12 Sun Dec 14 03:25:35 2003
+++ Zope3/src/zope/app/security/tests/test_securitydirectives.py Wed Jan 14 17:55:27 2004
@@ -18,9 +18,8 @@
import unittest
from zope.component.service import serviceManager as services
-from zope.app.services.servicenames import Roles, Permissions, Authentication
+from zope.app.services.servicenames import Permissions, Authentication
from zope.app.interfaces.security import IPermissionService
-from zope.app.interfaces.security import IRoleService
from zope.app.interfaces.security import IAuthenticationService
from zope.configuration.config import ConfigurationConflictError
@@ -32,26 +31,16 @@
from zope.app.security.settings import Allow
from zope.app.security.registries.principalregistry import principalRegistry
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.rolepermission \
- import rolePermissionManager as role_perm_mgr
-from zope.app.security.grants.principalpermission \
- import principalPermissionManager as principal_perm_mgr
-from zope.app.security.grants.principalrole \
- import principalRoleManager as principal_role_mgr
+ import permissionRegistry as pregistry
class TestBase(CleanUp):
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)
@@ -89,68 +78,10 @@
"perm_duplicate.zcml", zope.app.security.tests)
-class TestRoleDirective(TestBase, unittest.TestCase):
-
- def testRegister(self):
- context = xmlconfig.file("role.zcml", zope.app.security.tests)
-
- role = rregistry.getRole("zope.Everyperson")
- self.failUnless(role.getId().endswith('Everyperson'))
- self.assertEqual(role.getTitle(), 'Tout le monde')
- self.assertEqual(role.getDescription(),
- 'The common man, woman, person, or thing')
-
- def testDuplicationRegistration(self):
- self.assertRaises(ConfigurationConflictError, xmlconfig.file,
- "role_duplicate.zcml", zope.app.security.tests)
-
-
-class TestSecurityMapping(TestBase, unittest.TestCase):
-
- def setUp(self):
- TestBase.setUp(self)
- pregistry.definePermission("zope.Foo", '', '')
- rregistry.defineRole("zope.Bar", '', '')
- principalRegistry.definePrincipal("zope.Blah", '', '')
- self.context = xmlconfig.file("mapping.zcml", zope.app.security.tests)
-
- def test_PermRoleMap(self):
- roles = role_perm_mgr.getRolesForPermission("zope.Foo")
- perms = role_perm_mgr.getPermissionsForRole("zope.Bar")
-
- self.assertEqual(len(roles), 1)
- self.failUnless(("zope.Bar",Allow) in roles)
-
- self.assertEqual(len(perms), 1)
- self.failUnless(("zope.Foo",Allow) in perms)
-
- def test_PermPrincipalMap(self):
- principals = principal_perm_mgr.getPrincipalsForPermission("zope.Foo")
- perms = principal_perm_mgr.getPermissionsForPrincipal("zope.Blah")
-
- self.assertEqual(len(principals), 1)
- self.failUnless(("zope.Blah", Allow) in principals)
-
- self.assertEqual(len(perms), 1)
- self.failUnless(("zope.Foo", Allow) in perms)
-
- def test_RolePrincipalMap(self):
- principals = principal_role_mgr.getPrincipalsForRole("zope.Bar")
- roles = principal_role_mgr.getRolesForPrincipal("zope.Blah")
-
- self.assertEqual(len(principals), 1)
- self.failUnless(("zope.Blah", Allow) in principals)
-
- self.assertEqual(len(roles), 1)
- self.failUnless(("zope.Bar", Allow) in roles)
-
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestPrincipalDirective),
unittest.makeSuite(TestPermissionDirective),
- unittest.makeSuite(TestRoleDirective),
- unittest.makeSuite(TestSecurityMapping),
))
if __name__ == '__main__':
=== Removed File Zope3/src/zope/app/security/tests/mapping.zcml ===
=== Removed File Zope3/src/zope/app/security/tests/role.zcml ===
=== Removed File Zope3/src/zope/app/security/tests/role_duplicate.zcml ===
=== Removed File Zope3/src/zope/app/security/tests/test_zopepolicy.py ===
More information about the Zope3-Checkins
mailing list