Commit a3d65815 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Software Installation local roles

parent e9d766d3
......@@ -691,14 +691,12 @@ class TestSlaveInstance(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(instance, self.user_id, ['Owner'])
class TestSoftwareInstallation(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self):
def test_default(self):
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation')
installation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(installation, [self.user_id,
'G-COMPANY'], False)
self.assertRoles(installation, 'G-COMPANY', ['Assignor'])
self.assertSecurityGroup(installation, [self.user_id], False)
self.assertRoles(installation, self.user_id, ['Owner'])
def test_ComputeNode(self):
......@@ -713,98 +711,38 @@ class TestSoftwareInstallation(TestSlapOSGroupRoleSecurityMixin):
installation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(installation, [self.user_id,
'G-COMPANY', compute_node.getUserId()], False)
self.assertRoles(installation, 'G-COMPANY', ['Assignor'])
compute_node.getUserId()], False)
self.assertRoles(installation, compute_node.getUserId(), ['Assignor'])
self.assertRoles(installation, self.user_id, ['Owner'])
def test_ProjectMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
compute_node_reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
compute_node.edit(reference=compute_node_reference,
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()
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation',
aggregate=compute_node.getRelativeUrl())
installation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(installation, [self.user_id,
'G-COMPANY', compute_node.getUserId(), project.getReference()], False)
self.assertRoles(installation, 'G-COMPANY', ['Assignor'])
self.assertRoles(installation, compute_node.getUserId(), ['Assignor'])
self.assertRoles(installation, self.user_id, ['Owner'])
self.assertRoles(installation, project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
compute_node_reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
compute_node.edit(reference=compute_node_reference,
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()
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation',
aggregate=compute_node.getRelativeUrl())
follow_up_value=project)
installation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(installation, [self.user_id,
'G-COMPANY', compute_node.getUserId(), organisation.getReference()], False)
self.assertRoles(installation, 'G-COMPANY', ['Assignor'])
self.assertRoles(installation, compute_node.getUserId(), ['Assignor'])
self.assertSecurityGroup(installation, [
self.user_id,
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference(),
'%s_F-CUSTOMER' % project.getReference(),
], False)
self.assertRoles(installation, self.user_id, ['Owner'])
self.assertRoles(installation, organisation.getReference(), ['Assignee'])
def test_ProviderOfTheInstallation(self):
provider_reference = 'TESTPERSON-%s' % self.generateNewId()
provider = self.portal.person_module.newContent(
portal_type='Person', reference=provider_reference)
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation',
destination_section=provider.getRelativeUrl())
installation.updateLocalRolesOnSecurityGroups()
self.assertRoles(installation, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
self.assertRoles(installation, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(installation, '%s_F-CUSTOMER' % project.getReference(), ['Auditor'])
self.assertSecurityGroup(installation, [self.user_id,
'G-COMPANY', provider.getUserId()], False)
self.assertRoles(installation, 'G-COMPANY', ['Assignor'])
self.assertRoles(installation, provider.getUserId(), ['Assignee'])
self.assertRoles(installation, self.user_id, ['Owner'])
class TestSoftwareInstallationModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.software_installation_module
self.changeOwnership(module)
self.assertSecurityGroup(module,
['G-COMPANY', 'R-MEMBER', 'R-COMPUTER', self.user_id], False)
['F-PRODUCTION*', 'F-CUSTOMER', 'R-COMPUTER', self.user_id], False)
self.assertRoles(module, 'R-COMPUTER', ['Auditor'])
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author'])
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author'])
self.assertRoles(module, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(module, 'F-PRODUCTION*', ['Auditor', 'Author'])
self.assertRoles(module, self.user_id, ['Owner'])
class TestSoftwareInstance(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