Commit b3ad06f2 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

BusinessTemplate: install as System Processes user.

See merge request !1302
parents bcb43861 49b9612b
...@@ -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:
......
...@@ -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',
......
...@@ -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()
......
...@@ -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()
......
...@@ -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):
......
...@@ -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.
......
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