Commit bd097b34 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Computer Model local roles

parent 500f0ccd
<local_roles_item> <local_roles_item>
<local_roles> <local_roles>
<role id='G-COMPANY'> <role id='F-CUSTOMER'>
<item>Auditor</item> <item>Auditor</item>
<item>Author</item>
</role> </role>
<role id='R-MEMBER'> <role id='F-PRODUCTION*'>
<item>Auditor</item> <item>Auditor</item>
<item>Author</item> <item>Author</item>
</role> </role>
<role id='R-SHADOW-PERSON'>
<item>Auditor</item>
</role>
</local_roles> </local_roles>
<local_role_group_ids> <local_role_group_ids>
<local_role_group_id id='group'> <local_role_group_id id='function'>
<principal id='G-COMPANY'>Auditor</principal> <principal id='F-CUSTOMER'>Auditor</principal>
<principal id='G-COMPANY'>Author</principal>
</local_role_group_id> </local_role_group_id>
<local_role_group_id id='user'> <local_role_group_id id='shadow'>
<principal id='R-MEMBER'>Auditor</principal> <principal id='R-SHADOW-PERSON'>Auditor</principal>
<principal id='R-MEMBER'>Author</principal>
</local_role_group_id> </local_role_group_id>
</local_role_group_ids> </local_role_group_ids>
</local_roles_item> </local_roles_item>
\ No newline at end of file
<type_roles> <type_roles>
<role id='Auditor; Author'> <role id='Auditor'>
<property id='title'>Group Company</property>
<multi_property id='categories'>local_role_group/group</multi_property>
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Auditor; Author'>
<property id='title'>Member</property> <property id='title'>Member</property>
<multi_property id='categories'>local_role_group/user</multi_property> <multi_property id='categories'>local_role_group/function</multi_property>
<multi_property id='category'>role/member</multi_property> <multi_property id='category'>function/customer</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Person Shadow</property>
<multi_property id='categories'>local_role_group/shadow</multi_property>
<multi_property id='category'>role/shadow/person</multi_property>
<multi_property id='base_category'>role</multi_property> <multi_property id='base_category'>role</multi_property>
</role> </role>
<role id='Auditor; Author'>
<property id='title'>Production</property>
<multi_property id='category'>function/production*</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
</type_roles> </type_roles>
\ No newline at end of file
<type_roles> <type_roles>
<role id='Auditor'>
<property id='title'>Person Shadow</property>
<multi_property id='categories'>local_role_group/shadow</multi_property>
<multi_property id='category'>role/shadow/person</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Project Customer</property>
<property id='description'>XXX add local role group</property>
<property id='condition'>python: context.getFollowUp("") != ""</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/customer</multi_property>
<multi_property id='base_category'>follow_up</multi_property>
</role>
<role id='Assignee'> <role id='Assignee'>
<property id='title'>Compute Node Agent</property> <property id='title'>Project Production Agent</property>
<property id='description'>Monovalued role</property> <property id='description'>XXX add local role group</property>
<property id='condition'>python: context.getFollowUp("") != ""</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='categories'>local_role_group/user</multi_property> <multi_property id='category'>function/production/agent</multi_property>
<multi_property id='base_category'>source_administration</multi_property> <multi_property id='base_category'>follow_up</multi_property>
</role> </role>
<role id='Assignor'> <role id='Assignor'>
<property id='title'>Group company</property> <property id='title'>Project Production Manager</property>
<multi_property id='categories'>local_role_group/group</multi_property> <property id='description'>XXX add local role group</property>
<multi_property id='category'>group/company</multi_property> <property id='condition'>python: context.getFollowUp("") != ""</property>
<multi_property id='base_category'>group</multi_property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/production/manager</multi_property>
<multi_property id='base_category'>follow_up</multi_property>
</role> </role>
</type_roles> </type_roles>
\ No newline at end of file
...@@ -134,36 +134,45 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin): ...@@ -134,36 +134,45 @@ class TestComputeNode(TestSlapOSGroupRoleSecurityMixin):
class TestComputerModel(TestSlapOSGroupRoleSecurityMixin): class TestComputerModel(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self): def test_default(self):
model = self.portal.computer_model_module.newContent( model = self.portal.computer_model_module.newContent(
portal_type='Computer Model') portal_type='Computer Model')
model.updateLocalRolesOnSecurityGroups() model.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(model, self.assertSecurityGroup(model,
['G-COMPANY', self.user_id], False) ['R-SHADOW-PERSON', self.user_id], False)
self.assertRoles(model, 'G-COMPANY', ['Assignor']) self.assertRoles(model, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(model, self.user_id, ['Owner']) self.assertRoles(model, self.user_id, ['Owner'])
def test_ComputeNodeAgent(self): def test_ProjectMember(self):
reference = 'TESTPERSON-%s' % self.generateNewId() project = self.addProject()
person = self.portal.person_module.newContent(portal_type='Person', compute_node = self.portal.computer_model_module.newContent(
reference=reference)
model = self.portal.computer_model_module.newContent(
portal_type='Computer Model', portal_type='Computer Model',
source_administration=person.getRelativeUrl()) follow_up_value=project)
model.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(model, compute_node.updateLocalRolesOnSecurityGroups()
['G-COMPANY', self.user_id, person.getUserId()], False) self.assertSecurityGroup(compute_node, [
self.assertRoles(model, person.getUserId(), ['Assignee']) self.user_id,
self.assertRoles(model, self.user_id, ['Owner']) 'R-SHADOW-PERSON',
'%s_F-PRODAGNT' % project.getReference(),
'%s_F-PRODMAN' % project.getReference(),
'%s_F-CUSTOMER' % project.getReference(),
], False)
self.assertRoles(compute_node, self.user_id, ['Owner'])
self.assertRoles(compute_node, 'R-SHADOW-PERSON', ['Auditor'])
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'])
class TestComputerModelModule(TestSlapOSGroupRoleSecurityMixin): class TestComputerModelModule(TestSlapOSGroupRoleSecurityMixin):
def test(self): def test(self):
module = self.portal.computer_model_module module = self.portal.computer_model_module
self.changeOwnership(module) self.changeOwnership(module)
self.assertSecurityGroup(module, self.assertSecurityGroup(module,
['G-COMPANY', 'R-MEMBER', self.user_id], False) ['F-PRODUCTION*', 'F-CUSTOMER', 'R-SHADOW-PERSON', self.user_id],
self.assertRoles(module, 'R-MEMBER', ['Auditor', 'Author']) False)
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author']) 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']) self.assertRoles(module, self.user_id, ['Owner'])
class TestComputerModule(TestSlapOSGroupRoleSecurityMixin): class TestComputerModule(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