Commit 30832018 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Yet a bit more fixes and test

parent 6d709dce
Pipeline #12813 failed with stage
in 0 seconds
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
<role id='Auditor'> <role id='Auditor'>
<property id='title'>Member</property> <property id='title'>Member</property>
<property id='description'>User can only see SlapOS company for invoice purposes.</property> <property id='description'>User can only see SlapOS company for invoice purposes.</property>
<property id='condition'>python: here.getGroup() == "company"</property> <property id='condition'>python: here.getRole() == "admin"</property>
<multi_property id='category'>role/member</multi_property> <multi_property id='category'>role/member</multi_property>
<multi_property id='base_category'>role</multi_property> <multi_property id='base_category'>role</multi_property>
</role> </role>
<role id='Assignee'> <role id='Assignee'>
<property id='title'>Organisation Member</property> <property id='title'>Organisation Member</property>
<property id='condition'>python: here.getReference() is not None</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromSelf</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromSelf</property>
<multi_property id='categories'>local_role_group/organisation</multi_property> <multi_property id='categories'>local_role_group/organisation</multi_property>
<multi_property id='base_category'>destination</multi_property> <multi_property id='base_category'>destination</multi_property>
......
...@@ -465,11 +465,21 @@ class TestOrganisation(TestSlapOSGroupRoleSecurityMixin): ...@@ -465,11 +465,21 @@ class TestOrganisation(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee']) self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee'])
def test_GroupCompany(self): def test_without_reference(self):
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation')
organisation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(organisation,
['G-COMPANY', self.user_id, 'R-SHADOW-PERSON'], False)
self.assertRoles(organisation, 'G-COMPANY', ['Assignor'])
self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee'])
def test_RoleAdmin(self):
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
organisation.setReference("TESTORG-%s" % self.generateNewId()) organisation.setReference("TESTORG-%s" % self.generateNewId())
organisation.setGroup("company") organisation.setRole("admin")
organisation.updateLocalRolesOnSecurityGroups() organisation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(organisation, self.assertSecurityGroup(organisation,
['G-COMPANY', self.user_id, organisation.getReference(), 'R-SHADOW-PERSON', 'R-MEMBER'], False) ['G-COMPANY', self.user_id, organisation.getReference(), 'R-SHADOW-PERSON', 'R-MEMBER'], False)
...@@ -479,6 +489,17 @@ class TestOrganisation(TestSlapOSGroupRoleSecurityMixin): ...@@ -479,6 +489,17 @@ class TestOrganisation(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor']) self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee']) self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee'])
def test_defaultSlapOSOrganisation(self):
# Test to ensure slapos organisation is well configured by default
organisation = self.portal.organisation_module.slapos
organisation.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(organisation,
['G-COMPANY', self.user_id, 'R-SHADOW-PERSON', 'R-MEMBER'], False)
self.assertRoles(organisation, 'G-COMPANY', ['Assignor'])
self.assertRoles(organisation, 'R-MEMBER', ['Auditor'])
self.assertRoles(organisation, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(organisation, self.user_id, ['Owner', 'Assignee'])
class TestOrganisationModule(TestSlapOSGroupRoleSecurityMixin): class TestOrganisationModule(TestSlapOSGroupRoleSecurityMixin):
def test(self): def test(self):
module = self.portal.organisation_module module = self.portal.organisation_module
......
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