Commit 595248f2 authored by Romain Courteaud's avatar Romain Courteaud

Test worklist guard.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27262 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2e8aa666
......@@ -383,6 +383,47 @@ class TestWorklist(ERP5TypeTestCase):
self.checkWorklist(result, 'has_region', 2)
self.checkWorklist(result, 'has_role', 1)
def test_03_worklist_guard(self, quiet=0, run=run_all_test):
"""
Test worklist guard
"""
if not run:
return
workflow_tool = self.getWorkflowTool()
self.createManagerAndLogin()
self.createUsers()
self.logMessage("Create worklists with guard expression")
self.createWorklist(self.checked_workflow, 'guard_expression_worklist',
'valid_guard_expression',
portal_type=self.checked_portal_type,
validation_state='validated',
guard_roles="Associate",
guard_expr='python: user.getId() == "bar"')
document = self.createDocument()
document.manage_addLocalRoles("bar", ["Associate"])
document.manage_addLocalRoles("foo", ["Associate"])
document.validate()
document.reindexObject()
transaction.commit()
self.tic()
self.clearCache()
self.logMessage(" Check that manager can not access worklist")
result = workflow_tool.listActions(object=document)
self.checkWorklist(result, 'valid_guard_expression', 0)
self.logMessage(" Check that user bar can access worklist")
self.login('bar')
result = workflow_tool.listActions(object=document)
self.checkWorklist(result, 'valid_guard_expression', 1)
self.logMessage(" Check that user foo can not access worklist")
self.login('foo')
result = workflow_tool.listActions(object=document)
self.checkWorklist(result, 'valid_guard_expression', 0)
def test_suite():
suite = unittest.TestSuite()
......
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