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): ...@@ -751,13 +751,12 @@ class TestPersonModule(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(module, self.user_id, ['Owner']) self.assertRoles(module, self.user_id, ['Owner'])
class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin): class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self): def test_default(self):
instance = self.portal.software_instance_module.newContent( instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance') portal_type='Slave Instance')
instance.updateLocalRolesOnSecurityGroups() instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', self.user_id], False) self.assertSecurityGroup(instance, [self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, self.user_id, ['Owner']) self.assertRoles(instance, self.user_id, ['Owner'])
def test_CustomerOfTheInstance(self): def test_CustomerOfTheInstance(self):
...@@ -775,76 +774,28 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -775,76 +774,28 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
portal_type='Slave Instance', specialise=subscription.getRelativeUrl()) portal_type='Slave Instance', specialise=subscription.getRelativeUrl())
instance.updateLocalRolesOnSecurityGroups() instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', customer.getUserId(), self.assertSecurityGroup(instance, [customer.getUserId(),
subscription_reference, self.user_id], False) subscription_reference, self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, customer.getUserId(), ['Assignee']) self.assertRoles(instance, customer.getUserId(), ['Assignee'])
self.assertRoles(instance, subscription_reference, ['Assignee']) self.assertRoles(instance, subscription_reference, ['Assignee'])
self.assertRoles(instance, self.user_id, ['Owner']) self.assertRoles(instance, self.user_id, ['Owner'])
def test_ProjectMember(self): def test_ProjectMember(self):
project = self.addProject() 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( instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance', specialise=instance_tree.getRelativeUrl()) portal_type='Slave Instance',
instance.updateLocalRolesOnSecurityGroups() follow_up_value=project
)
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())
instance.updateLocalRolesOnSecurityGroups() instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', customer.getUserId(), self.assertSecurityGroup(instance, [
subscription_reference, self.user_id, organisation.getReference()], False) self.user_id,
self.assertRoles(instance, 'G-COMPANY', ['Assignor']) '%s_F-PRODAGNT' % project.getReference(),
self.assertRoles(instance, customer.getUserId(), ['Assignee']) '%s_F-PRODMAN' % project.getReference()
self.assertRoles(instance, subscription_reference, ['Assignee']) ], False)
self.assertRoles(instance, self.user_id, ['Owner']) 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): def test_SoftwareInstanceWhichProvidesThisSlaveInstance(self):
compute_node_reference = 'TESTCOMP-%s' % self.generateNewId() compute_node_reference = 'TESTCOMP-%s' % self.generateNewId()
...@@ -867,9 +818,8 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin): ...@@ -867,9 +818,8 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
instance = self.portal.software_instance_module.newContent( instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance', aggregate=partition.getRelativeUrl()) portal_type='Slave Instance', aggregate=partition.getRelativeUrl())
instance.updateLocalRolesOnSecurityGroups() instance.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(instance, ['G-COMPANY', provider.getUserId(), self.assertSecurityGroup(instance, [provider.getUserId(),
compute_node.getUserId(), self.user_id], False) compute_node.getUserId(), self.user_id], False)
self.assertRoles(instance, 'G-COMPANY', ['Assignor'])
self.assertRoles(instance, provider.getUserId(), ['Assignor']) self.assertRoles(instance, provider.getUserId(), ['Assignor'])
self.assertRoles(instance, compute_node.getUserId(), ['Assignor']) self.assertRoles(instance, compute_node.getUserId(), ['Assignor'])
self.assertRoles(instance, self.user_id, ['Owner']) 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