Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 8119:c12377fb4144 permission-performance
Change permission representation
Now permissions are checked in different order. Permissions without a
check method (which are cheap to check) are checked first. Only if no
permission is found do we check permissions with check methods.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Fri, 18 Oct 2024 16:52:42 +0200 |
| parents | 0713c286f71c |
| children | 28c5030757d3 |
comparison
equal
deleted
inserted
replaced
| 8118:c88ad93f0e77 | 8119:c12377fb4144 |
|---|---|
| 239 self.db.security.getPermission('Register', 'user'), | 239 self.db.security.getPermission('Register', 'user'), |
| 240 self.db.security.getPermission('Email Access', None), | 240 self.db.security.getPermission('Email Access', None), |
| 241 self.db.security.getPermission('Create', 'issue'), | 241 self.db.security.getPermission('Create', 'issue'), |
| 242 self.db.security.getPermission('Create', 'msg'), | 242 self.db.security.getPermission('Create', 'msg'), |
| 243 ] | 243 ] |
| 244 self.db.security.role['anonymous'].permissions = p | 244 self.db.security.role['anonymous'].addPermission(*p) |
| 245 | 245 |
| 246 def _create_mailgw(self, message, args=()): | 246 def _create_mailgw(self, message, args=()): |
| 247 class MailGW(self.instance.MailGW): | 247 class MailGW(self.instance.MailGW): |
| 248 """call _handle_message as handle_message | 248 """call _handle_message as handle_message |
| 249 the real handle_message reopens the database, and destroys | 249 the real handle_message reopens the database, and destroys |
| 2865 Message-Id: <dummy_test_message_id> | 2865 Message-Id: <dummy_test_message_id> |
| 2866 Subject: [issue] Testing... | 2866 Subject: [issue] Testing... |
| 2867 | 2867 |
| 2868 This is a test submission of a new issue. | 2868 This is a test submission of a new issue. |
| 2869 ''' | 2869 ''' |
| 2870 self.db.security.role['anonymous'].permissions=[] | 2870 self.db.security.role['anonymous']._permissions={} |
| 2871 anonid = self.db.user.lookup('anonymous') | 2871 anonid = self.db.user.lookup('anonymous') |
| 2872 self.db.user.set(anonid, roles='Anonymous') | 2872 self.db.user.set(anonid, roles='Anonymous') |
| 2873 try: | 2873 try: |
| 2874 self._handle_mail(message) | 2874 self._handle_mail(message) |
| 2875 except Unauthorized as value: | 2875 except Unauthorized as value: |
| 2886 # we get a "please register at:" message this time. | 2886 # we get a "please register at:" message this time. |
| 2887 p = [ | 2887 p = [ |
| 2888 self.db.security.getPermission('Register', 'user'), | 2888 self.db.security.getPermission('Register', 'user'), |
| 2889 self.db.security.getPermission('Web Access', None), | 2889 self.db.security.getPermission('Web Access', None), |
| 2890 ] | 2890 ] |
| 2891 self.db.security.role['anonymous'].permissions=p | 2891 self.db.security.role['anonymous'].addPermission(*p) |
| 2892 try: | 2892 try: |
| 2893 self._handle_mail(message) | 2893 self._handle_mail(message) |
| 2894 except Unauthorized as value: | 2894 except Unauthorized as value: |
| 2895 body_diff = self.assertEqual(str(value), """ | 2895 body_diff = self.assertEqual(str(value), """ |
| 2896 You are not a registered user. Please register at: | 2896 You are not a registered user. Please register at: |
| 2913 # now with the permission | 2913 # now with the permission |
| 2914 p = [ | 2914 p = [ |
| 2915 self.db.security.getPermission('Register', 'user'), | 2915 self.db.security.getPermission('Register', 'user'), |
| 2916 self.db.security.getPermission('Email Access', None), | 2916 self.db.security.getPermission('Email Access', None), |
| 2917 ] | 2917 ] |
| 2918 self.db.security.role['anonymous'].permissions=p | 2918 self.db.security.role['anonymous'].addPermission(*p) |
| 2919 self._handle_mail(message) | 2919 self._handle_mail(message) |
| 2920 m = self.db.user.list() | 2920 m = self.db.user.list() |
| 2921 m.sort() | 2921 m.sort() |
| 2922 self.assertNotEqual(l, m) | 2922 self.assertNotEqual(l, m) |
| 2923 | 2923 |
