Mercurial > p > roundup > code
diff test/test_cgi.py @ 4306:966592263fb8
Clean up all the places where role processing occurs.
This is now in a central place in hyperdb.Class and is used
consistently throughout. This also means now a template can override
the way role processing occurs (e.g. for elaborate permission
schemes). Thanks to intevation for funding the change.
Note: On first glance the hyperdb.Class may not be the ideal place for
role processing. On second thought: Roles may appear in other classes,
too (e.g., a user_group or similar) which then don't need to reinvent
the wheel. And I didn't want to introduce a separate UserClass (as is
the case for the HTML classes) due to compatibility issues with existing
schema.py out there.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Tue, 15 Dec 2009 15:11:27 +0000 |
| parents | 6441ffe588f7 |
| children | 8e0d350ce644 |
line wrap: on
line diff
--- a/test/test_cgi.py Mon Dec 14 21:48:51 2009 +0000 +++ b/test/test_cgi.py Tue Dec 15 15:11:27 2009 +0000 @@ -648,6 +648,24 @@ self.failUnlessRaises(exceptions.Unauthorised, actions.EditItemAction(cl).handle) + def testRoles(self): + cl = self._make_client({}) + self.db.user.set('1', roles='aDmin, uSer') + item = HTMLItem(cl, 'user', '1') + self.assert_(item.hasRole('Admin')) + self.assert_(item.hasRole('User')) + self.assert_(item.hasRole('AdmiN')) + self.assert_(item.hasRole('UseR')) + self.assert_(item.hasRole('UseR','Admin')) + self.assert_(item.hasRole('UseR','somethingelse')) + self.assert_(item.hasRole('somethingelse','Admin')) + self.assert_(not item.hasRole('userr')) + self.assert_(not item.hasRole('adminn')) + self.assert_(not item.hasRole('')) + self.assert_(not item.hasRole(' ')) + self.db.user.set('1', roles='') + self.assert_(not item.hasRole('')) + def testCSVExport(self): cl = self._make_client({'@columns': 'id,name'}, nodeid=None, userid='1')
