Commit 32cc66e0 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Instance Tree security

parent f18fcc3b
...@@ -441,11 +441,9 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin): ...@@ -441,11 +441,9 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin):
portal_type='Instance Tree', reference=reference) portal_type='Instance Tree', reference=reference)
subscription.updateLocalRolesOnSecurityGroups() subscription.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(subscription, [self.user_id, reference, self.assertSecurityGroup(subscription, [self.user_id, reference], False)
'G-COMPANY'], False)
self.assertRoles(subscription, reference, ['Assignee']) self.assertRoles(subscription, reference, ['Assignee'])
self.assertRoles(subscription, self.user_id, ['Owner']) self.assertRoles(subscription, self.user_id, ['Owner'])
self.assertRoles(subscription, 'G-COMPANY', ['Assignor'])
def test_CustomOfTheInstanceTree(self): def test_CustomOfTheInstanceTree(self):
customer_reference = 'TESTPERSON-%s' % self.generateNewId() customer_reference = 'TESTPERSON-%s' % self.generateNewId()
...@@ -458,67 +456,27 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin): ...@@ -458,67 +456,27 @@ class TestInstanceTree(TestSlapOSGroupRoleSecurityMixin):
subscription.updateLocalRolesOnSecurityGroups() subscription.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(subscription, [self.user_id, reference, self.assertSecurityGroup(subscription, [self.user_id, reference,
customer.getUserId(), 'G-COMPANY'], False) customer.getUserId()], False)
self.assertRoles(subscription, reference, ['Assignee']) self.assertRoles(subscription, reference, ['Assignee'])
self.assertRoles(subscription, customer.getUserId(), ['Assignee']) self.assertRoles(subscription, customer.getUserId(), ['Assignee'])
self.assertRoles(subscription, self.user_id, ['Owner']) self.assertRoles(subscription, self.user_id, ['Owner'])
self.assertRoles(subscription, 'G-COMPANY', ['Assignor'])
def test_ProjectMember(self): def test_ProjectMember(self):
project = self.addProject() project = self.addProject()
person = self.makePerson(project, user=1)
reference = 'TESTHS-%s' % self.generateNewId() reference = 'TESTHS-%s' % self.generateNewId()
subscription = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', reference=reference,
title=reference,
destination_section=person.getRelativeUrl())
project = self.portal.project_module.newContent( project = self.portal.project_module.newContent(
portal_type='Project') portal_type='Project')
self.tic()
self.login(person.getUserId())
subscription.InstanceTree_createMovement(
destination_project=project.getRelativeUrl())
self.login()
self.tic()
subscription.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(subscription, [self.user_id, reference,
person.getUserId(), 'G-COMPANY', project.getReference()], False)
self.assertRoles(subscription, reference, ['Assignee'])
self.assertRoles(subscription, person.getUserId(), ['Assignee'])
self.assertRoles(subscription, self.user_id, ['Owner'])
self.assertRoles(subscription, 'G-COMPANY', ['Assignor'])
self.assertRoles(subscription, project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
reference = 'TESTHS-%s' % self.generateNewId()
subscription = self.portal.instance_tree_module.newContent( subscription = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree', reference=reference, portal_type='Instance Tree', reference=reference,
title=reference, follow_up_value=project)
destination_section=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference="TESTO-%s" % self.generateNewId())
self.tic()
self.login(person.getUserId())
subscription.InstanceTree_createMovement(
destination=organisation.getRelativeUrl())
self.login()
self.tic()
subscription.updateLocalRolesOnSecurityGroups() subscription.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(subscription, [self.user_id, reference, self.assertSecurityGroup(subscription, [self.user_id, reference,
person.getUserId(), 'G-COMPANY', organisation.getReference()], False) '%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference()], False)
self.assertRoles(subscription, reference, ['Assignee']) self.assertRoles(subscription, reference, ['Assignee'])
self.assertRoles(subscription, person.getUserId(), ['Assignee'])
self.assertRoles(subscription, self.user_id, ['Owner']) self.assertRoles(subscription, self.user_id, ['Owner'])
self.assertRoles(subscription, 'G-COMPANY', ['Assignor']) self.assertRoles(subscription, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(subscription, organisation.getReference(), ['Assignee']) self.assertRoles(subscription, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
class TestInstanceTreeModule(TestSlapOSGroupRoleSecurityMixin): class TestInstanceTreeModule(TestSlapOSGroupRoleSecurityMixin):
...@@ -526,11 +484,11 @@ class TestInstanceTreeModule(TestSlapOSGroupRoleSecurityMixin): ...@@ -526,11 +484,11 @@ class TestInstanceTreeModule(TestSlapOSGroupRoleSecurityMixin):
module = self.portal.instance_tree_module module = self.portal.instance_tree_module
self.changeOwnership(module) self.changeOwnership(module)
self.assertSecurityGroup(module, self.assertSecurityGroup(module,
['G-COMPANY', 'R-COMPUTER', 'R-MEMBER', 'R-INSTANCE', self.user_id], False) ['F-PRODUCTION*', 'R-COMPUTER', 'F-CUSTOMER', 'R-INSTANCE', self.user_id], False)
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author']) self.assertRoles(module, 'F-CUSTOMER', ['Auditor', 'Author'])
self.assertRoles(module, 'R-COMPUTER', ['Auditor']) self.assertRoles(module, 'R-COMPUTER', ['Auditor'])
self.assertRoles(module, 'R-INSTANCE', ['Auditor']) self.assertRoles(module, 'R-INSTANCE', ['Auditor'])
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author']) self.assertRoles(module, 'F-PRODUCTION*', ['Auditor'])
self.assertRoles(module, self.user_id, ['Owner']) self.assertRoles(module, self.user_id, ['Owner'])
class TestOrganisation(TestSlapOSGroupRoleSecurityMixin): class TestOrganisation(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