[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPermissionRegistry.py:1.1.2.8 testPrincipalPermissionManager.py:1.1.2.3 testPrincipalRoleManager.py:1.1.2.3 testRolePermissionManager.py:1.1.2.4 testRoleRegistry.py:1.1.2.4 testSecurityDirectives.py:1.1.2.5
Jim Fulton
jim@zope.com
Wed, 26 Dec 2001 15:36:16 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv554/tests
Modified Files:
Tag: Zope-3x-branch
testPermissionRegistry.py testPrincipalPermissionManager.py
testPrincipalRoleManager.py testRolePermissionManager.py
testRoleRegistry.py testSecurityDirectives.py
Log Message:
updated to use non-generic registry names
=== Zope3/lib/python/Zope/App/Security/tests/testPermissionRegistry.py 1.1.2.7 => 1.1.2.8 ===
import unittest, sys
-from Zope.App.Security.PermissionRegistry import registry
+from Zope.App.Security.PermissionRegistry import permissionRegistry
from Zope.App.Security.IPermission import IPermission
from Interface.verify import verify
class Test(unittest.TestCase):
def tearDown(self):
- registry._clear()
+ permissionRegistry._clear()
def testEmptyPermissions(self):
- self.assertRaises(LookupError, registry.getPermission, 'Foo')
- self.failIf(registry.definedPermission('Foo'))
+ self.assertRaises(LookupError, permissionRegistry.getPermission, 'Foo')
+ self.failIf(permissionRegistry.definedPermission('Foo'))
def testPermissionIsAnIPermission(self):
- registry.definePermission('Foo', 'foo title')
- permission = registry.getPermission('Foo')
+ permissionRegistry.definePermission('Foo', 'foo title')
+ permission = permissionRegistry.getPermission('Foo')
self.assertEqual(verify(IPermission, permission), 1)
def testDefinePermission(self):
- perm = registry.definePermission('Foo', 'foo title')
+ perm = permissionRegistry.definePermission('Foo', 'foo title')
self.failUnless(verify(IPermission, perm))
- self.failUnless(registry.definedPermission('Foo'))
- permission = registry.getPermission('Foo')
+ self.failUnless(permissionRegistry.definedPermission('Foo'))
+ permission = permissionRegistry.getPermission('Foo')
self.assertEquals(permission.getTitle(), 'foo title')
def testDefinePermissionWithTitle(self):
eq = self.assertEqual
- registry.definePermission('Foo', 'Foo-able')
- permission = registry.getPermission('Foo')
+ permissionRegistry.definePermission('Foo', 'Foo-able')
+ permission = permissionRegistry.getPermission('Foo')
eq(permission.getTitle(), 'Foo-able')
eq(permission.getDescription(), '')
def testDefinePermissionWithTitleAndDescription(self):
eq = self.assertEqual
- registry.definePermission('Foo', 'Foo-able', 'A foo-worthy permission')
- permission = registry.getPermission('Foo')
+ permissionRegistry.definePermission('Foo', 'Foo-able', 'A foo-worthy permission')
+ permission = permissionRegistry.getPermission('Foo')
eq(permission.getTitle(), 'Foo-able')
eq(permission.getDescription(), 'A foo-worthy permission')
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalPermissionManager.py 1.1.2.2 => 1.1.2.3 ===
import unittest
-from Zope.App.Security.PermissionRegistry import registry as pregistry
-from Zope.App.Security.PrincipalRegistry import globalRegistry as xregistry
-from Zope.App.Security.PrincipalPermissionManager import manager
+from Zope.App.Security.PermissionRegistry import permissionRegistry as pregistry
+from Zope.App.Security.PrincipalRegistry import principalRegistry as xregistry
+from Zope.App.Security.PrincipalPermissionManager \
+ import principalPermissionManager as manager
class Test(unittest.TestCase):
def tearDown(self):
pregistry._clear()
- xregistry.clear()
+ xregistry._clear()
manager._clear()
def _make_principal(self, id=None, title=None):
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRoleManager.py 1.1.2.2 => 1.1.2.3 ===
import unittest
-from Zope.App.Security.RoleRegistry import registry as rregistry
-from Zope.App.Security.PrincipalRegistry import globalRegistry as pregistry
-from Zope.App.Security.PrincipalRoleManager import manager
+from Zope.App.Security.RoleRegistry import roleRegistry as rregistry
+from Zope.App.Security.PrincipalRegistry import principalRegistry as pregistry
+from Zope.App.Security.PrincipalRoleManager import principalRoleManager
class Test(unittest.TestCase):
def tearDown(self):
rregistry._clear()
- pregistry.clear()
- manager._clear()
+ pregistry._clear()
+ principalRoleManager._clear()
+
+ setUp=tearDown
def _make_principal(self, id=None, title=None):
return pregistry.definePrincipal(
@@ -32,25 +34,25 @@
def testUnboundPrincipalRole(self):
role = rregistry.defineRole('ARole', 'A Role')
principal = self._make_principal()
- self.assertEqual(manager.getPrincipalsForRole(role), [])
- self.assertEqual(manager.getRolesForPrincipal(principal), [])
+ self.assertEqual(principalRoleManager.getPrincipalsForRole(role), [])
+ self.assertEqual(principalRoleManager.getRolesForPrincipal(principal), [])
def testPrincipalRole(self):
role = rregistry.defineRole('ARole', 'A Role')
principal = self._make_principal()
- manager.assignRoleToPrincipal(role, principal)
- self.assertEqual(manager.getPrincipalsForRole(role),
+ principalRoleManager.assignRoleToPrincipal(role, principal)
+ self.assertEqual(principalRoleManager.getPrincipalsForRole(role),
[principal])
- self.assertEqual(manager.getRolesForPrincipal(principal),
+ self.assertEqual(principalRoleManager.getRolesForPrincipal(principal),
[role])
def testManyRolesOnePrincipal(self):
perm1 = rregistry.defineRole('Role One', 'Role #1')
perm2 = rregistry.defineRole('Role Two', 'Role #2')
prin1 = self._make_principal()
- manager.assignRoleToPrincipal(perm1, prin1)
- manager.assignRoleToPrincipal(perm2, prin1)
- perms = manager.getRolesForPrincipal(prin1)
+ principalRoleManager.assignRoleToPrincipal(perm1, prin1)
+ principalRoleManager.assignRoleToPrincipal(perm2, prin1)
+ perms = principalRoleManager.getRolesForPrincipal(prin1)
self.assertEqual(len(perms), 2)
self.failUnless(perm1 in perms)
self.failUnless(perm2 in perms)
@@ -59,9 +61,9 @@
perm1 = rregistry.defineRole('Role One', 'Role #1')
prin1 = self._make_principal()
prin2 = self._make_principal('Principal 2', 'Principal Two')
- manager.assignRoleToPrincipal(perm1, prin1)
- manager.assignRoleToPrincipal(perm1, prin2)
- principals = manager.getPrincipalsForRole(perm1)
+ principalRoleManager.assignRoleToPrincipal(perm1, prin1)
+ principalRoleManager.assignRoleToPrincipal(perm1, prin2)
+ principals = principalRoleManager.getPrincipalsForRole(perm1)
self.assertEqual(len(principals), 2)
self.failUnless(prin1 in principals)
self.failUnless(prin2 in principals)
=== Zope3/lib/python/Zope/App/Security/tests/testRolePermissionManager.py 1.1.2.3 => 1.1.2.4 ===
import unittest
-from Zope.App.Security.PermissionRegistry import registry as pregistry
-from Zope.App.Security.RoleRegistry import registry as rregistry
-from Zope.App.Security.RolePermissionManager import manager
+from Zope.App.Security.PermissionRegistry import permissionRegistry as pregistry
+from Zope.App.Security.RoleRegistry import roleRegistry as rregistry
+from Zope.App.Security.RolePermissionManager import rolePermissionManager as manager
class Test(unittest.TestCase):
=== Zope3/lib/python/Zope/App/Security/tests/testRoleRegistry.py 1.1.2.3 => 1.1.2.4 ===
import unittest, sys
-from Zope.App.Security.RoleRegistry import registry
+from Zope.App.Security.RoleRegistry import roleRegistry
from Zope.App.Security.IRole import IRole
from Interface.verify import verify
class Test(unittest.TestCase):
def tearDown(self):
- registry._clear()
+ roleRegistry._clear()
def testEmptyRoles(self):
- self.assertRaises(LookupError, registry.getRole, 'Foo')
- self.failIf(registry.definedRole('Foo'))
+ self.assertRaises(LookupError, roleRegistry.getRole, 'Foo')
+ self.failIf(roleRegistry.definedRole('Foo'))
def testRoleIsAnIRole(self):
- registry.defineRole('Foo', 'Foo role')
- role = registry.getRole('Foo')
+ r = roleRegistry.defineRole('Foo', 'Foo role')
+ role = roleRegistry.getRole(r.getId())
self.assertEqual(verify(IRole, role), 1)
def testDefineRole(self):
- role = registry.defineRole('Foo', 'Foo role')
+ role = roleRegistry.defineRole('Foo', 'foo role')
self.failUnless(verify(IRole, role))
- self.failUnless(registry.definedRole('Foo'))
- role = registry.getRole('Foo')
- self.assertEquals(role.getTitle(), 'Foo role')
+ self.failUnless(roleRegistry.definedRole(role.getId()))
+ role = roleRegistry.getRole(role.getId())
+ self.assertEquals(role.getTitle(), 'foo role')
def testDefineRoleWithTitle(self):
eq = self.assertEqual
- registry.defineRole('Foo', 'Foo-able')
- role = registry.getRole('Foo')
+ r = roleRegistry.defineRole('Foo', 'Foo-able')
+ role = roleRegistry.getRole(r.getId())
eq(role.getTitle(), 'Foo-able')
eq(role.getDescription(), '')
def testDefineRoleWithTitleAndDescription(self):
eq = self.assertEqual
- registry.defineRole('Foo', 'Foo-able', 'A foo-worthy role')
- role = registry.getRole('Foo')
+ r = roleRegistry.defineRole('Foo', 'Foo-able', 'A foo-worthy role')
+ role = roleRegistry.getRole(r.getId())
eq(role.getTitle(), 'Foo-able')
eq(role.getDescription(), 'A foo-worthy role')
=== Zope3/lib/python/Zope/App/Security/tests/testSecurityDirectives.py 1.1.2.4 => 1.1.2.5 ===
from Zope.Configuration.meta import _clear as metaclear
from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
-from Zope.App.Security.PrincipalRegistry import globalRegistry
-from Zope.App.Security.PermissionRegistry import registry as pregistry
-from Zope.App.Security.RoleRegistry import registry as rregistry
+from Zope.App.Security.PrincipalRegistry import principalRegistry
+from Zope.App.Security.PermissionRegistry import permissionRegistry as pregistry
+from Zope.App.Security.RoleRegistry import roleRegistry as rregistry
from Zope.App.Security.metaConfigure import metaConfigure
-from Zope.App.Security.RolePermissionManager import manager as role_perm_mgr
+from Zope.App.Security.RolePermissionManager import rolePermissionManager as role_perm_mgr
from Zope.App.Security.PrincipalPermissionManager \
- import manager as principal_perm_mgr
+ import principalPermissionManager as principal_perm_mgr
from Zope.App.Security.PrincipalRoleManager \
- import manager as principal_role_mgr
+ import principalRoleManager as principal_role_mgr
def configfile(s):
return StringIO("""<zopeConfigure
@@ -36,11 +36,11 @@
class TestPrincipalDirective(unittest.TestCase):
def setUp(self):
- globalRegistry.clear()
+ principalRegistry._clear()
metaConfigure()
def tearDown(self):
- globalRegistry.clear()
+ principalRegistry._clear()
metaclear()
def testRegister(self):
@@ -54,7 +54,7 @@
login="jim" password="123" />""")
xmlconfig(f)
- reg=globalRegistry
+ reg=principalRegistry
p = reg.getPrincipal('1')
self.assertEqual(p.getId(), '1')