[ZPT] CVS: Zope/lib/python/Products/PageTemplates/tests - testDTMLTests.py:1.4 testHTMLTests.py:1.9
Tres Seaver
tseaver@zope.com
Sat, 17 Nov 2001 05:33:32 -0500
Update of /cvs-repository/Zope/lib/python/Products/PageTemplates/tests
In directory cvs.zope.org:/tmp/cvs-serv23828/lib/python/Products/PageTemplates/tests
Modified Files:
testDTMLTests.py testHTMLTests.py
Log Message:
- Ensure that any security policy we may find is permissive.
=== Zope/lib/python/Products/PageTemplates/tests/testDTMLTests.py 1.3 => 1.4 ===
from Products.PageTemplates.PageTemplate import PageTemplate
from Acquisition import Implicit
+from AccessControl import SecurityManager
class AqPageTemplate(Implicit, PageTemplate):
pass
+class UnitTestSecurityPolicy:
+ """
+ Stub out the existing security policy for unit testing purposes.
+ """
+ #
+ # Standard SecurityPolicy interface
+ #
+ def validate( self
+ , accessed=None
+ , container=None
+ , name=None
+ , value=None
+ , context=None
+ , roles=None
+ , *args
+ , **kw):
+ return 1
+
+ def checkPermission( self, permission, object, context) :
+ return 1
+
class DTMLTests(unittest.TestCase):
def setUp(self):
self.t=(AqPageTemplate())
+ self.policy = UnitTestSecurityPolicy()
+ self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
+
+ def tearDown(self):
+ SecurityManager.setSecurityPolicy( self.oldPolicy )
def check1(self):
"""DTML test 1: if, in, and var:
=== Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py 1.8 => 1.9 ===
from Products.PageTemplates.tests import util
from Products.PageTemplates.PageTemplate import PageTemplate
+from AccessControl import SecurityManager
from Acquisition import Implicit
class AqPageTemplate(Implicit, PageTemplate):
@@ -95,12 +96,39 @@
class Folder(util.Base):
pass
+
+class UnitTestSecurityPolicy:
+ """
+ Stub out the existing security policy for unit testing purposes.
+ """
+ #
+ # Standard SecurityPolicy interface
+ #
+ def validate( self
+ , accessed=None
+ , container=None
+ , name=None
+ , value=None
+ , context=None
+ , roles=None
+ , *args
+ , **kw):
+ return 1
+
+ def checkPermission( self, permission, object, context) :
+ return 1
+
class HTMLTests(unittest.TestCase):
def setUp(self):
self.folder = f = Folder()
f.laf = AqPageTemplate()
f.t = AqPageTemplate()
+ self.policy = UnitTestSecurityPolicy()
+ self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
+
+ def tearDown(self):
+ SecurityManager.setSecurityPolicy( self.oldPolicy )
def getProducts(self):
return [