Commit 2d5ce56e authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Event local roles

parent 9c9b7298
......@@ -1594,13 +1594,12 @@ class TestEventModule(TestSlapOSGroupRoleSecurityMixin):
class TestMailMessage(TestSlapOSGroupRoleSecurityMixin):
event_portal_type = 'Mail Message'
def test_GroupCompany(self):
def test_default(self):
product = self.portal.event_module.newContent(
portal_type=self.event_portal_type)
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
[self.user_id], False)
self.assertRoles(product, self.user_id, ['Owner'])
def test_SourceCustomer(self):
......@@ -1613,8 +1612,7 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin):
)
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', person.getUserId(), self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
[person.getUserId(), self.user_id], False)
self.assertRoles(product, person.getUserId(), ['Auditor'])
self.assertRoles(product, self.user_id, ['Owner'])
......@@ -1628,167 +1626,41 @@ class TestMailMessage(TestSlapOSGroupRoleSecurityMixin):
)
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', person.getUserId(), self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
[person.getUserId(), self.user_id], False)
self.assertRoles(product, person.getUserId(), ['Auditor'])
self.assertRoles(product, self.user_id, ['Owner'])
def test_ProjectMember(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())
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()
)
event = self.portal.event_module.newContent(
portal_type=self.event_portal_type,
destination_value=person,
follow_up=support_request.getRelativeUrl()
source_project_value=project
)
event.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(event,
['G-COMPANY', person.getUserId(),
self.user_id, project.getReference()], False)
self.assertRoles(event, 'G-COMPANY', ['Assignor'])
self.assertRoles(event, person.getUserId(), ['Auditor'])
self.assertRoles(event, project.getReference(), ['Auditor'])
self.assertRoles(event, self.user_id, ['Owner'])
def test_ProjectMember_InstanceTreeRequest(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()
)
event = self.portal.event_module.newContent(
portal_type=self.event_portal_type,
destination_value=person,
follow_up=support_request.getRelativeUrl()
)
event.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(event,
['G-COMPANY', person.getUserId(),
self.user_id, project.getReference()], False)
self.assertRoles(event, 'G-COMPANY', ['Assignor'])
self.assertRoles(event, person.getUserId(), ['Auditor'])
self.assertRoles(event, project.getReference(), ['Auditor'])
self.assertSecurityGroup(event, [self.user_id,
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference()], False)
self.assertRoles(event, self.user_id, ['Owner'])
self.assertRoles(event, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(event, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
def test_DestinationProject(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()
)
event = self.portal.event_module.newContent(
portal_type=self.event_portal_type,
destination_value=person,
follow_up=support_request.getRelativeUrl()
destination_project_value=project
)
event.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(event,
['G-COMPANY', person.getUserId(),
self.user_id, organisation.getReference()], False)
self.assertRoles(event, 'G-COMPANY', ['Assignor'])
self.assertRoles(event, person.getUserId(), ['Auditor'])
self.assertRoles(event, organisation.getReference(), ['Auditor'])
self.assertRoles(event, self.user_id, ['Owner'])
def test_OrganisationMember_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())
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()
)
event = self.portal.event_module.newContent(
portal_type=self.event_portal_type,
destination_value=person,
follow_up=support_request.getRelativeUrl()
)
event.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(event,
['G-COMPANY', person.getUserId(),
self.user_id, organisation.getReference()], False)
self.assertRoles(event, 'G-COMPANY', ['Assignor'])
self.assertRoles(event, person.getUserId(), ['Auditor'])
self.assertRoles(event, organisation.getReference(), ['Auditor'])
self.assertSecurityGroup(event, [self.user_id,
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference()], False)
self.assertRoles(event, self.user_id, ['Owner'])
self.assertRoles(event, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(event, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
class TestShortMessage(TestMailMessage):
......
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