Commit 6a9fe9ac authored by Jérome Perrin's avatar Jérome Perrin

show the portal type of the document in failure messages


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23314 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent da809155
...@@ -69,11 +69,11 @@ class AssertPermissionMethod(object): ...@@ -69,11 +69,11 @@ class AssertPermissionMethod(object):
if hasattr(user, 'getGroups'): if hasattr(user, 'getGroups'):
groups = user.getGroups() groups = user.getGroups()
self._instance.fail( self._instance.fail(
'User %s does NOT have %s permission on %s (user roles: [%s], ' 'User %s does NOT have %s permission on %s %s (user roles: [%s], '
'roles needed: [%s], existing local roles: %s, ' 'roles needed: [%s], existing local roles: %s, '
'your user groups: [%s])' % 'your user groups: [%s])' %
(username, self._permission_name, document, (username, self._permission_name, document.getPortalTypeName(),
', '.join(user.getRolesInContext(document)), document, ', '.join(user.getRolesInContext(document)),
', '.join([x['name'] for x in ', '.join([x['name'] for x in
document.rolesOfPermission(self._permission_name) document.rolesOfPermission(self._permission_name)
if x['selected']]), if x['selected']]),
...@@ -101,9 +101,9 @@ class AssertNoPermissionMethod(object): ...@@ -101,9 +101,9 @@ class AssertNoPermissionMethod(object):
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
if user.has_permission(self._permission_name, document): if user.has_permission(self._permission_name, document):
self._instance.fail( self._instance.fail(
'User %s has %s permission on %s (roles: [%s])' % 'User %s has %s permission on %s %s (roles: [%s])' %
(username, self._permission_name, document, (username, self._permission_name, document.getPortalTypeName(),
', '.join(user.getRolesInContext(document)))) document, ', '.join(user.getRolesInContext(document))))
except: except:
setSecurityManager(sm) setSecurityManager(sm)
...@@ -179,8 +179,8 @@ class SecurityTestCase(ERP5TypeTestCase): ...@@ -179,8 +179,8 @@ class SecurityTestCase(ERP5TypeTestCase):
self.workflow_tool.listActions(object=document) if self.workflow_tool.listActions(object=document) if
ai['category'] == 'workflow'] ai['category'] == 'workflow']
if transition in valid_transistion_list: if transition in valid_transistion_list:
self.fail('User %s can pass %s transition on %s. Roles: [%s]' % ( self.fail('User %s can pass %s transition on %s %s. Roles: [%s]' % (
username, transition, document, username, transition, document.getPortalTypeName(), document,
", ".join(user.getRolesInContext(document)))) ", ".join(user.getRolesInContext(document))))
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment