[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testProtectClass.py:1.1.2.7
Paul Everitt
paul@zope.com
Thu, 28 Feb 2002 18:22:05 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv3926/tests
Modified Files:
Tag: Zope-3x-branch
testProtectClass.py
Log Message:
Added checks for misspelled permission ids.
=== Zope3/lib/python/Zope/App/Security/tests/testProtectClass.py 1.1.2.6 => 1.1.2.7 ===
from testmodulehookup import *
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.App.Security.Exceptions import UndefinedPermissionError
def defineDirectives():
xmlconfig(StringIO("""
- <zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+ <zopeConfigure xmlns='http://namespaces.zope.org/zope'
+ xmlns:security='http://namespaces.zope.org/security'>
+ <directive namespace="http://namespaces.zope.org/security"
+ name="permission"
+ attributes="permission_id, title, description"
+ handler="Zope.App.Security.metaConfigure.definePermission" />
<directive namespace="http://namespaces.zope.org/security"
name="protectClass"
attributes="name, permission, interface, method, methods"
@@ -31,6 +37,8 @@
name="instances"
attributes="permission" />
</directive>
+ <security:permission permission_id="extravagant" title="extravagant" />
+ <security:permission permission_id="paltry" title="paltry" />
</zopeConfigure>"""))
NOTSET = []
@@ -209,6 +217,15 @@
% (PREFIX+"test_class", P1))
self.assertDeclaration(declaration,
instP=P1)
+
+ def testBadPermission(self):
+ declaration = ("""<security:protectClass name="%s">
+ <security:instances permission_id="%s"/>
+ </security:protectClass>"""
+ % (PREFIX+"test_class", 'bad'))
+ self.assertRaises(UndefinedPermissionError, self.assertDeclaration,
+ declaration, instP='bad')
+
def apply_declaration(declaration):
"""Apply the xmlconfig machinery."""