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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amrani
erp5
Commits
6d2ffcca
Commit
6d2ffcca
authored
Oct 27, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SecurityTestCase: add helper methods for worklists
parent
141aaf37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
product/ERP5Type/tests/SecurityTestCase.py
product/ERP5Type/tests/SecurityTestCase.py
+35
-0
No files found.
product/ERP5Type/tests/SecurityTestCase.py
View file @
6d2ffcca
...
@@ -244,6 +244,41 @@ class SecurityTestCase(ERP5TypeTestCase):
...
@@ -244,6 +244,41 @@ class SecurityTestCase(ERP5TypeTestCase):
assertUserCanPassWorkflowTransition
=
failUnlessUserCanPassWorkflowTransition
assertUserCanPassWorkflowTransition
=
failUnlessUserCanPassWorkflowTransition
def
assertUserHasWorklist
(
self
,
username
,
worklist_id
,
document_count
):
self
.
portal
.
portal_workflow
.
refreshWorklistCache
()
self
.
portal
.
portal_caches
.
clearAllCache
()
sm
=
getSecurityManager
()
try
:
self
.
_loginAsUser
(
username
)
global_action_list
=
[
x
for
x
in
self
.
portal
.
portal_workflow
.
listActions
(
object
=
self
.
portal
)
if
x
[
'category'
]
==
'global'
]
worklist_action_list
=
[
x
for
x
in
global_action_list
if
x
[
'worklist_id'
]
==
worklist_id
]
if
not
(
worklist_action_list
):
self
.
fail
(
"User %s does not have worklist %s.
\
n
Worklists: %s"
%
(
username
,
worklist_id
,
pformat
(
global_action_list
)))
worklist_action
,
=
worklist_action_list
self
.
assertEquals
(
document_count
,
worklist_action
[
'count'
],
"User %s has %s documents in her %s worklist, not %s"
%
(
username
,
worklist_action
[
'count'
],
worklist_id
,
document_count
))
finally
:
setSecurityManager
(
sm
)
def
assertUserHasNoWorklist
(
self
,
username
,
worklist_id
):
self
.
portal
.
portal_workflow
.
refreshWorklistCache
()
self
.
portal
.
portal_caches
.
clearAllCache
()
sm
=
getSecurityManager
()
try
:
self
.
_loginAsUser
(
username
)
worklist_action_list
=
[
x
for
x
in
self
.
portal
.
portal_workflow
.
listActions
(
object
=
self
.
portal
)
if
x
[
'category'
]
==
'global'
and
x
[
'worklist_id'
]
==
worklist_id
]
if
worklist_action_list
:
self
.
fail
(
"User %s has worklist %s: %s"
%
(
username
,
worklist_id
,
pformat
(
worklist_action_list
)))
finally
:
setSecurityManager
(
sm
)
# Simple check for an user Role
# Simple check for an user Role
def
failIfUserHaveRoleOnDocument
(
self
,
username
,
role
,
document
):
def
failIfUserHaveRoleOnDocument
(
self
,
username
,
role
,
document
):
"""Fails if the user have the role on the document."""
"""Fails if the user have the role on the document."""
...
...
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