[Zope-Checkins] CVS: Zope/lib/python/AccessControl/tests -
testZopeGuards.py:1.1.2.3
Jim Fulton
jim at zope.com
Mon Jan 19 13:54:41 EST 2004
Update of /cvs-repository/Zope/lib/python/AccessControl/tests
In directory cvs.zope.org:/tmp/cvs-serv4014/lib/python/AccessControl/tests
Modified Files:
Tag: Zope-2_6-branch
testZopeGuards.py
Log Message:
Collector #1182: Functions for handling decisions about
unprotected subobjects were not passed "names" when doing
unnamed (item) access. In 2.6.3 we changed access checks when
doing item access to pass None rather than the key value when
validating access. This broke some existing applications. We
have reverted these changes.
=== Zope/lib/python/AccessControl/tests/testZopeGuards.py 1.1.2.2 => 1.1.2.3 ===
--- Zope/lib/python/AccessControl/tests/testZopeGuards.py:1.1.2.2 Fri Jan 9 14:07:17 2004
+++ Zope/lib/python/AccessControl/tests/testZopeGuards.py Mon Jan 19 13:54:10 2004
@@ -78,12 +78,17 @@
self.args = args
-class TestGuardedGetattr(GuardTestCase):
+class TestGuardedGetattrPy(GuardTestCase):
+
+ def setUp(self):
+ GuardTestCase.setUp(self)
+ from AccessControl.ZopeGuards import guarded_getattr_py
+ self.guarded_getattr = guarded_getattr_py
def test_calls_validate_for_unknown_type(self):
sm = SecurityManager()
self.setSecurityManager(sm)
- guarded_getattr(self, 'test_calls_validate_for_unknown_type')
+ self.guarded_getattr(self, 'test_calls_validate_for_unknown_type')
self.assert_(sm.calls)
def test_attr_handler_table(self):
@@ -94,22 +99,30 @@
d = {}
_dict = type(d)
old = ContainerAssertions.get(_dict)
-
- mytable = {'keys': 1,
- 'values': Method,
- }
- ContainerAssertions[_dict] = mytable
+
+ def myfactory(name, value):
+ if name == 'values':
+ return Method
+ return 1
+
+ ContainerAssertions[_dict] = myfactory
try:
- guarded_getattr(d, 'keys')
+ self.guarded_getattr(d, 'keys')
self.assertEqual(len(sm.calls), 0)
- values = guarded_getattr(d, 'values')
+ values = self.guarded_getattr(d, 'values')
self.assertEqual(values.__class__, Method)
self.assertEqual(values.args, (d, 'values'))
- self.assertRaises(Unauthorized, guarded_getattr, d, 'items')
finally:
ContainerAssertions[_dict] = old
+class TestGuardedGetattrC(TestGuardedGetattrPy):
+
+ def setUp(self):
+ TestGuardedGetattrPy.setUp(self)
+ from AccessControl.cAccessControl import guarded_getattr
+ self.guarded_getattr = guarded_getattr
+
class TestDictGuards(GuardTestCase):
def test_get_simple(self):
@@ -293,7 +306,8 @@
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestGuardedGetattr))
+ suite.addTest(unittest.makeSuite(TestGuardedGetattrPy))
+ suite.addTest(unittest.makeSuite(TestGuardedGetattrC))
suite.addTest(unittest.makeSuite(TestDictGuards))
suite.addTest(unittest.makeSuite(TestMinMaxGuards))
suite.addTest(unittest.makeSuite(TestListGuards))
More information about the Zope-Checkins
mailing list