Commit a5ff9282 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Compute Node local roles

parent c14b12a6
...@@ -102,121 +102,36 @@ class TestAssignment(TestSlapOSGroupRoleSecurityMixin): ...@@ -102,121 +102,36 @@ class TestAssignment(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(assignment, self.user_id, ['Owner']) self.assertRoles(assignment, self.user_id, ['Owner'])
class TestComputeNode(TestSlapOSGroupRoleSecurityMixin): class TestComputeNode(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self): def test_default(self):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node') compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node')
compute_node.updateLocalRolesOnSecurityGroups() compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node, self.assertSecurityGroup(compute_node,
['G-COMPANY', self.user_id, compute_node.getUserId()], False) [self.user_id, compute_node.getUserId()], False)
self.assertRoles(compute_node, 'G-COMPANY', ['Assignor'])
self.assertRoles(compute_node, self.user_id, ['Owner']) self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor']) self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
def test_ProjectMember(self): def test_ProjectMember(self):
project = self.addProject() project = self.addProject()
person = self.makePerson(project, user=1)
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
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()
compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node,
['G-COMPANY', self.user_id, person.getUserId(),
project.getReference(), compute_node.getUserId()], False)
self.assertRoles(compute_node, 'G-COMPANY', ['Assignor'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, person.getUserId(), ['Assignee'])
self.assertRoles(compute_node, project.getReference(), ['Assignee'])
def test_OrganisationMember(self):
project = self.addProject()
person = self.makePerson(project, user=1)
compute_node = self.portal.compute_node_module.newContent( compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node', portal_type='Compute Node',
source_administration=person.getRelativeUrl()) follow_up_value=project)
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()
compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node,
['G-COMPANY', self.user_id, person.getUserId(),
organisation.getReference(), compute_node.getUserId()], False)
self.assertRoles(compute_node, 'G-COMPANY', ['Assignor'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, person.getUserId(), ['Assignee'])
self.assertRoles(compute_node, organisation.getReference(), ['Assignee'])
def test_ComputeNodeAgent(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
source_administration=person.getRelativeUrl())
compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node,
[self.user_id, 'G-COMPANY', person.getUserId(), compute_node.getUserId()], False)
self.assertRoles(compute_node, 'G-COMPANY', ['Assignor'])
self.assertRoles(compute_node, person.getUserId(), ['Assignee'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
def test_AllocationScope(self):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node')
# open/public
compute_node.edit(allocation_scope='open/public')
compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node,
[self.user_id, 'G-COMPANY', 'R-SHADOW-PERSON', compute_node.getUserId()], False)
self.assertRoles(compute_node, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
# open/personal
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
compute_node.edit(allocation_scope='open/personal',
source_administration=person.getRelativeUrl()
)
compute_node.updateLocalRolesOnSecurityGroups() compute_node.updateLocalRolesOnSecurityGroups()
shadow_user_id = 'SHADOW-%s' % person.getUserId() self.assertSecurityGroup(compute_node, [
self.user_id,
self.assertSecurityGroup(compute_node, compute_node.getUserId(),
[self.user_id, 'G-COMPANY', shadow_user_id, '%s_F-PRODAGNT' % project.getReference(),
person.getUserId(), compute_node.getUserId()], False) '%s_F-PRODMAN' % project.getReference(),
self.assertRoles(compute_node, shadow_user_id, ['Auditor']) '%s_F-CUSTOMER' % project.getReference(),
'%s_R-INSTANCE' % project.getReference(),
], False)
self.assertRoles(compute_node, self.user_id, ['Owner']) self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor']) self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
self.assertRoles(compute_node, '%s_F-PRODAGNT' % project.getReference(), ['Assignee'])
self.assertRoles(compute_node, '%s_F-PRODMAN' % project.getReference(), ['Assignor'])
self.assertRoles(compute_node, '%s_F-CUSTOMER' % project.getReference(), ['Auditor'])
self.assertRoles(compute_node, '%s_R-INSTANCE' % project.getReference(), ['Auditor'])
def test_selfComputeNode(self):
reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
reference=reference)
compute_node.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(compute_node,
[self.user_id, 'G-COMPANY', compute_node.getUserId()], False)
self.assertRoles(compute_node, compute_node.getUserId(), ['Assignor'])
self.assertRoles(compute_node, self.user_id, ['Owner'])
class TestComputerModel(TestSlapOSGroupRoleSecurityMixin): class TestComputerModel(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self): def test_GroupCompany(self):
......
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