Commit 9c9b7298 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Slave Instance local roles

parent 064daeec
......@@ -751,13 +751,12 @@ class TestPersonModule(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(module, self.user_id, ['Owner'])
class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self):
def test_default(self):
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertSecurityGroup(instance, [self.user_id], False)
self.assertRoles(instance, self.user_id, ['Owner'])
def test_CustomerOfTheInstance(self):
......@@ -775,76 +774,28 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
portal_type='Slave Instance', specialise=subscription.getRelativeUrl())
instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', customer.getUserId(),
self.assertSecurityGroup(instance, [customer.getUserId(),
subscription_reference, self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
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()
customer = self.makePerson(project, user=1)
subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference,
destination_section=customer.getRelativeUrl())
project = self.portal.project_module.newContent(
portal_type='Project')
self.tic()
self.login(customer.getUserId())
instance_tree.InstanceTree_createMovement(
destination_project=project.getRelativeUrl())
self.login()
self.tic()
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance', specialise=instance_tree.getRelativeUrl())
instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', customer.getUserId(),
subscription_reference, self.user_id, project.getReference()], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, customer.getUserId(), ['Assignee'])
self.assertRoles(instance, subscription_reference, ['Assignee'])
self.assertRoles(instance, self.user_id, ['Owner'])
self.assertRoles(instance, project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
project = self.addProject()
customer = self.makePerson(project, user=1)
subscription_reference = 'TESTHS-%s ' % self.generateNewId()
instance_tree = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="INSTTREETEST-%s" % self.generateNewId(),
reference=subscription_reference,
destination_section=customer.getRelativeUrl())
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference="TESTO-%s" % self.generateNewId())
self.tic()
self.login(customer.getUserId())
instance_tree.InstanceTree_createMovement(
destination=organisation.getRelativeUrl())
self.login()
self.tic()
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance', specialise=instance_tree.getRelativeUrl())
portal_type='Slave Instance',
follow_up_value=project
)
instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', customer.getUserId(),
subscription_reference, self.user_id, organisation.getReference()], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, customer.getUserId(), ['Assignee'])
self.assertRoles(instance, subscription_reference, ['Assignee'])
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, organisation.getReference(), ['Assignee'])
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()
......@@ -867,9 +818,8 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance', aggregate=partition.getRelativeUrl())
instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', provider.getUserId(),
self.assertSecurityGroup(instance, [provider.getUserId(),
compute_node.getUserId(), self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, provider.getUserId(), ['Assignor'])
self.assertRoles(instance, compute_node.getUserId(), ['Assignor'])
self.assertRoles(instance, self.user_id, ['Owner'])
......
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