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
Alexander Emmerich
erp5
Commits
1fc4fc1b
Commit
1fc4fc1b
authored
Dec 09, 2016
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfiguratorTestMixin: Reduce reliance on Person.reference as a user id.
parent
bbc09fc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
456 additions
and
434 deletions
+456
-434
product/ERP5Configurator/tests/ConfiguratorTestMixin.py
product/ERP5Configurator/tests/ConfiguratorTestMixin.py
+456
-434
No files found.
product/ERP5Configurator/tests/ConfiguratorTestMixin.py
View file @
1fc4fc1b
...
...
@@ -250,6 +250,17 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
next_dict
.
setdefault
(
k
,
[]).
append
(
v
)
sequence
.
edit
(
next_dict
=
next_dict
)
def
_getUserIdList
(
self
,
login_list
):
user_id_dict
=
{
x
[
'login'
]:
x
[
'id'
]
for
x
in
self
.
portal
.
acl_users
.
searchUsers
(
login
=
login_list
,
exact_match
=
True
,
)
}
self
.
assertSameSet
(
user_id_dict
,
login_list
)
return
user_id_dict
.
values
()
def
stepCheckMultiplePersonConfigurationItem
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
Check if multiple Person Configuration Item of the Business
...
...
@@ -546,7 +557,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
"""
Test if gadget system is working.
"""
for
user_id
in
self
.
all_username_list
:
for
user_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user_id
)
knowledge_pad_module
=
self
.
portal
.
knowledge_pad_module
knowledge_pad
=
knowledge_pad_module
.
newContent
(
portal_type
=
'Knowledge Pad'
)
...
...
@@ -560,78 +571,78 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def
stepViewEventModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Everybody can view events. """
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
self
.
portal
.
event_module
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
self
.
portal
.
event_module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
self
.
portal
.
event_module
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
self
.
portal
.
event_module
)
def
stepAddEvent
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" Everybody can add events. """
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAddDocument
(
user
name
,
self
.
portal
.
event_module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAddDocument
(
user
_id
,
self
.
portal
.
event_module
)
for
event_type
in
(
'Visit'
,
'Web Message'
,
'Letter'
,
'Note'
,
'Phone Call'
,
'Mail Message'
,
'Fax Message'
):
self
.
_loginAsUser
(
user
name
)
self
.
_loginAsUser
(
user
_id
)
event
=
self
.
portal
.
event_module
.
newContent
(
portal_type
=
event_type
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
event
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
event
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
event
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
event
)
def
stepSentEventWorkflow
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
for
event_type
in
(
'Visit'
,
'Web Message'
,
'Letter'
,
'Note'
,
'Phone Call'
,
'Mail Message'
,
'Fax Message'
):
event
=
self
.
portal
.
event_module
.
newContent
(
portal_type
=
event_type
)
# in draft state, we can view & modify
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
event
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
event
)
self
.
failUnlessUserCanModifyDocument
(
user
name
,
event
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
event
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
event
)
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
event
)
# everybody can cancel from draft
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'cancel_action'
,
event
)
user
_id
,
'cancel_action'
,
event
)
# everybody can plan
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'plan_action'
,
event
)
user
_id
,
'plan_action'
,
event
)
event
.
plan
()
self
.
assertEqual
(
'planned'
,
event
.
getSimulationState
())
# everybody can confirm or send a planned event
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'confirm_action'
,
event
)
user
_id
,
'confirm_action'
,
event
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'start_action'
,
event
)
user
_id
,
'start_action'
,
event
)
event
.
start
()
self
.
assertEqual
(
'started'
,
event
.
getSimulationState
())
# everybody can deliver a sent event
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'deliver_action'
,
event
)
user
_id
,
'deliver_action'
,
event
)
event
.
deliver
()
self
.
assertEqual
(
'delivered'
,
event
.
getSimulationState
())
## Accounts {{{
def
stepViewAccountModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" everybody can view and access account module. """
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
self
.
portal
.
account_module
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
self
.
portal
.
account_module
)
def
stepAddAccountModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
""" only accountants can add accounts. """
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanAddDocument
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanAddDocument
(
user
_id
,
self
.
portal
.
account_module
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanAddDocument
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanAddDocument
(
user
_id
,
self
.
portal
.
account_module
)
def
stepViewAccount
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -640,60 +651,60 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# in draft state,
self
.
assertEqual
(
'draft'
,
account
.
getValidationState
())
# everybody can see
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
account
)
# only accountants can modify
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
account
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
account
)
# only accountants can validate
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'validate_action'
,
account
)
user
_id
,
'validate_action'
,
account
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
'validate_action'
,
account
)
user
_id
,
'validate_action'
,
account
)
account
.
validate
()
self
.
assertEqual
(
'validated'
,
account
.
getValidationState
())
# in validated state, every body can view, but *nobody* can modify
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
account
)
self
.
failIfUserCanModifyDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
account
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
account
)
# only accountants can invalidate
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'invalidate_action'
,
account
)
user
_id
,
'invalidate_action'
,
account
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
'invalidate_action'
,
account
)
user
_id
,
'invalidate_action'
,
account
)
account
.
invalidate
()
self
.
assertEqual
(
'invalidated'
,
account
.
getValidationState
())
# back in invalidated state, everybody can view
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
account
)
# only accountants can modify
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
account
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
account
)
account
.
delete
()
# nobody can view delete object, but we can still access, for safety
for
user
name
in
self
.
all_username_list
:
self
.
failIfUserCanViewDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failIfUserCanViewDocument
(
user
_id
,
account
)
def
stepCopyPasteAccount
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# tests copy / pasting accounts from account module
...
...
@@ -703,40 +714,40 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'draft'
,
account
.
getValidationState
())
# everybody can see
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
account
)
def
stepViewEntityModules
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Everybody can view entities.
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
for
module
in
[
self
.
portal
.
person_module
,
self
.
portal
.
organisation_module
]:
self
.
failUnlessUserCanViewDocument
(
user
name
,
module
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
module
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
module
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
module
)
def
stepAddEntityModules
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Everybody can add entities.
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
for
module
in
[
self
.
portal
.
person_module
,
self
.
portal
.
organisation_module
]:
self
.
failUnlessUserCanAddDocument
(
user
name
,
module
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
module
)
def
stepCopyAndPastePerson
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# copy & paste in person module
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
person
.
Base_createCloneDocument
()
def
stepCopyAndPasteOrganisation
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# copy & paste in organisation module
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
organisation
.
Base_createCloneDocument
()
def
stepEntityWorkflow
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -744,30 +755,30 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
portal
.
organisation_module
]:
entity
=
module
.
newContent
()
# in draft state, we can view, modify & add
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanModifyDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
entity
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
entity
)
# everybody can validate
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'validate_action'
,
entity
)
user
_id
,
'validate_action'
,
entity
)
entity
.
validate
()
self
.
assertEqual
(
'validated'
,
entity
.
getValidationState
())
# in validated state, we can still modify
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanModifyDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
entity
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
entity
)
# and invalidate
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'invalidate_action'
,
entity
)
user
_id
,
'invalidate_action'
,
entity
)
def
stepViewCreatedPersons
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
loginByUserName
(
user_name
=
'test_configurator_user'
)
...
...
@@ -776,9 +787,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertNotEquals
(
0
,
len
(
person_list
))
for
entity
in
person_list
:
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
entity
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
entity
)
def
stepViewCreatedOrganisations
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
loginByUserName
(
user_name
=
'test_configurator_user'
)
...
...
@@ -787,9 +798,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertNotEquals
(
0
,
len
(
organisation_list
))
for
entity
in
organisation_list
:
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
entity
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
entity
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
entity
)
def
stepViewCreatedAssignemnts
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
loginByUserName
(
user_name
=
'test_configurator_user'
)
...
...
@@ -801,9 +812,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
found_one
=
0
for
assignment
in
person
.
contentValues
(
portal_type
=
'Assignment'
):
found_one
=
1
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAccessDocument
(
user
name
,
assignment
)
self
.
failUnlessUserCanViewDocument
(
user
name
,
assignment
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
assignment
)
self
.
failUnlessUserCanViewDocument
(
user
_id
,
assignment
)
self
.
assertTrue
(
found_one
,
'No assignment found in %s'
%
person
)
# }}}
...
...
@@ -813,8 +824,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# Everybody can add accounting periods.
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
assertTrue
(
'Accounting Period'
in
organisation
.
getVisibleAllowedContentTypeList
())
...
...
@@ -834,42 +845,44 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
accounting_period
.
getSimulationState
(),
'draft'
)
# accountants can modify the period
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
accounting_period
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
accounting_period
)
# accountants can cancel the period
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'cancel_action'
,
accounting_period
)
user
_id
,
'cancel_action'
,
accounting_period
)
# accountants can start the period
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'start_action'
,
accounting_period
)
user
_id
,
'start_action'
,
accounting_period
)
# once the period is started, nobody can modify
accounting_period
.
start
()
self
.
assertEqual
(
'started'
,
accounting_period
.
getSimulationState
())
for
user
name
in
self
.
accountant_username_list
:
self
.
failIfUserCanModifyDocument
(
user
name
,
accounting_period
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failIfUserCanModifyDocument
(
user
_id
,
accounting_period
)
# accountants can still cancel the period
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'cancel_action'
,
accounting_period
)
user
_id
,
'cancel_action'
,
accounting_period
)
# accountants can stop the period
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'stop_action'
,
accounting_period
)
user
_id
,
'stop_action'
,
accounting_period
)
# and reopen it
accounting_period
.
stop
()
self
.
assertEqual
(
'stopped'
,
accounting_period
.
getSimulationState
())
for
user
name
in
self
.
accountant_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'restart_action'
,
accounting_period
)
user
_id
,
'restart_action'
,
accounting_period
)
# but only accounting manager can close it
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
failUnlessUserCanPassWorkflowTransition
(
self
.
accounting_manager_reference
,
'deliver_action'
,
accounting_period
)
accounting_manager_id
,
'deliver_action'
,
accounting_period
)
if
self
.
restricted_security
:
accounting_agent_id
,
=
self
.
_getUserIdList
([
self
.
accounting_agent_reference
])
self
.
failIfUserCanPassWorkflowTransition
(
self
.
accounting_agent_reference
,
'deliver_action'
,
accounting_period
)
accounting_agent_id
,
'deliver_action'
,
accounting_period
)
# }}}
...
...
@@ -881,15 +894,15 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
bank_account
=
entity
.
newContent
(
portal_type
=
'Bank Account'
)
# everybody can view in draft ...
self
.
assertEqual
(
'draft'
,
bank_account
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
bank_account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
bank_account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
bank_account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
bank_account
)
# ... and validated states
bank_account
.
validate
()
self
.
assertEqual
(
'validated'
,
bank_account
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
bank_account
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
bank_account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
bank_account
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
bank_account
)
def
stepViewCreditCard
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Everybody can view credit cards
...
...
@@ -898,15 +911,15 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
ext_payment
=
entity
.
newContent
(
portal_type
=
'Credit Card'
)
# every body can view in draft ...
self
.
assertEqual
(
'draft'
,
ext_payment
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
ext_payment
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
ext_payment
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
ext_payment
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
ext_payment
)
# ... and validated states
ext_payment
.
validate
()
self
.
assertEqual
(
'validated'
,
ext_payment
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
ext_payment
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
ext_payment
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
ext_payment
)
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
ext_payment
)
def
stepValidateAndModifyBankAccount
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Every body can modify Bank Accounts
...
...
@@ -914,26 +927,26 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
portal_type
=
'Organisation'
)
bank_account
=
entity
.
newContent
(
portal_type
=
'Bank Account'
)
# draft
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
bank_account
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
bank_account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'validate_action'
,
bank_account
)
# validated
bank_account
.
validate
()
self
.
assertEqual
(
'validated'
,
bank_account
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
bank_account
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
bank_account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'invalidate_action'
,
bank_account
)
# invalidated
bank_account
.
invalidate
()
self
.
assertEqual
(
'invalidated'
,
bank_account
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
bank_account
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
bank_account
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'validate_action'
,
bank_account
)
def
stepValidateAndModifyCreditCard
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -942,33 +955,33 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
portal_type
=
'Organisation'
)
credit_card
=
entity
.
newContent
(
portal_type
=
'Credit Card'
)
# draft
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
credit_card
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
credit_card
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'validate_action'
,
credit_card
)
# validated
credit_card
.
validate
()
self
.
assertEqual
(
'validated'
,
credit_card
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
credit_card
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
credit_card
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'invalidate_action'
,
credit_card
)
# invalidated
credit_card
.
invalidate
()
self
.
assertEqual
(
'invalidated'
,
credit_card
.
getValidationState
())
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
credit_card
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
credit_card
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'validate_action'
,
credit_card
)
def
stepAddPaymentNodeInPerson
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
person
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
person
)
self
.
assertTrue
(
'Bank Account'
in
person
.
getVisibleAllowedContentTypeList
())
self
.
assertTrue
(
'Credit Card'
in
...
...
@@ -976,9 +989,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# when the entity is validated, we can still add some payment nodes
person
.
validate
()
self
.
portal
.
portal_caches
.
clearAllCache
()
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
person
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
person
)
self
.
assertTrue
(
'Bank Account'
in
person
.
getVisibleAllowedContentTypeList
())
self
.
assertTrue
(
'Credit Card'
in
...
...
@@ -987,9 +1000,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def
stepAddPaymentNodeInOrganisation
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
org
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
org
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
org
)
self
.
assertTrue
(
'Bank Account'
in
org
.
getVisibleAllowedContentTypeList
())
self
.
assertTrue
(
'Credit Card'
in
...
...
@@ -997,9 +1010,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# when the entity is validated, we can still add some payment nodes
org
.
validate
()
self
.
portal
.
portal_caches
.
clearAllCache
()
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
org
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
org
)
self
.
assertTrue
(
'Bank Account'
in
org
.
getVisibleAllowedContentTypeList
())
self
.
assertTrue
(
'Credit Card'
in
...
...
@@ -1011,8 +1024,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
portal_type
=
'Organisation'
)
bank_account
=
person
.
newContent
(
portal_type
=
'Bank Account'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
bank_account
.
Base_createCloneDocument
()
def
stepCopyAndPasteBankAccountInOrganisation
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -1021,24 +1034,24 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
portal_type
=
'Organisation'
)
bank_account
=
organisation
.
newContent
(
portal_type
=
'Bank Account'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
bank_account
.
Base_createCloneDocument
()
# }}}
## Accounting Module {{{
def
stepViewAccountingTransactionModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanViewDocument
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanViewDocument
(
user
_id
,
self
.
portal
.
accounting_module
)
self
.
failUnlessUserCanAccessDocument
(
user
name
,
self
.
failUnlessUserCanAccessDocument
(
user
_id
,
self
.
portal
.
accounting_module
)
def
stepAddAccountingTransactionModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Anyone can adds accounting transactions
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanAddDocument
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanAddDocument
(
user
_id
,
self
.
portal
.
accounting_module
)
def
stepCopyAndPasteAccountingTransactions
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
...
@@ -1047,8 +1060,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
if
portal_type
!=
'Balance Transaction'
:
transaction
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
portal_type
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
transaction
.
Base_createCloneDocument
()
def
_getAccountingTransactionTypeList
(
self
):
...
...
@@ -1062,47 +1075,47 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
start_date
=
DateTime
(
2001
,
01
,
01
),
stop_date
=
DateTime
(
2001
,
01
,
01
))
self
.
assertEqual
(
'draft'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'start_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
# TODO
### self.failUnlessUserCanPassWorkflowTransition(user
name
,
### self.failUnlessUserCanPassWorkflowTransition(user
_id
,
### 'delete_action',
### transaction)
...
...
@@ -1111,55 +1124,55 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# only accountant can modify
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
# only accountant can "stop"
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
transaction
.
stop
()
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# nobody can modify
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
# in started state, we can modify again, and go back to stopped state
...
...
@@ -1167,9 +1180,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
...
...
@@ -1178,11 +1191,13 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
# only accounting_manager can validate
self
.
failUnlessUserCanPassWorkflowTransition
(
self
.
accounting_manager_reference
,
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
failUnlessUserCanPassWorkflowTransition
(
accounting_manager_id
,
'deliver_action'
,
transaction
)
if
self
.
restricted_security
:
self
.
failIfUserCanPassWorkflowTransition
(
self
.
accounting_agent_reference
,
accounting_agent_id
,
=
self
.
_getUserIdList
([
self
.
accounting_agent_reference
])
self
.
failIfUserCanPassWorkflowTransition
(
accounting_agent_id
,
'deliver_action'
,
transaction
)
...
...
@@ -1192,57 +1207,57 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
start_date
=
DateTime
(
2001
,
01
,
01
),
stop_date
=
DateTime
(
2001
,
01
,
01
))
self
.
assertEqual
(
'draft'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
-
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
-
self
.
sales_and_purchase_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
# TODO
### self.failUnlessUserCanPassWorkflowTransition(user
name
,
### self.failUnlessUserCanPassWorkflowTransition(user
_id
,
### 'delete_action',
### transaction)
...
...
@@ -1251,55 +1266,55 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# only accountant can modify
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
# only accountant can "stop"
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
transaction
.
stop
()
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# nobody can modify
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
# in started state, we can modify again, and go back to stopped state
...
...
@@ -1307,9 +1322,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
...
...
@@ -1318,11 +1333,13 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
# only accounting_manager can validate
self
.
failUnlessUserCanPassWorkflowTransition
(
self
.
accounting_manager_reference
,
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
failUnlessUserCanPassWorkflowTransition
(
accounting_manager_id
,
'deliver_action'
,
transaction
)
if
self
.
restricted_security
:
self
.
failIfUserCanPassWorkflowTransition
(
self
.
accounting_agent_reference
,
accounting_agent_id
,
=
self
.
_getUserIdList
([
self
.
accounting_agent_reference
])
self
.
failIfUserCanPassWorkflowTransition
(
accounting_agent_id
,
'deliver_action'
,
transaction
)
...
...
@@ -1333,62 +1350,62 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
start_date
=
DateTime
(
2001
,
01
,
01
),
stop_date
=
DateTime
(
2001
,
01
,
01
))
self
.
assertEqual
(
'draft'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
-
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
-
self
.
sales_and_purchase_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
# XXX would require to go to confirmed state first
# self.failIfUserCanPassWorkflowTransition(user
name
,
# self.failIfUserCanPassWorkflowTransition(user
_id
,
# 'start_action',
# transaction)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
# TODO
### self.failUnlessUserCanPassWorkflowTransition(user
name
,
### self.failUnlessUserCanPassWorkflowTransition(user
_id
,
### 'delete_action',
### transaction)
...
...
@@ -1397,55 +1414,55 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# only accountant can modify
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
# only accountant can "stop"
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
transaction
.
stop
()
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# nobody can modify
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
# in started state, we can modify again, and go back to stopped state
...
...
@@ -1453,9 +1470,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
...
...
@@ -1464,11 +1481,13 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
# only accounting_manager can validate
self
.
failUnlessUserCanPassWorkflowTransition
(
self
.
accounting_manager_reference
,
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
failUnlessUserCanPassWorkflowTransition
(
accounting_manager_id
,
'deliver_action'
,
transaction
)
if
self
.
restricted_security
:
self
.
failIfUserCanPassWorkflowTransition
(
self
.
accounting_agent_reference
,
accounting_agent_id
,
=
self
.
_getUserIdList
([
self
.
accounting_agent_reference
])
self
.
failIfUserCanPassWorkflowTransition
(
accounting_agent_id
,
'deliver_action'
,
transaction
)
...
...
@@ -1478,47 +1497,47 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
start_date
=
DateTime
(
2001
,
01
,
01
),
stop_date
=
DateTime
(
2001
,
01
,
01
))
self
.
assertEqual
(
'draft'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'start_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'plan_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'confirm_action'
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
# TODO
### self.failUnlessUserCanPassWorkflowTransition(user
name
,
### self.failUnlessUserCanPassWorkflowTransition(user
_id
,
### 'delete_action',
### transaction)
...
...
@@ -1527,55 +1546,55 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# only accountant can modify
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
# only accountant can "stop"
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
transaction
.
stop
()
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
for
user
name
in
self
.
all_username_list
:
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
# everybody can view
self
.
assertUserCanViewDocument
(
user
name
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
transaction
)
self
.
assertUserCanViewDocument
(
user
_id
,
transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
transaction
)
# nobody can modify
self
.
failIfUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
name
,
transaction
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failIfUserCanAddDocument
(
user
_id
,
transaction
)
if
self
.
restricted_security
:
for
user
name
in
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
-
self
.
accountant_username_list
):
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'deliver_action'
,
transaction
)
self
.
failIfUserCanPassWorkflowTransition
(
user
name
,
self
.
failIfUserCanPassWorkflowTransition
(
user
_id
,
'cancel_action'
,
transaction
)
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'restart_action'
,
transaction
)
# in started state, we can modify again, and go back to stopped state
...
...
@@ -1583,9 +1602,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'started'
,
transaction
.
getSimulationState
())
self
.
tic
()
for
user
name
in
self
.
accountant_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
accountant_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
transaction
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'stop_action'
,
transaction
)
...
...
@@ -1594,11 +1613,13 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self
.
assertEqual
(
'stopped'
,
transaction
.
getSimulationState
())
# only accounting_manager can validate
self
.
failUnlessUserCanPassWorkflowTransition
(
self
.
accounting_manager_reference
,
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
failUnlessUserCanPassWorkflowTransition
(
accounting_manager_id
,
'deliver_action'
,
transaction
)
if
self
.
restricted_security
:
self
.
failIfUserCanPassWorkflowTransition
(
self
.
accounting_agent_reference
,
accounting_agent_id
,
=
self
.
_getUserIdList
([
self
.
accounting_agent_reference
])
self
.
failIfUserCanPassWorkflowTransition
(
accounting_agent_id
,
'deliver_action'
,
transaction
)
...
...
@@ -1607,13 +1628,14 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# done from unrestricted code, so no problem)
balance_transaction
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Balance Transaction'
)
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
balance_transaction
)
self
.
assertUserCanAccessDocument
(
user
name
,
balance_transaction
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
balance_transaction
)
self
.
assertUserCanAccessDocument
(
user
_id
,
balance_transaction
)
def
stepAccountingTransaction_getCausalityGroupedAccountingTransactionList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
_loginAsUser
(
self
.
accounting_manager_reference
)
accounting_manager_id
,
=
self
.
_getUserIdList
([
self
.
accounting_manager_reference
])
self
.
_loginAsUser
(
accounting_manager_id
)
accounting_transaction_x_related_to_a
=
self
.
portal
.
\
accounting_module
.
newContent
(
portal_type
=
'Accounting Transaction'
,
...
...
@@ -1685,11 +1707,11 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def
stepAddAssignments
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# for now, anybody can add assignements
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
assertTrue
(
'Assignment'
in
person
.
getVisibleAllowedContentTypeList
())
self
.
failUnlessUserCanAddDocument
(
user
name
,
person
)
self
.
failUnlessUserCanAddDocument
(
user
_id
,
person
)
def
stepAssignmentTI
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
ti
=
self
.
getTypesTool
().
getTypeInfo
(
'Assignment'
)
...
...
@@ -1701,9 +1723,9 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# everybody can open assignments in express
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
)
for
user
name
in
self
.
all_username_list
:
self
.
failUnlessUserCanModifyDocument
(
user
name
,
assignment
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
failUnlessUserCanModifyDocument
(
user
_id
,
assignment
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
_id
,
'open_action'
,
assignment
)
# }}}
...
...
@@ -1711,106 +1733,106 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# {{{ Trade
def
stepViewAcessAddPurchaseTradeCondition
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
purchase_trade_condition_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
tc
=
module
.
newContent
(
portal_type
=
'Purchase Trade Condition'
)
self
.
assertUserCanViewDocument
(
user
name
,
tc
)
self
.
assertUserCanViewDocument
(
user
_id
,
tc
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'validate_action'
,
tc
)
user
_id
,
'validate_action'
,
tc
)
self
.
portal
.
portal_workflow
.
doActionFor
(
tc
,
'validate_action'
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'invalidate_action'
,
tc
)
user
_id
,
'invalidate_action'
,
tc
)
def
stepViewAccessAddSaleTradeCondition
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
sale_trade_condition_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
tc
=
module
.
newContent
(
portal_type
=
'Sale Trade Condition'
)
self
.
assertUserCanViewDocument
(
user
name
,
tc
)
self
.
assertUserCanViewDocument
(
user
_id
,
tc
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'validate_action'
,
tc
)
user
_id
,
'validate_action'
,
tc
)
self
.
portal
.
portal_workflow
.
doActionFor
(
tc
,
'validate_action'
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'invalidate_action'
,
tc
)
user
_id
,
'invalidate_action'
,
tc
)
def
stepViewAccessAddSaleOrder
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
sale_order_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
order
=
module
.
newContent
(
portal_type
=
'Sale Order'
)
self
.
assertUserCanViewDocument
(
user
name
,
order
)
self
.
assertUserCanViewDocument
(
user
_id
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'plan_action'
,
order
)
user
_id
,
'plan_action'
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'confirm_action'
,
order
)
user
_id
,
'confirm_action'
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'cancel_action'
,
order
)
user
_id
,
'cancel_action'
,
order
)
order
.
confirm
()
self
.
assertEqual
(
'confirmed'
,
order
.
getSimulationState
())
self
.
assertUserCanViewDocument
(
user
name
,
order
)
self
.
failIfUserCanModifyDocument
(
user
name
,
order
)
self
.
assertUserCanViewDocument
(
user
_id
,
order
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
order
)
def
stepViewAccessAddSalePackingList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
sale_packing_list_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
pl
=
module
.
newContent
(
portal_type
=
'Sale Packing List'
)
self
.
assertUserCanViewDocument
(
user
name
,
pl
)
self
.
assertUserCanViewDocument
(
user
_id
,
pl
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'confirm_action'
,
pl
)
user
_id
,
'confirm_action'
,
pl
)
def
stepViewAccessPurchaseOrder
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
purchase_order_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
order
=
module
.
newContent
(
portal_type
=
'Purchase Order'
)
self
.
assertUserCanViewDocument
(
user
name
,
order
)
self
.
assertUserCanViewDocument
(
user
_id
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'plan_action'
,
order
)
user
_id
,
'plan_action'
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'confirm_action'
,
order
)
user
_id
,
'confirm_action'
,
order
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'cancel_action'
,
order
)
user
_id
,
'cancel_action'
,
order
)
order
.
confirm
()
self
.
assertEqual
(
'confirmed'
,
order
.
getSimulationState
())
self
.
assertUserCanViewDocument
(
user
name
,
order
)
self
.
failIfUserCanModifyDocument
(
user
name
,
order
)
self
.
assertUserCanViewDocument
(
user
_id
,
order
)
self
.
failIfUserCanModifyDocument
(
user
_id
,
order
)
def
stepPurchasePackingList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
module
=
self
.
portal
.
purchase_packing_list_module
for
user
name
in
self
.
all_username_list
:
self
.
assertUserCanViewDocument
(
user
name
,
module
)
self
.
assertUserCanAccessDocument
(
user
name
,
module
)
for
user
name
in
self
.
sales_and_purchase_username_list
:
self
.
assertUserCanAddDocument
(
user
name
,
module
)
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
assertUserCanViewDocument
(
user
_id
,
module
)
self
.
assertUserCanAccessDocument
(
user
_id
,
module
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
sales_and_purchase_username_list
)
:
self
.
assertUserCanAddDocument
(
user
_id
,
module
)
self
.
_loginAsUser
(
user
_id
)
pl
=
module
.
newContent
(
portal_type
=
'Purchase Packing List'
)
self
.
assertUserCanViewDocument
(
user
name
,
pl
)
self
.
assertUserCanViewDocument
(
user
_id
,
pl
)
self
.
failUnlessUserCanPassWorkflowTransition
(
user
name
,
'confirm_action'
,
pl
)
user
_id
,
'confirm_action'
,
pl
)
# }}}
# web
...
...
@@ -1832,7 +1854,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
"""
portal_contributions
=
self
.
portal
.
portal_contributions
checkPermission
=
self
.
portal
.
portal_membership
.
checkPermission
for
user
name
in
self
.
all_username_list
:
self
.
_loginAsUser
(
user
name
)
for
user
_id
in
self
.
_getUserIdList
(
self
.
all_username_list
)
:
self
.
_loginAsUser
(
user
_id
)
self
.
assertEqual
(
True
,
\
checkPermission
(
'Modify portal content'
,
portal_contributions
))
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