[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testAttributePrincipalPermissionManager.py:1.1.2.6 testAttributePrincipalRoleManager.py:1.1.2.8 testAttributeRolePermissionManager.py:1.1.2.9 testPrincipalPermissionView.py:1.1.2.7 testPrincipalRegistry.py:1.1.2.8 testPrincipalRoleView.py:1.1.2.7 testRolePermissionView.py:1.1.2.6 testZSP.py:1.1.2.14
Gary Poster
garyposter@earthlink.net
Mon, 29 Apr 2002 19:20:39 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv1556/App/Security/tests
Modified Files:
Tag: Zope-3x-branch
testAttributePrincipalPermissionManager.py
testAttributePrincipalRoleManager.py
testAttributeRolePermissionManager.py
testPrincipalPermissionView.py testPrincipalRegistry.py
testPrincipalRoleView.py testRolePermissionView.py testZSP.py
Log Message:
ComponentArchitecture reorganization; addition of for_container; addition of IWriteContainer.isAddable.
good news: all tests pass; bad news: after the new security system, my changes have some problems. I had to punt on the default contents view of all folders for instance--hasServiceManager is causing a problem for some reason I couldn't divine, even with Shane's Checker tool. I commented out the offending code on the contents.pt just to keep things up.
I tagged before committing: gary_CA-reorganization
changes more in depth (as I understand it, all or most approved :-) ):
(in ComponentArchitecture:)
* changing implementation names to Global* (i.e., AdapterService becomes
GlobalAdapterService) and giving each its own file (many are clumped together
in hooks.py)
* removing hooks.py in ComponentArchitecture, putting all functions in appropriate module above (i.e. getAdapter will be in the adapter module)
* largely removing indirection (_hook) except for getService and
getNextService
* changing IServiceService.py to IServiceManager
* changing Service.py to GlobalServiceManager.py (and class name too)
* removing "provide*" functions (i.e., provideAdapter, provideUtility, etc.)
and "defineService" from the __init__.py imports
* change all global services to classes with appropriate methods as per
interfaces
* update all tests
* remove all of the "provide*" functions from the interfaces
* renamed IComponentArchitecture to IPlacefulComponentArchitecture (hereafter IPCA), after long discussion with SteveA
* list Resources as one of core CA services in IPlacefulComponentArchitecture
* build actual IPCA interface, not just import of service interfaces (because we want IPCA to be placeful, but the service interfaces do not need to be)
* place functions implementing ICA actually in __init__
* explicitly setting up services in zcml
* created Global service interfaces, and placed the "provides" and "set" and "define" functions there: however, to keep the main interfaces clean and clear, I placed these global interfaces in the same file as the global implementations, hoping to clarify that these are not reusable interfaces but descriptive, one-time interfaces
* built PlacefulSetup in Zope.ComponentArchitecture.tests for more specific CleanUp (a subclass). PlacefulSetup is in the tests folder of the local ServiceManager. AddableSetup also is available, in the AddableService tests.
(elsewhere in Zope3)
* built for_container in addables
* built isAddable for containers (after discussion with Jim, we decided an addable "contains" attribute in the zcml might not be the way to go. I chose the isAddable approach for a number of reasons)
* addableservice does some more checks in getting the addable list, pertinent to the above and to whether it can find the appropriate factories
* a few more tests: a start of one in the local event service, and some more here and there
I'm sorry to add to the confusion of the big security changes, but I needed to either trash these changes or commit them: I'm a bit out of time for the moment. If all else fails, again, I did tag the previous version.
=== Zope3/lib/python/Zope/App/Security/tests/testAttributePrincipalPermissionManager.py 1.1.2.5 => 1.1.2.6 ===
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""Test handler for AttributePrincipalPermissionManager module."""
@@ -17,8 +17,8 @@
import unittest
from Zope.App.OFS.Memento.IAttributeMementoStorable \
- import IAttributeMementoStorable
-from Zope.ComponentArchitecture import provideAdapter
+ import IAttributeMementoStorable
+from Zope.ComponentArchitecture import getService
from Zope.App.OFS.Memento.IMementoBag import IMementoBag
from Zope.App.OFS.Memento.AttributeMementoBag import AttributeMementoBag
from Zope.App.Security.PermissionRegistry \
@@ -28,18 +28,19 @@
from Zope.App.Security.AttributePrincipalPermissionManager \
import AttributePrincipalPermissionManager
from Zope.App.Security.Settings import Allow, Deny, Unset
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
class Manageable:
__implements__ = IAttributeMementoStorable
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacelessSetup, unittest.TestCase):
def setUp(self):
- CleanUp.setUp(self)
- provideAdapter(IAttributeMementoStorable, IMementoBag,
- AttributeMementoBag)
-
+ PlacelessSetup.setUp(self)
+ getService(None,"Adapters").provideAdapter(
+ IAttributeMementoStorable, IMementoBag,
+ AttributeMementoBag)
+
def _make_principal(self, id=None, title=None):
p = prinregistry.definePrincipal(
id or 'APrincipal',
=== Zope3/lib/python/Zope/App/Security/tests/testAttributePrincipalRoleManager.py 1.1.2.7 => 1.1.2.8 ===
from Zope.App.OFS.Memento.IAttributeMementoStorable \
import IAttributeMementoStorable
-from Zope.ComponentArchitecture import provideAdapter
+from Zope.ComponentArchitecture import getService
from Zope.App.OFS.Memento.IMementoBag import IMementoBag
from Zope.App.OFS.Memento.AttributeMementoBag import AttributeMementoBag
from Zope.App.Security.RoleRegistry import roleRegistry as rregistry
@@ -26,17 +26,18 @@
from Zope.App.Security.AttributePrincipalRoleManager \
import AttributePrincipalRoleManager
from Zope.App.Security.Settings import Assign, Remove
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup import PlacefulSetup
class Manageable:
__implements__ = IAttributeMementoStorable
-class Test(CleanUp, unittest.TestCase):
-
+class Test(PlacefulSetup, unittest.TestCase):
+
def setUp(self):
- CleanUp.setUp(self)
- provideAdapter(IAttributeMementoStorable, IMementoBag,
- AttributeMementoBag)
+ PlacefulSetup.setUp(self)
+ getService(None,"Adapters").provideAdapter(
+ IAttributeMementoStorable, IMementoBag,
+ AttributeMementoBag)
def _make_principal(self, id=None, title=None):
p = pregistry.definePrincipal(
=== Zope3/lib/python/Zope/App/Security/tests/testAttributeRolePermissionManager.py 1.1.2.8 => 1.1.2.9 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -18,27 +18,31 @@
from Zope.App.OFS.Memento.IMementoBag import IMementoBag
from Zope.App.OFS.Memento.AttributeMementoBag import AttributeMementoBag
from Zope.ComponentArchitecture \
- import defineService, provideService, provideAdapter
+ import getServiceManager, getService
from Zope.App.Security.IRoleService import IRoleService
from Zope.App.Security.IPermissionService import IPermissionService
from Zope.App.Security.RoleRegistry import roleRegistry
from Zope.App.Security.PermissionRegistry import permissionRegistry
from Zope.App.Security.Settings import Allow, Deny
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
import unittest, sys
class Manageable:
__implements__ = IAttributeMementoStorable
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
- CleanUp.setUp(self)
+ PlacefulSetup.setUp(self)
+ defineService=getServiceManager(None).defineService
+ provideService=getServiceManager(None).provideService
defineService('RoleService', IRoleService)
defineService('PermissionService', IPermissionService)
provideService('RoleService', roleRegistry)
provideService('PermissionService', permissionRegistry)
+ provideAdapter=getService(None,"Adapters").provideAdapter
provideAdapter(IAttributeMementoStorable, IMementoBag,
AttributeMementoBag)
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalPermissionView.py 1.1.2.6 => 1.1.2.7 ===
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -18,9 +18,7 @@
import unittest
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.ComponentArchitecture import defineService, provideService
-from Zope.ComponentArchitecture import provideAdapter
+from Zope.ComponentArchitecture import getService, getServiceManager
from Zope.App.OFS.Memento.IAttributeMementoStorable \
import IAttributeMementoStorable
from Zope.App.OFS.Memento.IMementoBag import IMementoBag
@@ -31,6 +29,8 @@
import IPrincipalPermissionManager
from Zope.App.Security.IPrincipalPermissionMap import IPrincipalPermissionMap
from Zope.App.Security.Settings import Allow, Deny, Unset
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
class DummyContext:
@@ -130,18 +130,23 @@
return self._title
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
+ PlacefulSetup.setUp(self)
self._permissions = []
self._permissions.append(DummyObject('qux', 'Qux'))
self._permissions.append(DummyObject('baz', 'Baz'))
+ defineService=getServiceManager(None).defineService
+ provideService=getServiceManager(None).provideService
- defineService('PermissionService', IPermissionService)
- provideService('PermissionService', DummyPermissionService(
- self._permissions))
+ defineService(
+ 'PermissionService', IPermissionService)
+ provideService('PermissionService',
+ DummyPermissionService(self._permissions))
- defineService('AuthenticationService', IAuthenticationService)
+ defineService('AuthenticationService',
+ IAuthenticationService)
self._principals = []
self._principals.append(DummyObject('foo', 'Foo'))
@@ -149,10 +154,11 @@
provideService('AuthenticationService',
DummyAuthenticationService(principals = self._principals))
+ provideAdapter=getService(None,'Adapters').provideAdapter
provideAdapter(IAttributeMementoStorable,
IPrincipalPermissionManager, DummyAdapter)
- provideAdapter(IAttributeMementoStorable, IMementoBag,
- AttributeMementoBag)
+ provideAdapter(
+ IAttributeMementoStorable, IMementoBag, AttributeMementoBag)
def _makeOne(self):
from Zope.App.Security.PrincipalPermissionView \
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRegistry.py 1.1.2.7 => 1.1.2.8 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -17,7 +17,8 @@
from Zope.App.Security.PrincipalRegistry import DuplicateLogin, DuplicateId
from Zope.Exceptions import NotFoundError
from Zope.Publisher.HTTP.IHTTPCredentials import IHTTPCredentials
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
class Request:
@@ -34,15 +35,16 @@
self.challenge = challenge
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
- CleanUp.setUp(self)
+ PlacefulSetup.setUp(self)
- from Zope.ComponentArchitecture import provideAdapter
+ from Zope.ComponentArchitecture import getService
from Zope.App.Security.BasicAuthAdapter import BasicAuthAdapter
from Zope.App.Security.ILoginPassword import ILoginPassword
- provideAdapter(IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
+ getService(None,"Adapters").provideAdapter(
+ IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
self.reg = PrincipalRegistry()
=== Zope3/lib/python/Zope/App/Security/tests/testPrincipalRoleView.py 1.1.2.6 => 1.1.2.7 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
@@ -18,8 +18,9 @@
import unittest
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.ComponentArchitecture import defineService, provideService
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup\
+ import PlacefulSetup
+from Zope.ComponentArchitecture import getServiceManager
from Zope.App.Security.IRoleService import IRoleService
from Zope.App.Security.IAuthenticationService import IAuthenticationService
@@ -65,12 +66,15 @@
def getPrincipals( self ):
return self._principals
-class Test(CleanUp, unittest.TestCase ):
+class Test(PlacefulSetup, unittest.TestCase ):
def setUp(self):
+ PlacefulSetup.setUp(self)
self._roles = []
self._roles.append( DummyObject( 'qux', 'Qux' ) )
self._roles.append( DummyObject( 'baz', 'Baz' ) )
+ defineService=getServiceManager(None).defineService
+ provideService=getServiceManager(None).provideService
defineService( 'RoleService', IRoleService )
provideService( 'RoleService'
=== Zope3/lib/python/Zope/App/Security/tests/testRolePermissionView.py 1.1.2.5 => 1.1.2.6 ===
##############################################################################
import unittest, sys
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.ComponentArchitecture import defineService, provideService
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup\
+ import PlacefulSetup
+from Zope.ComponentArchitecture import getServiceManager
from Zope.App.Security.IRoleService import IRoleService
from RoleService import RoleService
from PermissionService import PermissionService
@@ -21,9 +22,12 @@
from Zope.App.Security.RolePermissionView import RolePermissionView
from Zope.App.Security.IPermissionService import IPermissionService
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
+ PlacefulSetup.setUp(self)
+ defineService=getServiceManager(None).defineService
+ provideService=getServiceManager(None).provideService
defineService('RoleService', IRoleService)
provideService('RoleService', RoleService(
manager='Manager', member='Member'))
=== Zope3/lib/python/Zope/App/Security/tests/testZSP.py 1.1.2.13 => 1.1.2.14 ===
"""
+
Revision information: $Id$
"""
@@ -21,7 +22,7 @@
from Interface import Interface
from Zope.Proxy.ContextWrapper import ContextWrapper
-from Zope.ComponentArchitecture import provideAdapter
+from Zope.ComponentArchitecture import getService
from Zope.App.Security.IRolePermissionManager import IRolePermissionManager
from Zope.App.Security.PermissionRegistry import permissionRegistry
from Zope.App.Security.PrincipalRegistry import principalRegistry
@@ -48,7 +49,8 @@
import IAttributeMementoStorable
from Zope.App.OFS.Memento.IMementoBag import IMementoBag
from Zope.App.OFS.Memento.AttributeMementoBag import AttributeMementoBag
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup\
+ import PlacefulSetup
class Context:
def __init__(self, user, stack=[]):
@@ -59,10 +61,12 @@
-class Test(CleanUp, unittest.TestCase):
+class Test(PlacefulSetup, unittest.TestCase):
def setUp(self):
- provideAdapter(IAttributeMementoStorable, IMementoBag,
+ PlacefulSetup.setUp(self)
+ getService(None,"Adapters").provideAdapter(
+ IAttributeMementoStorable, IMementoBag,
AttributeMementoBag)
jim = principalRegistry.definePrincipal('jim', 'Jim', 'Jim Fulton',
'jim', '123')
@@ -142,7 +146,8 @@
def testPlayfulRolePermissions(self):
ARPM = AttributeRolePermissionManager
- provideAdapter(ITest, IRolePermissionManager, ARPM)
+ getService(None,"Adapters").provideAdapter(ITest,
+ IRolePermissionManager, ARPM)
test = permissionRegistry.definePermission('test', 'Test', '')
test = test.getId()
@@ -183,7 +188,8 @@
def testPlayfulPrinciplePermissions(self):
APPM = AttributePrincipalPermissionManager
- provideAdapter(ITest, IPrincipalPermissionManager, APPM)
+ getService(None,"Adapters").provideAdapter(ITest,
+ IPrincipalPermissionManager, APPM)
ob1 = TestClass()
ob2 = TestClass()