Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Lu Xu
erp5
Commits
b3ad06f2
Commit
b3ad06f2
authored
Oct 28, 2020
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Plain Diff
BusinessTemplate: install as System Processes user.
See merge request
nexedi/erp5!1302
parents
bcb43861
49b9612b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
5 deletions
+58
-5
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccountingReports.py
...Item/portal_components/test.erp5.testAccountingReports.py
+8
-0
bt5/erp5_accounting_renderjs_ui_test/TestTemplateItem/portal_components/test.erp5.testFunctionalRJSAccountingReport.py
...components/test.erp5.testFunctionalRJSAccountingReport.py
+9
-0
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
...eItem/portal_components/test.erp5.testBusinessTemplate.py
+1
-2
bt5/erp5_forge/TestTemplateItem/portal_components/test.erp5.testTemplateTool.py
...plateItem/portal_components/test.erp5.testTemplateTool.py
+12
-0
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+17
-3
product/ERP5Type/tests/testFunctionalCore.py
product/ERP5Type/tests/testFunctionalCore.py
+11
-0
No files found.
bt5/erp5_accounting/TestTemplateItem/portal_components/test.erp5.testAccountingReports.py
View file @
b3ad06f2
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
import
unittest
import
unittest
from
AccessControl
import
getSecurityManager
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
erp5.component.test.testAccounting
import
AccountingTestCase
from
erp5.component.test.testAccounting
import
AccountingTestCase
...
@@ -5119,6 +5120,13 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
...
@@ -5119,6 +5120,13 @@ class TestAccountingReportsWithAnalytic(AccountingTestCase, ERP5ReportTestCase):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
AccountingTestCase
.
afterSetUp
(
self
)
AccountingTestCase
.
afterSetUp
(
self
)
self
.
login
()
self
.
login
()
# change ownership of the preference
self
.
portal
.
portal_preferences
.
accounting_zuite_preference
.
changeOwnership
(
getSecurityManager
().
getUser
(),
True
,
)
# create some functions
# create some functions
function
=
self
.
portal
.
portal_categories
.
function
function
=
self
.
portal
.
portal_categories
.
function
if
function
.
_getOb
(
'a'
,
None
)
is
None
:
if
function
.
_getOb
(
'a'
,
None
)
is
None
:
...
...
bt5/erp5_accounting_renderjs_ui_test/TestTemplateItem/portal_components/test.erp5.testFunctionalRJSAccountingReport.py
View file @
b3ad06f2
...
@@ -28,12 +28,21 @@
...
@@ -28,12 +28,21 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
from
AccessControl
import
getSecurityManager
from
Products.ERP5Type.tests.ERP5TypeFunctionalTestCase
import
ERP5TypeFunctionalTestCase
from
Products.ERP5Type.tests.ERP5TypeFunctionalTestCase
import
ERP5TypeFunctionalTestCase
class
TestRenderJSAccountingReport
(
ERP5TypeFunctionalTestCase
):
class
TestRenderJSAccountingReport
(
ERP5TypeFunctionalTestCase
):
foreground
=
0
foreground
=
0
run_only
=
"renderjs_ui_accounting_report_zuite"
run_only
=
"renderjs_ui_accounting_report_zuite"
def
afterSetUp
(
self
):
# change ownership of the preference
self
.
portal
.
portal_preferences
.
accounting_zuite_preference
.
changeOwnership
(
getSecurityManager
().
getUser
(),
True
,
)
super
(
TestRenderJSAccountingReport
,
self
).
afterSetUp
()
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
return
(
return
(
'erp5_accounting_renderjs_ui_test'
,
'erp5_accounting_renderjs_ui_test'
,
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
View file @
b3ad06f2
...
@@ -31,7 +31,6 @@ import unittest
...
@@ -31,7 +31,6 @@ import unittest
import
logging
import
logging
from
unittest
import
expectedFailure
,
skip
from
unittest
import
expectedFailure
,
skip
from
AccessControl
import
getSecurityManager
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
...
@@ -2335,7 +2334,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
...
@@ -2335,7 +2334,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
# will be reset:
# will be reset:
expected_local_roles
=
{
expected_local_roles
=
{
'ac'
:
[
'Manager'
],
'ac'
:
[
'Manager'
],
getSecurityManager
().
getUser
().
getId
()
:
[
'Owner'
],
'System Processes'
:
[
'Owner'
],
'group_function'
:
[
'Auditor'
]
'group_function'
:
[
'Auditor'
]
}
}
p
=
self
.
getPortal
()
p
=
self
.
getPortal
()
...
...
bt5/erp5_forge/TestTemplateItem/portal_components/test.erp5.testTemplateTool.py
View file @
b3ad06f2
...
@@ -837,6 +837,18 @@ class TestTemplateTool(ERP5TypeTestCase):
...
@@ -837,6 +837,18 @@ class TestTemplateTool(ERP5TypeTestCase):
erp5_test
=
self
.
portal
.
portal_skins
[
'erp5_test'
]
erp5_test
=
self
.
portal
.
portal_skins
[
'erp5_test'
]
self
.
assertTrue
(
erp5_test
.
hasObject
(
'test_file'
))
self
.
assertTrue
(
erp5_test
.
hasObject
(
'test_file'
))
def
test_ownerhsip
(
self
):
self
.
assertEqual
(
self
.
portal
.
portal_skins
.
erp5_core
.
getOwnerTuple
(),
([
self
.
portal
.
getId
(),
'acl_users'
],
'System Processes'
),
)
bt
=
self
.
templates_tool
.
getInstalledBusinessTemplate
(
"erp5_forge"
)
bt
.
reinstall
(
force
=
True
)
self
.
commit
()
self
.
assertEqual
(
self
.
portal
.
portal_skins
.
erp5_forge
.
getOwnerTuple
(),
([
self
.
portal
.
getId
(),
'acl_users'
],
'System Processes'
),
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
b3ad06f2
...
@@ -33,14 +33,18 @@ from Shared.DC.ZRDB import Aqueduct
...
@@ -33,14 +33,18 @@ from Shared.DC.ZRDB import Aqueduct
from
Shared.DC.ZRDB.Connection
import
Connection
as
RDBConnection
from
Shared.DC.ZRDB.Connection
import
Connection
as
RDBConnection
from
Products.ERP5Type.Globals
import
Persistent
,
PersistentMapping
from
Products.ERP5Type.Globals
import
Persistent
,
PersistentMapping
from
Acquisition
import
Implicit
,
aq_base
,
aq_inner
,
aq_parent
from
Acquisition
import
Implicit
,
aq_base
,
aq_inner
,
aq_parent
from
AccessControl
import
ClassSecurityInfo
,
Unauthorized
,
getSecurityManager
from
AccessControl
import
ClassSecurityInfo
,
Unauthorized
from
AccessControl.SecurityInfo
import
ModuleSecurityInfo
from
AccessControl.SecurityInfo
import
ModuleSecurityInfo
from
AccessControl.SecurityManagement
import
getSecurityManager
,
\
newSecurityManager
,
setSecurityManager
from
AccessControl.User
import
nobody
from
Products.CMFCore.utils
import
getToolByName
from
Products.CMFCore.utils
import
getToolByName
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.ZSQLMethods.SQL
import
SQL
from
Products.ZSQLMethods.SQL
import
SQL
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
Products.ERP5Type.Cache
import
transactional_cached
from
Products.ERP5Type.Cache
import
transactional_cached
from
Products.ERP5Type.Message
import
translateString
from
Products.ERP5Type.Message
import
translateString
from
Products.ERP5Type.UnrestrictedMethod
import
super_user
from
Products.ERP5Type.Utils
import
readLocalDocument
,
\
from
Products.ERP5Type.Utils
import
readLocalDocument
,
\
writeLocalDocument
,
\
writeLocalDocument
,
\
importLocalDocument
,
\
importLocalDocument
,
\
...
@@ -5539,10 +5543,20 @@ Business Template is a set of definitions, such as skins, portal types and categ
...
@@ -5539,10 +5543,20 @@ Business Template is a set of definitions, such as skins, portal types and categ
site
.
portal_caches
.
clearAllCache
()
site
.
portal_caches
.
clearAllCache
()
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'install'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'install'
)
install
=
_install
def
install
(
self
,
*
args
,
**
kw
):
# switch to nobody temporarily so that unrestricted _install
# is always invoked by system user.
sm
=
getSecurityManager
()
newSecurityManager
(
None
,
nobody
)
try
:
with
super_user
():
return
self
.
_install
(
*
args
,
**
kw
)
finally
:
# Restore the original user.
setSecurityManager
(
sm
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'reinstall'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'reinstall'
)
reinstall
=
_
install
reinstall
=
install
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'trash'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'trash'
)
def
trash
(
self
,
new_bt
,
**
kw
):
def
trash
(
self
,
new_bt
,
**
kw
):
...
...
product/ERP5Type/tests/testFunctionalCore.py
View file @
b3ad06f2
...
@@ -29,12 +29,23 @@
...
@@ -29,12 +29,23 @@
import
unittest
import
unittest
from
AccessControl
import
getSecurityManager
from
Products.ERP5Type.tests.ERP5TypeFunctionalTestCase
import
\
from
Products.ERP5Type.tests.ERP5TypeFunctionalTestCase
import
\
ERP5TypeFunctionalTestCase
ERP5TypeFunctionalTestCase
class
TestZeleniumCore
(
ERP5TypeFunctionalTestCase
):
class
TestZeleniumCore
(
ERP5TypeFunctionalTestCase
):
foreground
=
0
foreground
=
0
def
afterSetUp
(
self
):
# change ownership of the preference
pref
=
self
.
portal
.
portal_preferences
.
_getOb
(
'accounting_zuite_preference'
,
None
,
)
if
pref
is
not
None
:
pref
.
changeOwnership
(
getSecurityManager
().
getUser
(),
True
)
super
(
TestZeleniumCore
,
self
).
afterSetUp
()
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
"""
"""
Return the list of business templates.
Return the list of business templates.
...
...
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