Commit 7385c674 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Computer Network local roles

parent bd097b34
......@@ -134,9 +134,10 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin):
class TestComputerModel(TestSlapOSGroupRoleSecurityMixin):
document_portal_type = 'Computer Model'
def test_default(self):
model = self.portal.computer_model_module.newContent(
portal_type='Computer Model')
model = self.portal.getDefaultModuleValue(self.document_portal_type).newContent(
portal_type=self.document_portal_type)
model.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(model,
['R-SHADOW-PERSON', self.user_id], False)
......@@ -145,8 +146,8 @@ class TestComputerModel(TestSlapOSGroupRoleSecurityMixin):
def test_ProjectMember(self):
project = self.addProject()
compute_node = self.portal.computer_model_module.newContent(
portal_type='Computer Model',
compute_node = self.portal.getDefaultModuleValue(self.document_portal_type).newContent(
portal_type=self.document_portal_type,
follow_up_value=project)
compute_node.updateLocalRolesOnSecurityGroups()
......@@ -202,79 +203,19 @@ class TestComputeNodeModule(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(module, self.user_id, ['Owner'])
class TestComputerNetwork(TestSlapOSGroupRoleSecurityMixin):
class TestComputerNetwork(TestComputerModel):
document_portal_type = 'Computer Network'
def test_ProjectMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
source_administration=person.getRelativeUrl())
project = self.portal.project_module.newContent(
portal_type='Project')
self.tic()
self.login(person.getUserId())
network.ComputerNetwork_createMovement(
destination_project=project.getRelativeUrl())
self.login()
self.tic()
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id, person.getUserId(),
project.getReference()], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Owner'])
self.assertRoles(network, person.getUserId(), ['Assignee'])
self.assertRoles(network, project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network',
source_administration=person.getRelativeUrl())
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference="TESTO-%s" % self.generateNewId())
self.tic()
self.login(person.getUserId())
network.ComputerNetwork_createMovement(
destination_section=organisation.getRelativeUrl())
self.login()
self.tic()
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id, person.getUserId(),
organisation.getReference()], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Owner'])
self.assertRoles(network, person.getUserId(), ['Assignee'])
self.assertRoles(network, organisation.getReference(), ['Assignee'])
def test_GroupCompany(self):
network = self.portal.computer_network_module.newContent(
portal_type='Computer Network')
network.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(network,
['G-COMPANY', 'R-SHADOW-PERSON', self.user_id], False)
self.assertRoles(network, 'G-COMPANY', ['Assignor'])
self.assertRoles(network, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(network, self.user_id, ['Owner'])
class TestComputerNetworkModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.computer_network_module
self.changeOwnership(module)
self.assertSecurityGroup(module,
['G-COMPANY', 'R-MEMBER', 'R-SHADOW-PERSON', self.user_id], False)
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author'])
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author'])
['F-PRODUCTION*', 'F-CUSTOMER', 'R-SHADOW-PERSON', self.user_id],
False)
self.assertRoles(module, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(module, 'F-PRODUCTION*', ['Auditor', 'Author'])
self.assertRoles(module, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(module, 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