[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/tests - testPrincipalPermissionView.py:1.2 testPrincipalRoleView.py:1.3 testRolePermissionView.py:1.5

Jim Fulton jim@zope.com
Tue, 16 Jul 2002 19:41:48 -0400


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

Modified Files:
	testPrincipalPermissionView.py testPrincipalRoleView.py 
	testRolePermissionView.py 
Log Message:

Renamed (changed service type id) if all services with names ending in
"Service". Container services were given a plural form 
(e.g. "RoleService" => "Roles"), but other services just lost the
suffix (e.g. "AuthenticationService" => "Authentication").

Fixed bug in ZopeSecurityPolicy that caused placeless role-permission
grants to be ignored for placefully assigned roles.

Also changed grant lookup order. Now placeless grants are checked
*before* placeful grants.

Finished the implementation of placeful principal role grants
(re)started at the EuroPython sprint.

Fixed a bug in service directives that caused service component lookup
to fail for unpriviledged users. This caused authentication using
Stephan's authentication service to fail in mysterious ways.

Now you can create users with Stephan's auth service, and assign them
roles using principal-role grants.

Added code to the ZMI (boring) standard_macros template to display the
user, which, BTW is available in request.user.



=== Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/tests/testPrincipalPermissionView.py 1.1 => 1.2 ===
         provideService=getServiceManager(None).provideService
 
         defineService(
-                 'PermissionService', IPermissionService)
-        provideService('PermissionService',
+                 'Permissions', IPermissionService)
+        provideService('Permissions',
                  DummyPermissionService(self._permissions))
 
-        defineService('AuthenticationService',
+        defineService('Authentication',
                  IAuthenticationService)
 
         self._principals = []
         self._principals.append(DummyObject('foo', 'Foo'))
         self._principals.append(DummyObject('bar', 'Bar'))
 
-        provideService('AuthenticationService',
+        provideService('Authentication',
             DummyAuthenticationService(principals = self._principals))
         provideAdapter=getService(None,'Adapters').provideAdapter
         provideAdapter(IAttributeAnnotatable,


=== Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/tests/testPrincipalRoleView.py 1.2 => 1.3 ===
 
 from Zope.App.Security.IPrincipalRoleManager import IPrincipalRoleManager
 from Zope.App.Security.IPrincipalRoleMap import IPrincipalRoleMap
+from Zope.Publisher.Browser.BrowserRequest import TestRequest
 
 class DummySetting:
     def __init__(self, name):
@@ -82,23 +83,23 @@
         defineService=getServiceManager(None).defineService
         provideService=getServiceManager(None).provideService
 
-        defineService('RoleService', IRoleService)
-        provideService('RoleService'
+        defineService('Roles', IRoleService)
+        provideService('Roles'
                       , DummyRoleService(roles = self._roles))
 
-        defineService('AuthenticationService', IAuthenticationService)
+        defineService('Authentication', IAuthenticationService)
 
         self._principals = []
         self._principals.append(DummyObject('foo', 'Foo'))
         self._principals.append(DummyObject('bar', 'Bar'))
 
-        provideService('AuthenticationService',
+        provideService('Authentication',
             DummyAuthenticationService(principals = self._principals))
 
     def _makeOne(self):
         from Zope.App.Security.Grants.Views.Browser.PrincipalRoleView \
              import PrincipalRoleView
-        return PrincipalRoleView(DummyManager(), None)
+        return PrincipalRoleView(DummyManager(), TestRequest())
 
     def testRoles(self):
         view = self._makeOne()
@@ -108,7 +109,7 @@
         ids = map(lambda x: x.getId(), self._roles)
 
         for role in roles:
-            self.failUnless(role in ids)
+            self.failUnless(role.getId() in ids)
 
     def testPrincipals(self):
         view = self._makeOne()
@@ -118,7 +119,7 @@
         ids = map(lambda x: x.getId(), self._principals)
 
         for principal in principals:
-            self.failUnless(principal in ids)
+            self.failUnless(principal.getId() in ids, (principal, ids))
 
     def testPrincipalRoleGrid(self):
         view = self._makeOne()
@@ -130,17 +131,18 @@
 
         self.failUnless(grid.listAvailableValues())
 
-        for id in grid.principals():
-            self.failUnless(id in p_ids)
+        for p in grid.principalIds():
+            self.failUnless(p in p_ids)
 
-        for id in grid.roles():
-            self.failUnless(id in r_ids)
+        for r in grid.roleIds():
+            self.failUnless(r in r_ids)
 
         map = DummyManager()
 
         grid_entries = [(r, p, map.getSetting(r, p).getName())
-            for r in grid.roles()
-            for p in grid.principals()]
+                        for r in grid.roleIds()
+                        for p in grid.principalIds()
+                        ]
 
         for r, p, setting in grid_entries:
             self.assertEquals(setting, grid.getValue(p, r))


=== Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/tests/testRolePermissionView.py 1.4 => 1.5 ===
         PlacefulSetup.setUp(self)
         defineService=getServiceManager(None).defineService
         provideService=getServiceManager(None).provideService
-        defineService('RoleService', IRoleService)
-        provideService('RoleService', RoleService(
+        defineService('Roles', IRoleService)
+        provideService('Roles', RoleService(
             manager='Manager', member='Member'))
-        defineService('PermissionService', IPermissionService)
-        provideService('PermissionService', PermissionService(
+        defineService('Permissions', IPermissionService)
+        provideService('Permissions', PermissionService(
             read='Read', write='Write'))
         self.view = RolePermissionView(RolePermissionManager(), None)