diff test/test_security.py @ 5186:36630a062fb5

Check in enhanced form for check command used by addPermission. New form can include a **context dictionary that allows access to the name of the property, class, and permission being checked. This should make designing more complex permission requirements easier.
author John Rouillard <rouilj@ieee.org>
date Fri, 17 Feb 2017 21:18:34 -0500
parents 364c54991861
children e0732fd6a6c7
line wrap: on
line diff
--- a/test/test_security.py	Fri Feb 17 19:44:15 2017 -0500
+++ b/test/test_security.py	Fri Feb 17 21:18:34 2017 -0500
@@ -155,8 +155,13 @@
         self.assertEquals(has('Test', none, 'test', property='c'), 0)
         self.assertEquals(has('Test', none, 'test'), 0)
 
-        # check function
-        check = lambda db, userid, itemid: itemid == '1'
+        # check function new style. Make sure that other args are passed.
+        def check(db,userid,itemid, **other):
+            prop = other['property']
+            prop = other['classname']
+            prop = other['permission']
+            return (itemid == '1')
+
         addRole(name='Role3')
         addToRole('Role3', add(name="Test", klass="test", check=check))
         user3 = self.db.user.create(username='user3', roles='Role3')

Roundup Issue Tracker: http://roundup-tracker.org/