Mercurial > p > roundup > code
comparison test/test_security.py @ 5269:c94fd717e28c
Fix http://issues.roundup-tracker.org/issue2550952 make __call__
method of a class usable as a check function.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 19 Sep 2017 22:00:20 -0400 |
| parents | 16a8a3f0772c |
| children | 64b05e24dbd8 |
comparison
equal
deleted
inserted
replaced
| 5268:cc79c0f1651d | 5269:c94fd717e28c |
|---|---|
| 179 prop = other['property'] | 179 prop = other['property'] |
| 180 prop = other['classname'] | 180 prop = other['classname'] |
| 181 prop = other['permission'] | 181 prop = other['permission'] |
| 182 return (itemid == '1') | 182 return (itemid == '1') |
| 183 | 183 |
| 184 # also create a check as a callable of a class | |
| 185 # http://issues.roundup-tracker.org/issue2550952 | |
| 186 class CheckClass(object): | |
| 187 def __call__(self, db,userid,itemid, **other): | |
| 188 prop = other['property'] | |
| 189 prop = other['classname'] | |
| 190 prop = other['permission'] | |
| 191 return (itemid == '1') | |
| 192 | |
| 184 addRole(name='Role3') | 193 addRole(name='Role3') |
| 185 addToRole('Role3', add(name="Test", klass="test", check=check)) | 194 # make sure check=CheckClass() and not check=CheckClass |
| 195 # otherwise we get: | |
| 196 # inspectible <slot wrapper '__init__' of 'object' objects> | |
| 197 addToRole('Role3', add(name="Test", klass="test", check=CheckClass())) | |
| 186 user3 = self.db.user.create(username='user3', roles='Role3') | 198 user3 = self.db.user.create(username='user3', roles='Role3') |
| 187 | 199 |
| 188 addRole(name='Role4') | 200 addRole(name='Role4') |
| 189 addToRole('Role4', add(name="Test", klass="test", check=check, | 201 addToRole('Role4', add(name="Test", klass="test", check=check, |
| 190 properties='a', props_only=True)) | 202 properties='a', props_only=True)) |
