Commit af312de9 authored by Romain Courteaud's avatar Romain Courteaud

Configure regularisation request security.

parent 025abe3a
<local_roles_item>
<local_roles>
<role id='G-COMPANY'>
<item>Auditor</item>
<item>Author</item>
</role>
<role id='R-MEMBER'>
<item>Auditor</item>
</role>
<role id='zope'>
<item>Owner</item>
</role>
</local_roles>
</local_roles_item>
\ No newline at end of file
<local_roles_item>
<local_roles>
<role id='G-COMPANY'>
<item>Assignor</item>
</role>
<role id='R-MEMBER'>
<item>Auditor</item>
</role>
<role id='zope'>
<item>Owner</item>
</role>
</local_roles>
</local_roles_item>
\ No newline at end of file
<type_roles>
<role id='Author; Auditor'>
<property id='title'>Group company</property>
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Member</property>
<multi_property id='category'>role/member</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Auditor'>
<property id='title'>Customer</property>
<property id='description'>Monovalued role</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='base_category'>destination_decision</multi_property>
</role>
<role id='Assignor'>
<property id='title'>Group company</property>
<multi_property id='category'>group/company</multi_property>
<multi_property id='base_category'>group</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Member can see template</property>
<property id='condition'>python: here.getRelativeUrl() == here.getPortalObject().portal_preferences.getPreferredRegularisationRequestTemplate()</property>
<multi_property id='category'>role/member</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
</type_roles>
\ No newline at end of file
...@@ -1935,3 +1935,50 @@ class TestBusinessProcess(TestSlapOSGroupRoleSecurityMixin): ...@@ -1935,3 +1935,50 @@ class TestBusinessProcess(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(product, 'G-COMPANY', ['Auditor']) self.assertRoles(product, 'G-COMPANY', ['Auditor'])
self.assertRoles(product, 'R-MEMBER', ['Auditor']) self.assertRoles(product, 'R-MEMBER', ['Auditor'])
self.assertRoles(product, self.user_id, ['Owner']) self.assertRoles(product, self.user_id, ['Owner'])
class TestRegularisationRequestModule(TestSlapOSGroupRoleSecurityMixin):
def test(self):
module = self.portal.regularisation_request_module
self.assertSecurityGroup(module,
['G-COMPANY', 'R-MEMBER', 'zope'], False)
self.assertRoles(module, 'G-COMPANY', ['Auditor', 'Author'])
self.assertRoles(module, 'R-MEMBER', ['Auditor'])
self.assertRoles(module, 'zope', ['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', reference, self.user_id], False)
self.assertRoles(product, 'G-COMPANY', ['Assignor'])
self.assertRoles(product, reference, ['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'])
...@@ -349,6 +349,18 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow( ...@@ -349,6 +349,18 @@ class TestSlapOSLocalPermissionSlapOSInteractionWorkflow(
self.assertSecurityGroup(support_request, ['G-COMPANY', self.user_id, self.assertSecurityGroup(support_request, ['G-COMPANY', self.user_id,
self.person_reference], False) self.person_reference], False)
def test_RegularisationRequest_setDestinationDecision(self):
self._makePerson()
regularisation_request = self.portal.regularisation_request_module.newContent(
portal_type='Regularisation Request')
self.assertSecurityGroup(regularisation_request, ['G-COMPANY', self.user_id], False)
regularisation_request.edit(destination_decision=self.person_user.getRelativeUrl())
transaction.commit()
self.assertSecurityGroup(regularisation_request, ['G-COMPANY', self.user_id,
self.person_reference], False)
def test_Acknowledgement_setDestination(self): def test_Acknowledgement_setDestination(self):
self._makePerson() self._makePerson()
event = self.portal.event_module.newContent( event = self.portal.event_module.newContent(
......
163 164
\ No newline at end of file \ No newline at end of file
...@@ -47,6 +47,8 @@ product_module ...@@ -47,6 +47,8 @@ product_module
purchase_order_module purchase_order_module
purchase_trade_condition_module purchase_trade_condition_module
query_module query_module
regularisation_request_module
regularisation_request_module/slapos_crm_regularisation_request_template
sale_opportunity_module sale_opportunity_module
sale_order_module sale_order_module
sale_packing_list_module sale_packing_list_module
......
...@@ -27,6 +27,7 @@ data_set_module ...@@ -27,6 +27,7 @@ data_set_module
document_ingestion_module document_ingestion_module
document_module document_module
event_module event_module
event_module/slapos_crm_web_message_template
hosting_subscription_module hosting_subscription_module
image_module image_module
inventory_module inventory_module
...@@ -46,6 +47,8 @@ product_module ...@@ -46,6 +47,8 @@ product_module
purchase_order_module purchase_order_module
purchase_trade_condition_module purchase_trade_condition_module
query_module query_module
regularisation_request_module
regularisation_request_module/slapos_crm_regularisation_request_template
sale_opportunity_module sale_opportunity_module
sale_order_module sale_order_module
sale_packing_list_module sale_packing_list_module
...@@ -59,8 +62,7 @@ software_instance_module ...@@ -59,8 +62,7 @@ software_instance_module
software_product_module software_product_module
software_release_module software_release_module
support_request_module support_request_module
support_request_module/slapos_crm_support_request_template
system_event_module system_event_module
transformation_module transformation_module
web_page_module web_page_module
support_request_module/slapos_crm_support_request_template \ No newline at end of file
event_module/slapos_crm_web_message_template
\ No newline at end of file
...@@ -74,6 +74,8 @@ Purchase Trade Condition ...@@ -74,6 +74,8 @@ Purchase Trade Condition
Purchase Trade Condition Module Purchase Trade Condition Module
Query Query
Query Module Query Module
Regularisation Request
Regularisation Request Module
Sale Invoice Transaction Sale Invoice Transaction
Sale Opportunity Sale Opportunity
Sale Opportunity Module Sale Opportunity Module
......
...@@ -74,6 +74,8 @@ Purchase Trade Condition ...@@ -74,6 +74,8 @@ Purchase Trade Condition
Purchase Trade Condition Module Purchase Trade Condition Module
Query Query
Query Module Query Module
Regularisation Request
Regularisation Request Module
Sale Invoice Transaction Sale Invoice Transaction
Sale Opportunity Sale Opportunity
Sale Opportunity Module Sale Opportunity 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