Commit 82644517 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Support Request local roles

parent 49221e1f
<local_roles_item>
<local_roles>
<role id='G-COMPANY'>
<item>Assignor</item>
</role>
<role id='R-MEMBER'>
<item>Auditor</item>
</role>
</local_roles>
<local_role_group_ids>
<local_role_group_id id='group'>
<principal id='G-COMPANY'>Assignor</principal>
</local_role_group_id>
<local_role_group_id id='user'>
<principal id='R-MEMBER'>Auditor</principal>
</local_role_group_id>
......
......@@ -36,6 +36,7 @@
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/production/agent</multi_property>
<multi_property id='base_category'>source_project</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
<role id='Assignor'>
<property id='title'>Source Project Production Manager</property>
......@@ -44,5 +45,6 @@
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/production/manager</multi_property>
<multi_property id='base_category'>source_project</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
</type_roles>
\ No newline at end of file
......@@ -1657,8 +1657,7 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
portal_type='Support Request')
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', self.user_id], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
[self.user_id], False)
self.assertRoles(support_request, self.user_id, ['Owner'])
def test_Customer(self):
......@@ -1671,8 +1670,7 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
)
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', person.getUserId(), self.user_id], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
[person.getUserId(), self.user_id], False)
self.assertRoles(support_request, person.getUserId(), ['Auditor'])
self.assertRoles(support_request, self.user_id, ['Owner'])
......@@ -1682,138 +1680,37 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
assert support_request.getPortalType() == 'Support Request'
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', support_request.Base_getOwnerId(), 'R-MEMBER'], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
[support_request.Base_getOwnerId(), 'R-MEMBER'], False)
self.assertRoles(support_request, support_request.Base_getOwnerId(), ['Owner'])
self.assertRoles(support_request, 'R-MEMBER', ['Auditor'])
self.assertPermissionsOfRole(support_request, 'Auditor',
['Access contents information', 'View'])
def test_ProjectMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
source_administration=person.getRelativeUrl())
project = self.portal.project_module.newContent(
portal_type='Project')
self.tic()
self.login(person.getUserId())
compute_node.ComputeNode_createMovement(
destination=person.getRelativeUrl(),
destination_project=project.getRelativeUrl())
self.login()
self.tic()
support_request = self.portal.support_request_module.newContent(
portal_type='Support Request',
destination_decision_value=person,
aggregate=compute_node.getRelativeUrl()
)
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', person.getUserId(), self.user_id, project.getReference()], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
self.assertRoles(support_request, person.getUserId(), ['Auditor'])
self.assertRoles(support_request, self.user_id, ['Owner'])
self.assertRoles(support_request, project.getReference(), ['Auditor'])
def test_ProjectMember_InstanceTree(self):
project = self.addProject()
person = self.makePerson(project, user=1)
instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent(
portal_type='Project')
self.tic()
self.login(person.getUserId())
instance_tree.InstanceTree_createMovement(
destination_project=project.getRelativeUrl())
self.login()
self.tic()
support_request = self.portal.support_request_module.newContent(
portal_type='Support Request',
destination_decision_value=person,
aggregate=instance_tree.getRelativeUrl()
)
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', person.getUserId(), self.user_id, project.getReference()], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
self.assertRoles(support_request, person.getUserId(), ['Auditor'])
self.assertRoles(support_request, self.user_id, ['Owner'])
self.assertRoles(support_request, project.getReference(), ['Auditor'])
def test_OrganisationMember(self):
def test_SourceProject(self):
project = self.addProject()
person = self.makePerson(project, user=1)
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
source_administration=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference="TESTO-%s" % self.generateNewId())
self.tic()
self.login(person.getUserId())
compute_node.ComputeNode_createMovement(
destination=person.getRelativeUrl(),
destination_section=organisation.getRelativeUrl())
self.login()
self.tic()
support_request = self.portal.support_request_module.newContent(
portal_type='Support Request',
destination_decision_value=person,
aggregate=compute_node.getRelativeUrl()
)
source_project_value=project)
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', person.getUserId(), self.user_id, organisation.getReference()], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
self.assertRoles(support_request, person.getUserId(), ['Auditor'])
self.assertSecurityGroup(support_request, [self.user_id,
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference()], False)
self.assertRoles(support_request, self.user_id, ['Owner'])
self.assertRoles(support_request, organisation.getReference(), ['Auditor'])
self.assertRoles(support_request, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(support_request, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
def test_OrganisationMember_InstanceTree(self):
def test_DestinationProject(self):
project = self.addProject()
person = self.makePerson(project, user=1)
instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
reference="INSTTREETEST-%s" % self.generateNewId(),
title="INSTTREETEST-%s" % self.generateNewId(),
destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference="TESTO-%s" % self.generateNewId())
self.tic()
self.login(person.getUserId())
instance_tree.InstanceTree_createMovement(
destination=organisation.getRelativeUrl())
self.login()
self.tic()
support_request = self.portal.support_request_module.newContent(
portal_type='Support Request',
destination_decision_value=person,
aggregate=instance_tree.getRelativeUrl()
)
destination_project_value=project)
support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request,
['G-COMPANY', person.getUserId(), self.user_id, organisation.getReference()], False)
self.assertRoles(support_request, 'G-COMPANY', ['Assignor'])
self.assertRoles(support_request, person.getUserId(), ['Auditor'])
self.assertSecurityGroup(support_request, [self.user_id,
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference()], False)
self.assertRoles(support_request, self.user_id, ['Owner'])
self.assertRoles(support_request, organisation.getReference(), ['Auditor'])
self.assertRoles(support_request, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(support_request, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
class TestWebPageModule(TestSlapOSGroupRoleSecurityMixin):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment