Commit dcdf9533 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Sale Supply local roles

parent af29eb8f
...@@ -1242,3 +1242,86 @@ class TestSecurePaymentTool(TestSlapOSGroupRoleSecurityMixin): ...@@ -1242,3 +1242,86 @@ class TestSecurePaymentTool(TestSlapOSGroupRoleSecurityMixin):
self.assertAcquiredPermissions(tool, ['Add ERP5 SQL Methods']) self.assertAcquiredPermissions(tool, ['Add ERP5 SQL Methods'])
class TestSaleSupplyModule(TestSlapOSGroupRoleSecurityMixin):
def test_SaleSupplyModule(self):
module = self.portal.sale_supply_module
# Why does the the sale_supply_module acquire the local roles
self.assertSecurityGroup(module,
['F-SALE*', 'F-CUSTOMER', module.Base_getOwnerId()], True)
self.assertRoles(module, 'F-SALE*', ['Auditor', 'Author'])
self.assertRoles(module, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(module, module.Base_getOwnerId(), ['Owner'])
class TestSaleSupply(TestSlapOSGroupRoleSecurityMixin):
def test_SaleSupply_default(self):
supply = self.portal.sale_supply_module.newContent(
portal_type='Sale Supply')
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
def test_SaleSupply_DestinationCustomer(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
supply = self.portal.sale_supply_module.newContent(
portal_type='Sale Supply')
supply.edit(
destination_value=person,
)
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
supply.validate()
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', person.getUserId(), self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
self.assertRoles(supply, person.getUserId(), ['Auditor'])
supply.invalidate()
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
def test_SaleSupply_DestinationProject(self):
project = self.addProject()
supply = self.portal.sale_supply_module.newContent(
portal_type='Sale Supply')
supply.edit(
destination_project_value=project,
)
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
supply.validate()
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', project.getReference(), self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
self.assertRoles(supply, project.getReference(), ['Auditor'])
supply.invalidate()
self.assertSecurityGroup(supply,
['F-SALEAGT', 'F-SALEMAN', self.user_id], False)
self.assertRoles(supply, self.user_id, ['Owner'])
self.assertRoles(supply, 'F-SALEAGT', ['Assignee'])
self.assertRoles(supply, 'F-SALEMAN', ['Assignor'])
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