Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
c9ee6406
Commit
c9ee6406
authored
Sep 05, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: add test on permissions
parent
c8d35a67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
bt5/erp5_workflow_test/TestTemplateItem/portal_components/test.erp5.testWorkflowAndDCWorkflow.py
.../portal_components/test.erp5.testWorkflowAndDCWorkflow.py
+66
-0
No files found.
bt5/erp5_workflow_test/TestTemplateItem/portal_components/test.erp5.testWorkflowAndDCWorkflow.py
View file @
c9ee6406
...
...
@@ -214,6 +214,72 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
self
.
resetComponentTool
()
self
.
login
()
def
test_permission
(
self
):
"""
test permission/role mapping on states (ERP5 Workflow only)
# XXX(WORKFLOW) move this test to testERP5Workflow?
"""
portal_workflow
=
self
.
portal
.
portal_workflow
self
.
logMessage
(
" Save portal type original configuration"
)
text_portal_type
=
self
.
portal
.
portal_types
.
_getOb
(
'Text'
)
original_portal_type_workflow
=
text_portal_type
.
getTypeWorkflowList
()
temporary_workflow_id
=
'temporary_edit_workflow'
self
.
copyWorkflow
(
portal_workflow
,
'edit_workflow'
,
temporary_workflow_id
)
text_portal_type
.
setTypeWorkflowList
([
'temporary_edit_workflow'
])
# some permission to be added in the test
permission
=
'View management screens'
permission_key
=
'_'
+
permission
.
replace
(
' '
,
'_'
)
+
'_Permission'
self
.
logMessage
(
" Create a text document: it will have the usual permissions"
+
" defined by edit_workflow"
)
text_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Text'
)
self
.
logMessage
(
" Verify that the permission '"
+
permission
+
"' is not "
+
"declared on the text document yet"
)
self
.
assertFalse
(
getattr
(
text_document
,
permission_key
,
False
))
workflow
=
portal_workflow
.
_getOb
(
temporary_workflow_id
)
if
workflow
.
getPortalType
()
!=
'Workflow'
:
self
.
logMessage
(
" Converting workflow "
+
temporary_workflow_id
)
portal_workflow
.
WorkflowTool_convertWorkflow
(
batch_mode
=
True
,
workflow_id_list
=
[
temporary_workflow_id
]
)
self
.
tic
()
workflow
=
portal_workflow
.
_getOb
(
temporary_workflow_id
)
self
.
assertEqual
(
workflow
.
getPortalType
(),
'Workflow'
)
self
.
logMessage
(
" Changing permission list to: %s"
%
[
permission
])
workflow
.
setWorkflowManagedPermissionList
([
permission
])
self
.
tic
()
self
.
logMessage
(
" Verify permission roles dict on 'current' state"
)
permission_roles_dict
=
workflow
.
state_current
\
.
getStatePermissionRolesDict
()
self
.
tic
()
self
.
assertIn
(
permission
,
permission_roles_dict
)
self
.
logMessage
(
" Change roles for '"
+
permission
+
"' on state and update role list for permission "
)
permission_roles_dict
[
permission
]
=
[
'Assignor'
]
workflow
.
updateRoleMappingsFor
(
text_document
)
self
.
tic
()
self
.
logMessage
(
" Check document permissions/roles mapping was updated"
)
self
.
assertEqual
(
getattr
(
text_document
,
permission_key
),
[
'Assignor'
])
self
.
logMessage
(
" Restore original configuration"
)
text_portal_type
.
setTypeWorkflowList
(
original_portal_type_workflow
)
portal_workflow
.
manage_delObjects
(
temporary_workflow_id
)
self
.
portal
.
document_module
.
manage_delObjects
(
text_document
.
getId
())
class
TestDCWorkflow
(
TestERP5WorkflowMixin
):
"""
Check DC Workflow works correctly in new Workflow Tool.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment