XXX restricted iterator
Showing
... | @@ -132,3 +132,33 @@ class TestRestrictedPythonSecurity(ERP5TypeTestCase): | ... | @@ -132,3 +132,33 @@ class TestRestrictedPythonSecurity(ERP5TypeTestCase): |
expected=(0, 1), | expected=(0, 1), | ||
) | ) | ||
def test_restricted_iterator(self): | |||
from Products.ERP5Type.Globals import InitializeClass | |||
from AccessControl import ClassSecurityInfo | |||
class Private: | |||
security = ClassSecurityInfo() | |||
security.declareObjectPrivate() | |||
def no(self): | |||
return 'no' | |||
InitializeClass(Private) | |||
self.login() | |||
self.portal.private = Private() | |||
self.assertRaises( | |||
Unauthorized, | |||
self.createAndRunScript, | |||
'return context.private.no()') | |||
self.portal.private_iterator = (x for x in [Private().no]) | |||
self.assertRaises( | |||
Unauthorized, | |||
self.createAndRunScript, | |||
'return [x for x in context.private_iterator]') | |||
self.portal.private_iterator = (x for x in [Private().no]) | |||
self.createAndRunScript( | |||
'return [x() for x in context.private_iterator]', | |||
expected=['no'] | |||
) | |||
|