Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
5b4d4aa9
Commit
5b4d4aa9
authored
Sep 26, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: fixup rebase
parent
1ef5a5db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
910 deletions
+0
-910
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
...l_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
+0
-910
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
View file @
5b4d4aa9
...
@@ -494,916 +494,6 @@ class TestComputerNetwork(TestComputerModel):
...
@@ -494,916 +494,6 @@ class TestComputerNetwork(TestComputerModel):
document_portal_type
=
'Computer Network'
document_portal_type
=
'Computer Network'
class
TestComputerNetworkModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
computer_network_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-PRODUCTION*'
,
'F-CUSTOMER'
,
'R-SHADOW-PERSON'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestCredentialUpdateModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
credential_update_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
self
.
user_id
,
'R-MEMBER'
,
'G-COMPANY'
],
False
)
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestDataSet
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
data_set
=
self
.
portal
.
data_set_module
.
newContent
(
portal_type
=
'Data Set'
)
data_set
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
data_set
,
[
self
.
user_id
,
'G-COMPANY'
],
False
)
self
.
assertRoles
(
data_set
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
data_set
,
self
.
user_id
,
[
'Owner'
])
class
TestDataSetModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
data_set_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Author'
,
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestInstanceTree
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_RelatedSoftwareInstanceGroup
(
self
):
reference
=
'TESTHS-%s'
%
self
.
generateNewId
()
subscription
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
reference
=
reference
)
subscription
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
subscription
,
[
self
.
user_id
,
reference
],
False
)
self
.
assertRoles
(
subscription
,
reference
,
[
'Assignee'
])
self
.
assertRoles
(
subscription
,
self
.
user_id
,
[
'Owner'
])
def
test_CustomOfTheInstanceTree
(
self
):
customer_reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
customer
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
customer_reference
)
reference
=
'TESTHS-%s'
%
self
.
generateNewId
()
subscription
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
reference
=
reference
,
destination_section
=
customer
.
getRelativeUrl
())
subscription
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
subscription
,
[
self
.
user_id
,
reference
,
customer
.
getUserId
()],
False
)
self
.
assertRoles
(
subscription
,
reference
,
[
'Assignee'
])
self
.
assertRoles
(
subscription
,
customer
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
subscription
,
self
.
user_id
,
[
'Owner'
])
def
test_ProjectMember
(
self
):
project
=
self
.
addProject
()
reference
=
'TESTHS-%s'
%
self
.
generateNewId
()
project
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
)
subscription
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
reference
=
reference
,
follow_up_value
=
project
)
subscription
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
subscription
,
[
self
.
user_id
,
reference
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
'%s_F-PRODMAN'
%
project
.
getReference
()],
False
)
self
.
assertRoles
(
subscription
,
reference
,
[
'Assignee'
])
self
.
assertRoles
(
subscription
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
subscription
,
'%s_F-PRODMAN'
%
project
.
getReference
(),
[
'Assignor'
])
self
.
assertRoles
(
subscription
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
[
'Assignee'
])
class
TestInstanceTreeModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
instance_tree_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-PRODUCTION*'
,
'R-COMPUTER'
,
'F-CUSTOMER'
,
'R-INSTANCE'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-COMPUTER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'R-INSTANCE'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestOrganisation
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
organisation
.
setReference
(
"TESTORG-%s"
%
self
.
generateNewId
())
organisation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
organisation
,
[
'G-COMPANY'
,
self
.
user_id
,
organisation
.
getReference
(),
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
organisation
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
organisation
,
organisation
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
organisation
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
self
.
user_id
,
[
'Owner'
,
'Assignee'
])
def
test_without_reference
(
self
):
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
organisation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
organisation
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
organisation
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
organisation
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
self
.
user_id
,
[
'Owner'
,
'Assignee'
])
def
test_RoleAdmin
(
self
):
organisation
=
self
.
portal
.
organisation_module
.
newContent
(
portal_type
=
'Organisation'
)
organisation
.
setReference
(
"TESTORG-%s"
%
self
.
generateNewId
())
organisation
.
setRole
(
"admin"
)
organisation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
organisation
,
[
'G-COMPANY'
,
self
.
user_id
,
organisation
.
getReference
(),
'R-SHADOW-PERSON'
,
'R-MEMBER'
],
False
)
self
.
assertRoles
(
organisation
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
organisation
,
organisation
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
organisation
,
'R-MEMBER'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
self
.
user_id
,
[
'Owner'
,
'Assignee'
])
def
test_defaultSlapOSOrganisation
(
self
):
# Test to ensure slapos organisation is well configured by default
organisation
=
self
.
portal
.
organisation_module
.
slapos
self
.
changeOwnership
(
organisation
)
organisation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
organisation
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-SHADOW-PERSON'
,
'R-MEMBER'
],
False
)
self
.
assertRoles
(
organisation
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
organisation
,
'R-MEMBER'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
organisation
,
self
.
user_id
,
[
'Owner'
,
'Assignee'
])
class
TestOrganisationModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
organisation_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
'R-COMPUTER'
,
'R-MEMBER'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-COMPUTER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestProjectModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
project_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
'R-COMPUTER'
,
'R-MEMBER'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
True
)
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-COMPUTER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestProject
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_with_user
(
self
):
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
,
user
=
1
)
project
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
,
destination_decision_value
=
person
)
project
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
project
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
(),
project
.
getReference
(),
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
project
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
project
,
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
project
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
project
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
project
,
person
.
getUserId
(),
[
'Assignee'
])
def
test
(
self
):
project
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
)
project
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
project
,
[
'G-COMPANY'
,
self
.
user_id
,
project
.
getReference
(),
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
project
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
project
,
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
project
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
project
,
self
.
user_id
,
[
'Owner'
])
class
TestPerson
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_GroupCompany
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
person
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
person
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
person
,
self
.
user_id
,
[
'Owner'
])
def
test_TheUserHimself
(
self
,
login_portal_type
=
"ERP5 Login"
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
.
newContent
(
portal_type
=
login_portal_type
)
person
.
updateLocalRolesOnSecurityGroups
()
shadow_reference
=
'SHADOW-%s'
%
person
.
getUserId
()
self
.
assertSecurityGroup
(
person
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
(),
shadow_reference
],
False
)
self
.
assertRoles
(
person
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
person
,
person
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
person
,
shadow_reference
,
[
'Auditor'
])
self
.
assertRoles
(
person
,
self
.
user_id
,
[
'Owner'
])
def
test_TheUserHimself_Facebook
(
self
):
self
.
test_TheUserHimself
(
login_portal_type
=
"Facebook Login"
)
def
test_TheUserHimself_Google
(
self
):
self
.
test_TheUserHimself
(
login_portal_type
=
"Google Login"
)
def
test_TheUserHimself_Certificate
(
self
):
self
.
test_TheUserHimself
(
login_portal_type
=
"Certificate Login"
)
def
test_ProjectMember
(
self
,
login_portal_type
=
"ERP5 Login"
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
.
newContent
(
portal_type
=
login_portal_type
)
project
=
self
.
portal
.
project_module
.
newContent
(
portal_type
=
"Project"
)
project
.
validate
()
person
.
newContent
(
portal_type
=
'Assignment'
,
destination_project_value
=
project
).
open
()
self
.
tic
()
person
.
updateLocalRolesOnSecurityGroups
()
shadow_reference
=
'SHADOW-%s'
%
person
.
getUserId
()
self
.
assertSecurityGroup
(
person
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
(),
shadow_reference
,
project
.
getReference
()],
False
)
self
.
assertRoles
(
person
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
person
,
person
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
person
,
shadow_reference
,
[
'Auditor'
])
self
.
assertRoles
(
person
,
project
.
getReference
(),
[
'Auditor'
])
self
.
assertRoles
(
person
,
self
.
user_id
,
[
'Owner'
])
class
TestCertificateLogin
(
TestSlapOSGroupRoleSecurityMixin
):
login_portal_type
=
"Certificate Login"
def
test_PersonCanAccessLoginDocument
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
login
=
person
.
newContent
(
portal_type
=
self
.
login_portal_type
)
person
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
person
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
person
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
def
test_ComputeNodeCanAccessSoftwareInstanceLoginDocument
(
self
):
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
)
login
=
software_instance
.
newContent
(
portal_type
=
self
.
login_portal_type
)
compute_node_reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
edit
(
reference
=
compute_node_reference
)
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
software_instance
.
edit
(
aggregate
=
partition
.
getRelativeUrl
())
compute_node
.
updateLocalRolesOnSecurityGroups
()
software_instance
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
software_instance
.
getUserId
(),
compute_node
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
software_instance
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
login
,
compute_node
.
getUserId
(),
[
'Assignor'
])
def
test_ComputeNodeCanAccessLoginDocument
(
self
):
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
'Compute Node'
)
login
=
compute_node
.
newContent
(
portal_type
=
self
.
login_portal_type
)
compute_node
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
compute_node
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
compute_node
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
def
test_ComputeNodeSourceAdministrationCanAccessLoginDocument
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
'Compute Node'
,
source_administration
=
person
.
getRelativeUrl
())
login
=
compute_node
.
newContent
(
portal_type
=
self
.
login_portal_type
)
compute_node
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
compute_node
.
getUserId
(),
person
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
compute_node
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
login
,
person
.
getUserId
(),
[
'Assignee'
])
def
test_SoftwareInstanceCanAccessLoginDocument
(
self
):
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
)
login
=
software_instance
.
newContent
(
portal_type
=
self
.
login_portal_type
)
software_instance
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
software_instance
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
software_instance
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
class
TestERP5Login
(
TestSlapOSGroupRoleSecurityMixin
):
login_portal_type
=
"ERP5 Login"
def
test_PersonCanAccessLoginDocument
(
self
):
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
login
=
person
.
newContent
(
portal_type
=
self
.
login_portal_type
)
person
.
updateLocalRolesOnSecurityGroups
()
login
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
login
,
[
self
.
user_id
,
person
.
getUserId
()],
False
)
self
.
assertRoles
(
login
,
person
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
login
,
self
.
user_id
,
[
'Owner'
])
class
TestGoogleLogin
(
TestERP5Login
):
login_portal_type
=
"Google Login"
class
TestFacebookLogin
(
TestERP5Login
):
login_portal_type
=
"Facebook Login"
class
TestPersonModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
person_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
'R-MEMBER'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestSlaveInstance
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_default
(
self
):
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
)
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
def
test_CustomerOfTheInstance
(
self
):
customer_reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
customer
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
customer_reference
)
subscription_reference
=
'TESTHS-%s '
%
self
.
generateNewId
()
subscription
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
reference
=
subscription_reference
,
destination_section
=
customer
.
getRelativeUrl
())
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
specialise
=
subscription
.
getRelativeUrl
())
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
customer
.
getUserId
(),
subscription_reference
,
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
customer
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
instance
,
subscription_reference
,
[
'Assignee'
])
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
def
test_ProjectMember
(
self
):
project
=
self
.
addProject
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
follow_up_value
=
project
)
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
self
.
user_id
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
'%s_F-PRODMAN'
%
project
.
getReference
()
],
False
)
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
instance
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
instance
,
'%s_F-PRODMAN'
%
project
.
getReference
(),
[
'Assignor'
])
def
test_SoftwareInstanceWhichProvidesThisSlaveInstance
(
self
):
compute_node_reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
edit
(
reference
=
compute_node_reference
)
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
provider_reference
=
'TESTSI-%s'
%
self
.
generateNewId
()
provider
=
self
.
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
provider
.
edit
(
reference
=
provider_reference
,
aggregate
=
partition
.
getRelativeUrl
())
provider
.
validate
()
self
.
tic
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Slave Instance'
,
aggregate
=
partition
.
getRelativeUrl
())
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
provider
.
getUserId
(),
compute_node
.
getUserId
(),
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
provider
.
getUserId
(),
[
'Assignor'
])
self
.
assertRoles
(
instance
,
compute_node
.
getUserId
(),
[
'Assignor'
])
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
class
TestSoftwareInstallation
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_default
(
self
):
installation
=
self
.
portal
.
software_installation_module
.
newContent
(
portal_type
=
'Software Installation'
)
installation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
installation
,
[
self
.
user_id
],
False
)
self
.
assertRoles
(
installation
,
self
.
user_id
,
[
'Owner'
])
def
test_ComputeNode
(
self
):
compute_node_reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
edit
(
reference
=
compute_node_reference
)
installation
=
self
.
portal
.
software_installation_module
.
newContent
(
portal_type
=
'Software Installation'
,
aggregate
=
compute_node
.
getRelativeUrl
())
installation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
installation
,
[
self
.
user_id
,
compute_node
.
getUserId
()],
False
)
self
.
assertRoles
(
installation
,
compute_node
.
getUserId
(),
[
'Assignor'
])
self
.
assertRoles
(
installation
,
self
.
user_id
,
[
'Owner'
])
def
test_ProjectMember
(
self
):
project
=
self
.
addProject
()
installation
=
self
.
portal
.
software_installation_module
.
newContent
(
portal_type
=
'Software Installation'
,
follow_up_value
=
project
)
installation
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
installation
,
[
self
.
user_id
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
'%s_F-PRODMAN'
%
project
.
getReference
(),
'%s_F-CUSTOMER'
%
project
.
getReference
(),
],
False
)
self
.
assertRoles
(
installation
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
installation
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
installation
,
'%s_F-PRODMAN'
%
project
.
getReference
(),
[
'Assignor'
])
self
.
assertRoles
(
installation
,
'%s_F-CUSTOMER'
%
project
.
getReference
(),
[
'Auditor'
])
class
TestSoftwareInstallationModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
software_installation_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-PRODUCTION*'
,
'F-CUSTOMER'
,
'R-COMPUTER'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'R-COMPUTER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestSoftwareInstance
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_default
(
self
):
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
)
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
def
test_CustomerOfTheInstance
(
self
):
customer_reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
customer
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
customer_reference
)
subscription_reference
=
'TESTHS-%s '
%
self
.
generateNewId
()
subscription
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
reference
=
subscription_reference
,
destination_section
=
customer
.
getRelativeUrl
())
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
specialise
=
subscription
.
getRelativeUrl
())
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
customer
.
getUserId
(),
subscription_reference
,
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
customer
.
getUserId
(),
[
'Assignee'
])
self
.
assertRoles
(
instance
,
subscription_reference
,
[
'Assignee'
])
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
def
test_ProjectMember
(
self
):
project
=
self
.
addProject
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
follow_up_value
=
project
)
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
self
.
user_id
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
'%s_F-PRODMAN'
%
project
.
getReference
(),
],
False
)
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
instance
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
instance
,
'%s_F-PRODMAN'
%
project
.
getReference
(),
[
'Assignor'
])
def
test_ComputeNode
(
self
):
compute_node_reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
edit
(
reference
=
compute_node_reference
)
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
)
self
.
commit
()
instance
=
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
aggregate
=
partition
.
getRelativeUrl
())
instance
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
instance
,
[
compute_node
.
getUserId
(),
self
.
user_id
],
False
)
self
.
assertRoles
(
instance
,
compute_node
.
getUserId
(),
[
'Assignor'
])
self
.
assertRoles
(
instance
,
self
.
user_id
,
[
'Owner'
])
class
TestSoftwareInstanceModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
software_instance_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-PRODUCTION*'
,
'R-COMPUTER'
,
'R-INSTANCE'
,
'F-CUSTOMER'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'R-COMPUTER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'R-INSTANCE'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestSoftwareProduct
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_default
(
self
):
product
=
self
.
portal
.
software_product_module
.
newContent
(
portal_type
=
'Software Product'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_Project
(
self
):
project
=
self
.
addProject
()
product
=
self
.
portal
.
software_product_module
.
newContent
(
portal_type
=
'Software Product'
,
follow_up_value
=
project
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
self
.
user_id
,
'%s_F-CUSTOMER'
%
project
.
getReference
(),
'%s_F-PRODAGNT'
%
project
.
getReference
(),
'%s_F-PRODMAN'
%
project
.
getReference
()],
False
)
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
product
,
'%s_F-PRODMAN'
%
project
.
getReference
(),
[
'Assignor'
])
self
.
assertRoles
(
product
,
'%s_F-PRODAGNT'
%
project
.
getReference
(),
[
'Assignee'
])
self
.
assertRoles
(
product
,
'%s_F-CUSTOMER'
%
project
.
getReference
(),
[
'Auditor'
])
class
TestSoftwareProductModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
software_product_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-PRODUCTION*'
,
'F-CUSTOMER'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestOpenSaleOrderModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
open_sale_order_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestOpenSaleOrder
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_GroupCompany
(
self
):
product
=
self
.
portal
.
open_sale_order_module
.
newContent
(
portal_type
=
'Open Sale Order'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestSalePackingListModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
sale_packing_list_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-MEMBER'
],
False
)
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
])
class
TestSalePackingList
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_GroupCompany
(
self
):
product
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_GroupCustomerSubscription
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
,
destination_decision_value
=
person
,
specialise_value
=
self
.
portal
.
sale_trade_condition_module
.
\
slapos_subscription_trade_condition
,
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
()],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
def
test_GroupCustomerAggregation
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
,
destination_decision_value
=
person
,
specialise_value
=
self
.
portal
.
sale_trade_condition_module
.
\
slapos_aggregated_trade_condition
,
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
()],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
def
test_GroupCustomerAggregatedSubscription
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
,
destination_decision_value
=
person
,
specialise_value
=
self
.
portal
.
sale_trade_condition_module
.
\
slapos_aggregated_subscription_trade_condition
,
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
person
.
getUserId
()],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
class
TestAccountingTransactionModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
accounting_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-ACCOUNTING*'
,
'F-PRODUCTION*'
,
self
.
user_id
,
'R-SHADOW-PERSON'
,
'F-CUSTOMER'
],
True
)
self
.
assertRoles
(
module
,
'F-ACCOUNTING*'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Assignor'
])
self
.
assertRoles
(
module
,
'F-PRODUCTION*'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
'F-CUSTOMER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestAccountingTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Accounting Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Accounting Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestBalanceTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Balance Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Balance Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestPaymentTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
'R-SHADOW-PERSON'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
'R-SHADOW-PERSON'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_UserWithoutLedger
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
edit
(
destination_section_value
=
person
,
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_UserLedger
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
edit
(
destination_section_value
=
person
,
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
shadow_user_id
=
'SHADOW-%s'
%
person
.
getUserId
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
,
person
.
getUserId
(),
shadow_user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
shadow_user_id
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestPurchaseInvoiceTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Purchase Invoice Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Purchase Invoice Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestSaleInvoiceTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
'R-SHADOW-PERSON'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_User
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
)
product
.
edit
(
ledger
=
'automated'
,
destination_section_value
=
person
,
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
self
.
user_id
,
person
.
getUserId
(),
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
self
.
assertRoles
(
product
,
'R-SHADOW-PERSON'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestServiceModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
service_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-MEMBER'
],
True
)
self
.
assertRoles
(
module
,
'G-COMPANY'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-MEMBER'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestService
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_GroupCompany
(
self
):
product
=
self
.
portal
.
service_module
.
newContent
(
portal_type
=
'Service'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-MEMBER'
],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'R-MEMBER'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestAccountModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test
(
self
):
module
=
self
.
portal
.
account_module
self
.
changeOwnership
(
module
)
self
.
assertSecurityGroup
(
module
,
[
'F-ACCOUNTING*'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
module
,
'F-ACCOUNTING*'
,
[
'Auditor'
,
'Author'
])
self
.
assertRoles
(
module
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
module
,
self
.
user_id
,
[
'Owner'
])
class
TestAccount
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction
(
self
):
product
=
self
.
portal
.
account_module
.
newContent
(
portal_type
=
'Account'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
'R-SHADOW-PERSON'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestCurrencyModule
(
TestSlapOSGroupRoleSecurityMixin
):
class
TestCurrencyModule
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_CurrencyModule
(
self
):
def
test_CurrencyModule
(
self
):
...
...
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