[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/security/
Merged changes from trunk revision 26753
Dmitry Vasiliev
dima at hlabs.spb.ru
Mon Jul 26 03:50:10 EDT 2004
Log message for revision 26754:
Merged changes from trunk revision 26753
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/security/management.py
U Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_management.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/security/management.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/security/management.py 2004-07-26 07:28:05 UTC (rev 26753)
+++ Zope3/branches/ZopeX3-3.0/src/zope/security/management.py 2004-07-26 07:50:10 UTC (rev 26754)
@@ -117,6 +117,8 @@
checkPermission is guaranteed to return True if permission is
CheckerPublic or None.
"""
+ if permission is CheckerPublic or permission is None:
+ return True
if interaction is None:
interaction = thread_local.interaction
return interaction.checkPermission(permission, object)
@@ -126,5 +128,6 @@
# circular imports are not fun
+from zope.security.checker import CheckerPublic
from zope.security.simplepolicies import ParanoidSecurityPolicy
_defaultPolicy = ParanoidSecurityPolicy
Modified: Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_management.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_management.py 2004-07-26 07:28:05 UTC (rev 26753)
+++ Zope3/branches/ZopeX3-3.0/src/zope/security/tests/test_management.py 2004-07-26 07:50:10 UTC (rev 26754)
@@ -68,9 +68,6 @@
permission = 'zope.Test'
obj = object()
- class InteractionStub:
- pass
-
class PolicyStub:
def checkPermission(s, p, o,):
@@ -84,7 +81,26 @@
interaction = queryInteraction()
self.assertEquals(checkPermission(permission, obj), True)
+ def test_checkPublicPermission(self):
+ from zope.security import checkPermission
+ from zope.security.checker import CheckerPublic
+ from zope.security.management import setSecurityPolicy
+ from zope.security.management import newInteraction
+ obj = object()
+
+ class ForbiddenPolicyStub(object):
+
+ def checkPermission(s, p, o):
+ return False
+
+ setSecurityPolicy(ForbiddenPolicyStub)
+ newInteraction()
+ self.assertEquals(checkPermission('zope.Test', obj), False)
+ self.assertEquals(checkPermission(None, obj), True)
+ self.assertEquals(checkPermission(CheckerPublic, obj), True)
+
+
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
More information about the Zope3-Checkins
mailing list