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

slapos_erp5: test Regularisation Request local roles

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