Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 4305:e39b88a7150a | 4306:966592263fb8 |
|---|---|
| 646 actions.EditItemAction(cl).handle) | 646 actions.EditItemAction(cl).handle) |
| 647 cl = self._make_client({'password':'bob', '@confirm@password':'bob'}) | 647 cl = self._make_client({'password':'bob', '@confirm@password':'bob'}) |
| 648 self.failUnlessRaises(exceptions.Unauthorised, | 648 self.failUnlessRaises(exceptions.Unauthorised, |
| 649 actions.EditItemAction(cl).handle) | 649 actions.EditItemAction(cl).handle) |
| 650 | 650 |
| 651 def testRoles(self): | |
| 652 cl = self._make_client({}) | |
| 653 self.db.user.set('1', roles='aDmin, uSer') | |
| 654 item = HTMLItem(cl, 'user', '1') | |
| 655 self.assert_(item.hasRole('Admin')) | |
| 656 self.assert_(item.hasRole('User')) | |
| 657 self.assert_(item.hasRole('AdmiN')) | |
| 658 self.assert_(item.hasRole('UseR')) | |
| 659 self.assert_(item.hasRole('UseR','Admin')) | |
| 660 self.assert_(item.hasRole('UseR','somethingelse')) | |
| 661 self.assert_(item.hasRole('somethingelse','Admin')) | |
| 662 self.assert_(not item.hasRole('userr')) | |
| 663 self.assert_(not item.hasRole('adminn')) | |
| 664 self.assert_(not item.hasRole('')) | |
| 665 self.assert_(not item.hasRole(' ')) | |
| 666 self.db.user.set('1', roles='') | |
| 667 self.assert_(not item.hasRole('')) | |
| 668 | |
| 651 def testCSVExport(self): | 669 def testCSVExport(self): |
| 652 cl = self._make_client({'@columns': 'id,name'}, nodeid=None, | 670 cl = self._make_client({'@columns': 'id,name'}, nodeid=None, |
| 653 userid='1') | 671 userid='1') |
| 654 cl.classname = 'status' | 672 cl.classname = 'status' |
| 655 output = StringIO.StringIO() | 673 output = StringIO.StringIO() |
