Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
slapos.core
Commits
f18fcc3b
Commit
f18fcc3b
authored
Jan 13, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: fixup Payment Transaction security
parent
26747043
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
25 deletions
+35
-25
master/bt5/slapos_erp5/PortalTypeRolesTemplateItem/Payment%20Transaction.xml
...rp5/PortalTypeRolesTemplateItem/Payment%20Transaction.xml
+12
-5
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
...l_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
+23
-20
No files found.
master/bt5/slapos_erp5/PortalTypeRolesTemplateItem/Payment%20Transaction.xml
View file @
f18fcc3b
<type_roles>
<role
id=
'Assignee'
>
<property
id=
'title'
>
Person Shadow
</property>
<property
id=
'condition'
>
python:
here.getDestinationSection('', portal_type='Person') == ""
</property>
<property
id=
'condition'
>
python:
(here.getDestinationSection('', portal_type='Person') == "") and (here.getLedger("") == "automated")
</property>
<multi_property
id=
'categories'
>
local_role_group/shadow
</multi_property>
<multi_property
id=
'category'
>
role/shadow/person
</multi_property>
<multi_property
id=
'base_category'
>
role
</multi_property>
...
...
@@ -10,12 +10,12 @@
<property
id=
'title'
>
ReadOnly for Accountant
</property>
<property
id=
'condition'
>
python: context.getLedger("") == "automated"
</property>
<multi_property
id=
'categories'
>
local_role_group/function
</multi_property>
<multi_property
id=
'category'
>
function/accounting
</multi_property>
<multi_property
id=
'category'
>
function/accounting
*
</multi_property>
<multi_property
id=
'base_category'
>
function
</multi_property>
</role>
<role
id=
'Auditor'
>
<property
id=
'title'
>
Shadow User
</property>
<property
id=
'condition'
>
python:
here.getDestinationSection('', portal_type='Person') != ''
</property>
<property
id=
'condition'
>
python:
(here.getDestinationSection('', portal_type='Person') != "") and (here.getLedger("") == "automated")
</property>
<property
id=
'base_category_script'
>
PaymentTransaction_getSecurityCategoryFromUser
</property>
<multi_property
id=
'categories'
>
local_role_group/shadow
</multi_property>
<multi_property
id=
'base_category'
>
aggregate
</multi_property>
...
...
@@ -27,11 +27,18 @@
<multi_property
id=
'categories'
>
local_role_group/user
</multi_property>
<multi_property
id=
'base_category'
>
destination_section
</multi_property>
</role>
<role
id=
'Assignee'
>
<property
id=
'title'
>
Writable for Accountant Agent
</property>
<property
id=
'condition'
>
python: context.getLedger("") != "automated"
</property>
<multi_property
id=
'categories'
>
local_role_group/function
</multi_property>
<multi_property
id=
'category'
>
function/accounting/agent
</multi_property>
<multi_property
id=
'base_category'
>
function
</multi_property>
</role>
<role
id=
'Assignor'
>
<property
id=
'title'
>
Writable for Accountant
</property>
<property
id=
'title'
>
Writable for Accountant
Manager
</property>
<property
id=
'condition'
>
python: context.getLedger("") != "automated"
</property>
<multi_property
id=
'categories'
>
local_role_group/function
</multi_property>
<multi_property
id=
'category'
>
function/accounting
</multi_property>
<multi_property
id=
'category'
>
function/accounting
/manager
</multi_property>
<multi_property
id=
'base_category'
>
function
</multi_property>
</role>
</type_roles>
\ No newline at end of file
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5GroupRoleSecurity.py
View file @
f18fcc3b
...
...
@@ -1336,16 +1336,28 @@ class TestBalanceTransaction(TestSlapOSGroupRoleSecurityMixin):
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestPaymentTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_
GroupCompany
(
self
):
def
test_
AccountingFunction_LedgerNotAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Assignor'
])
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_ShadowUser
(
self
):
def
test_AccountingFunction_LedgerAutomated
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
edit
(
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'F-ACCOUNTING*'
,
'R-SHADOW-PERSON'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCOUNTING*'
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
'R-SHADOW-PERSON'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_UserWithoutLedger
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
...
...
@@ -1355,15 +1367,13 @@ class TestPaymentTransaction(TestSlapOSGroupRoleSecurityMixin):
destination_section_value
=
person
,
)
product
.
updateLocalRolesOnSecurityGroups
()
shadow_user_id
=
'SHADOW-%s'
%
person
.
getUserId
()
self
.
assertSecurityGroup
(
product
,
[
'F-IS*'
,
self
.
user_id
,
person
.
getUserId
(),
shadow_user_id
],
False
)
self
.
assertRoles
(
product
,
'F-IS*'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
shadow_user_id
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
[
'F-ACCMAN'
,
'F-ACCAGT'
,
self
.
user_id
],
False
)
self
.
assertRoles
(
product
,
'F-ACCMAN'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
'F-ACCAGT'
,
[
'Assignee'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_User
(
self
):
def
test_User
Ledger
(
self
):
reference
=
'TESTPERSON-%s'
%
self
.
generateNewId
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
reference
=
reference
)
...
...
@@ -1371,25 +1381,18 @@ class TestPaymentTransaction(TestSlapOSGroupRoleSecurityMixin):
portal_type
=
'Payment Transaction'
)
product
.
edit
(
destination_section_value
=
person
,
ledger
=
'automated'
)
product
.
updateLocalRolesOnSecurityGroups
()
shadow_user_id
=
'SHADOW-%s'
%
person
.
getUserId
()
self
.
assertSecurityGroup
(
product
,
[
'
G-COMPANY
'
,
self
.
user_id
,
person
.
getUserId
(),
[
'
F-ACCOUNTING*
'
,
self
.
user_id
,
person
.
getUserId
(),
shadow_user_id
],
False
)
self
.
assertRoles
(
product
,
'
G-COMPANY'
,
[
'Assign
or'
])
self
.
assertRoles
(
product
,
'
F-ACCOUNTING*'
,
[
'Audit
or'
])
self
.
assertRoles
(
product
,
shadow_user_id
,
[
'Auditor'
])
self
.
assertRoles
(
product
,
person
.
getUserId
(),
[
'Auditor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
def
test_User_without_destination_section
(
self
):
product
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Payment Transaction'
)
product
.
updateLocalRolesOnSecurityGroups
()
self
.
assertSecurityGroup
(
product
,
[
'G-COMPANY'
,
self
.
user_id
,
'R-SHADOW-PERSON'
],
False
)
self
.
assertRoles
(
product
,
'G-COMPANY'
,
[
'Assignor'
])
self
.
assertRoles
(
product
,
self
.
user_id
,
[
'Owner'
])
class
TestPurchaseInvoiceTransaction
(
TestSlapOSGroupRoleSecurityMixin
):
def
test_AccountingFunction_LedgerNotAutomated
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment