[Zope-CVS] CVS: Products/BTreeFolder2/tests - testBTreeFolder2.py:1.5
Shane Hathaway
shane@cvs.zope.org
Thu, 22 Aug 2002 09:50:19 -0400
Update of /cvs-repository/Products/BTreeFolder2/tests
In directory cvs.zope.org:/tmp/cvs-serv22726/tests
Modified Files:
testBTreeFolder2.py
Log Message:
- Prevented a potential denial of service attack in generateId().
- Expanded the README to describe the interface of BTreeFolders.
=== Products/BTreeFolder2/tests/testBTreeFolder2.py 1.4 => 1.5 ===
--- Products/BTreeFolder2/tests/testBTreeFolder2.py:1.4 Fri May 10 10:52:14 2002
+++ Products/BTreeFolder2/tests/testBTreeFolder2.py Thu Aug 22 09:50:18 2002
@@ -19,7 +19,8 @@
import unittest
import Testing
import Zope
-from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
+from Products.BTreeFolder2.BTreeFolder2 \
+ import BTreeFolder2, ExhaustedUniqueIdsError
from OFS.ObjectManager import BadRequestException
from OFS.Folder import Folder
from Acquisition import aq_base
@@ -127,6 +128,15 @@
self.assertEqual(len(ids), 10) # All unique
for id in ids.keys():
self.f._checkId(id) # Must all be valid
+
+ def testGenerateIdDenialOfServicePrevention(self):
+ for n in range(10):
+ item = Folder()
+ item.id = 'item%d' % n
+ self.f._setOb(item.id, item)
+ self.f.generateId('item', rand_ceiling=20) # Shouldn't be a problem
+ self.assertRaises(ExhaustedUniqueIdsError,
+ self.f.generateId, 'item', rand_ceiling=9)
def testReplace(self):
old_f = Folder()