Commit 500f0ccd authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Regularisation Request local roles

parent d533a344
<local_roles_item> <local_roles_item>
<local_roles> <local_roles>
<role id='G-COMPANY'>
<item>Assignor</item>
</role>
<role id='R-MEMBER'> <role id='R-MEMBER'>
<item>Auditor</item> <item>Auditor</item>
</role> </role>
</local_roles> </local_roles>
<local_role_group_ids> <local_role_group_ids>
<local_role_group_id id='group'>
<principal id='G-COMPANY'>Assignor</principal>
</local_role_group_id>
<local_role_group_id id='user'> <local_role_group_id id='user'>
<principal id='R-MEMBER'>Auditor</principal> <principal id='R-MEMBER'>Auditor</principal>
</local_role_group_id> </local_role_group_id>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/production/agent</multi_property> <multi_property id='category'>function/production/agent</multi_property>
<multi_property id='base_category'>source_project</multi_property> <multi_property id='base_category'>source_project</multi_property>
<multi_property id='base_category'>function</multi_property>
</role> </role>
<role id='Assignor'> <role id='Assignor'>
<property id='title'>Source Project Production Manager</property> <property id='title'>Source Project Production Manager</property>
...@@ -44,5 +45,6 @@ ...@@ -44,5 +45,6 @@
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property> <property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='category'>function/production/manager</multi_property> <multi_property id='category'>function/production/manager</multi_property>
<multi_property id='base_category'>source_project</multi_property> <multi_property id='base_category'>source_project</multi_property>
<multi_property id='base_category'>function</multi_property>
</role> </role>
</type_roles> </type_roles>
\ No newline at end of file
...@@ -1494,9 +1494,11 @@ class TestSupportRequestModule(TestSlapOSGroupRoleSecurityMixin): ...@@ -1494,9 +1494,11 @@ class TestSupportRequestModule(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(module, self.user_id, ['Owner']) self.assertRoles(module, self.user_id, ['Owner'])
class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
def test_GroupCompany(self): ticket_portal_type = 'Support Request'
support_request = self.portal.support_request_module.newContent(
portal_type='Support Request') def test_default(self):
support_request = self.portal.getDefaultModuleValue(self.ticket_portal_type).newContent(
portal_type=self.ticket_portal_type)
support_request.updateLocalRolesOnSecurityGroups() support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request, self.assertSecurityGroup(support_request,
[self.user_id], False) [self.user_id], False)
...@@ -1506,8 +1508,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -1506,8 +1508,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
reference = 'TESTPERSON-%s' % self.generateNewId() reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
reference=reference) reference=reference)
support_request = self.portal.support_request_module.newContent( support_request = self.portal.getDefaultModuleValue(self.ticket_portal_type).newContent(
portal_type='Support Request', portal_type=self.ticket_portal_type,
destination_decision_value=person, destination_decision_value=person,
) )
support_request.updateLocalRolesOnSecurityGroups() support_request.updateLocalRolesOnSecurityGroups()
...@@ -1517,9 +1519,11 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -1517,9 +1519,11 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(support_request, self.user_id, ['Owner']) self.assertRoles(support_request, self.user_id, ['Owner'])
def test_Template(self): def test_Template(self):
support_request = self.portal.restrictedTraverse( support_request = self.portal.restrictedTraverse(getattr(
self.portal.portal_preferences.getPreferredSupportRequestTemplate()) self.portal.portal_preferences,
assert support_request.getPortalType() == 'Support Request' 'getPreferred%sTemplate' % self.ticket_portal_type.title().replace(' ', '')
)())
assert support_request.getPortalType() == self.ticket_portal_type
support_request.updateLocalRolesOnSecurityGroups() support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request, self.assertSecurityGroup(support_request,
[support_request.Base_getOwnerId(), 'R-MEMBER'], False) [support_request.Base_getOwnerId(), 'R-MEMBER'], False)
...@@ -1530,8 +1534,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -1530,8 +1534,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
def test_SourceProject(self): def test_SourceProject(self):
project = self.addProject() project = self.addProject()
support_request = self.portal.support_request_module.newContent( support_request = self.portal.getDefaultModuleValue(self.ticket_portal_type).newContent(
portal_type='Support Request', portal_type=self.ticket_portal_type,
source_project_value=project) source_project_value=project)
support_request.updateLocalRolesOnSecurityGroups() support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request, [self.user_id, self.assertSecurityGroup(support_request, [self.user_id,
...@@ -1543,8 +1547,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin): ...@@ -1543,8 +1547,8 @@ class TestSupportRequest(TestSlapOSGroupRoleSecurityMixin):
def test_DestinationProject(self): def test_DestinationProject(self):
project = self.addProject() project = self.addProject()
support_request = self.portal.support_request_module.newContent( support_request = self.portal.getDefaultModuleValue(self.ticket_portal_type).newContent(
portal_type='Support Request', portal_type=self.ticket_portal_type,
destination_project_value=project) destination_project_value=project)
support_request.updateLocalRolesOnSecurityGroups() support_request.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(support_request, [self.user_id, self.assertSecurityGroup(support_request, [self.user_id,
...@@ -1722,48 +1726,13 @@ class TestRegularisationRequestModule(TestSlapOSGroupRoleSecurityMixin): ...@@ -1722,48 +1726,13 @@ class TestRegularisationRequestModule(TestSlapOSGroupRoleSecurityMixin):
module = self.portal.regularisation_request_module module = self.portal.regularisation_request_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', self.user_id], True)
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author']) self.assertRoles(module, 'F-PRODUCTION*', ['Auditor'])
self.assertRoles(module, 'R-MEMBER', ['Auditor']) self.assertRoles(module, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(module, self.user_id, ['Owner']) self.assertRoles(module, self.user_id, ['Owner'])
class TestRegularisationRequest(TestSlapOSGroupRoleSecurityMixin): class TestRegularisationRequest(TestSupportRequest):
def test_GroupCompany(self): ticket_portal_type = 'Regularisation Request'
product = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request')
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
self.assertRoles(product, self.user_id, ['Owner'])
def test_Customer(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
product = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request',
destination_decision_value=person,
)
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', person.getUserId(), self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
self.assertRoles(product, person.getUserId(), ['Auditor'])
self.assertRoles(product, self.user_id, ['Owner'])
def test_Template(self):
product = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredRegularisationRequestTemplate())
assert product.getPortalType() == 'Regularisation Request'
product.updateLocalRolesOnSecurityGroups()
self.assertSecurityGroup(product,
['G-COMPANY', product.Base_getOwnerId(), 'R-MEMBER'], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
self.assertRoles(product, product.Base_getOwnerId(), ['Owner'])
self.assertRoles(product, 'R-MEMBER', ['Auditor'])
self.assertPermissionsOfRole(product, 'Auditor',
['Access contents information', 'View'])
class TestInvitationTokenModule(TestSlapOSGroupRoleSecurityMixin): class TestInvitationTokenModule(TestSlapOSGroupRoleSecurityMixin):
def test(self): def test(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