Commit 32f93f6d authored by Hanno Schlichting's avatar Hanno Schlichting

Removed persistent default code like the `error_log` and `temp_folder`.

parent 064be573
......@@ -33,6 +33,8 @@ Features Added
Restructuring
+++++++++++++
- Removed persistent default code like the `error_log` and `temp_folder`.
- Removed persistent default content, including the `standard_error_message`
template.
......
This diff is collapsed.
......@@ -29,10 +29,9 @@ from AccessControl import ClassSecurityInfo
from AccessControl.class_init import InitializeClass
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.Permissions import view, view_management_screens
from AccessControl.Permissions import view_management_screens
from AccessControl.ImplPython import guarded_getattr as guarded_getattr_py
from AccessControl.ImplC import guarded_getattr as guarded_getattr_c
from Products.SiteErrorLog.SiteErrorLog import SiteErrorLog
class AllowedItem(SimpleItem):
......@@ -56,16 +55,6 @@ class ProtectedItem(SimpleItem):
InitializeClass(ProtectedItem)
class ProtectedSiteErrorLog(SiteErrorLog):
'''This differs from the base by declaring security
for the object itself.
'''
id = 'error_log2'
security = ClassSecurityInfo()
security.declareObjectProtected(view)
InitializeClass(ProtectedSiteErrorLog)
class TestGetAttr(unittest.TestCase):
......@@ -83,7 +72,6 @@ class TestGetAttr(unittest.TestCase):
# Set up objects in the root that we want to aquire
self.app.manage_addFolder('plain_folder')
self.app._setObject('error_log2', ProtectedSiteErrorLog())
# We also want to be able to acquire simple attributes
self.app.manage_addProperty(id='simple_type', type='string', value='a string')
......@@ -131,74 +119,13 @@ class TestGetAttr(unittest.TestCase):
self.assertEqual(o, self.app.acl_users)
def testAclUsersDenied(self):
# XXX: Fails in 2.7.3
o = self.guarded_getattr(self.folder.denied, 'acl_users')
self.assertEqual(o, self.app.acl_users)
def testAclUsersProtected(self):
# XXX: Fails in 2.7.3 for Anonymous
o = self.guarded_getattr(self.folder.protected, 'acl_users')
self.assertEqual(o, self.app.acl_users)
# Acquire browser id manager
def testBrowserIdManagerAllowed(self):
o = self.guarded_getattr(self.folder.allowed, 'browser_id_manager')
self.assertEqual(o, self.app.browser_id_manager)
def testBrowserIdManagerDenied(self):
o = self.guarded_getattr(self.folder.denied, 'browser_id_manager')
self.assertEqual(o, self.app.browser_id_manager)
def testBrowserIdManagerProtected(self):
o = self.guarded_getattr(self.folder.protected, 'browser_id_manager')
self.assertEqual(o, self.app.browser_id_manager)
# Acquire error log
def testErrorLogAllowed(self):
o = self.guarded_getattr(self.folder.allowed, 'error_log')
self.assertEqual(o, self.app.error_log)
def testErrorLogDenied(self):
# XXX: Fails in 2.7.3
o = self.guarded_getattr(self.folder.denied, 'error_log')
self.assertEqual(o, self.app.error_log)
def testErrorLogProtected(self):
# XXX: Fails in 2.7.3 for Anonymous
o = self.guarded_getattr(self.folder.protected, 'error_log')
self.assertEqual(o, self.app.error_log)
# Now watch this: error log with object security declaration works fine!
def testProtectedErrorLogAllowed(self):
o = self.guarded_getattr(self.folder.allowed, 'error_log2')
self.assertEqual(o, self.app.error_log2)
def testProtectedErrorLogDenied(self):
o = self.guarded_getattr(self.folder.denied, 'error_log2')
self.assertEqual(o, self.app.error_log2)
def testProtectedErrorLogProtected(self):
o = self.guarded_getattr(self.folder.protected, 'error_log2')
self.assertEqual(o, self.app.error_log2)
# This appears to mean that any potential acquiree must make sure
# to declareObjectProtected(SomePermission).
# From the ZDG:
# We've seen how to make assertions on methods - but in the case of
# someObject we are not trying to access any particular method, but
# rather the object itself (to pass it to some_method). Because the
# security machinery will try to validate access to someObject, we
# need a way to let the security machinery know how to handle access
# to the object itself in addition to protecting its methods.
# IOW, acquiring an object in restricted Python now amounts to
# "passing it to some_method".
# Also test Richard Jones' use-case of acquiring a string:
def testSimpleTypeAllowed(self):
......@@ -206,12 +133,10 @@ class TestGetAttr(unittest.TestCase):
self.assertEqual(o, 'a string')
def testSimpleTypeDenied(self):
# XXX: Fails in 2.7.3
o = self.guarded_getattr(self.folder.denied, 'simple_type')
self.assertEqual(o, 'a string')
def testSimpleTypeProtected(self):
# XXX: Fails in 2.7.3 for Anonymous
o = self.guarded_getattr(self.folder.protected, 'simple_type')
self.assertEqual(o, 'a string')
......
......@@ -14,8 +14,6 @@
import os, unittest, tempfile, cStringIO
from logging import getLogger
from OFS.Application import Application, AppInitializer
import Zope2.Startup
import ZConfig
......@@ -101,69 +99,6 @@ class TestInitialization( unittest.TestCase ):
self.assertTrue(hasattr(app, 'Control_Panel'))
self.assertEqual(app.Control_Panel.meta_type, 'Control Panel')
def test_install_tempfolder_and_sdc(self):
self.configure(good_cfg)
i = self.getOne()
i.install_tempfolder_and_sdc()
app = i.getApp()
self.assertEqual(app.temp_folder.meta_type, 'Temporary Folder')
self.assertEqual(app.temp_folder.session_data.meta_type,
'Transient Object Container')
self.assertTrue(app._getInitializerFlag('temp_folder'))
def test_install_tempfolder_and_sdc_status(self):
self.configure(good_cfg)
i = self.getOne()
status = i.install_tempfolder_and_sdc()
self.assertTrue(status)
i = self.getOne()
self.configure(bad_cfg)
try:
logger = getLogger('Zope.ZODBMountPoint')
logger.disabled = 1
status = i.install_tempfolder_and_sdc()
finally:
logger.disabled = 0
self.assertFalse(status)
def test_install_tempfolder_and_sdc_unlimited_sessions(self):
unlimited_cfg = good_cfg + """
maximum-number-of-session-objects 0
"""
self.configure(unlimited_cfg)
i = self.getOne()
status = i.install_tempfolder_and_sdc()
self.assertTrue(status)
sdc = i.getApp().temp_folder.session_data
self.assertEqual(sdc.getSubobjectLimit(), 0)
def test_install_browser_id_manager(self):
self.configure(good_cfg)
i = self.getOne()
app = i.getApp()
i.install_browser_id_manager()
self.assertEqual(app.browser_id_manager.meta_type,'Browser Id Manager')
self.assertTrue(app._getInitializerFlag('browser_id_manager'))
def test_install_virtual_hosting(self):
self.configure(good_cfg)
i = self.getOne()
app = i.getApp()
i.install_virtual_hosting()
self.assertEqual(app.virtual_hosting.meta_type,'Virtual Host Monster')
self.assertTrue(app._getInitializerFlag('virtual_hosting'))
def test_install_session_data_manager(self):
self.configure(good_cfg)
i = self.getOne()
i.install_session_data_manager()
app = i.getApp()
self.assertEqual(app.session_data_manager.meta_type,
'Session Data Manager')
self.assertTrue(app._getInitializerFlag('session_data_manager'))
def test_install_required_roles(self):
self.configure(good_cfg)
i = self.getOne()
......@@ -187,14 +122,6 @@ class TestInitialization( unittest.TestCase ):
if os.path.exists(fname):
os.unlink(fname)
def test_install_errorlog(self):
self.configure(good_cfg)
i = self.getOne()
i.install_errorlog()
app = i.getApp()
self.assertEqual(app.error_log.meta_type, 'Site Error Log')
self.assertTrue(app._getInitializerFlag('error_log'))
def test_install_products(self):
self.configure(good_cfg)
i = self.getOne()
......
......@@ -17,7 +17,7 @@ class VHMRegressions(unittest.TestCase):
from Testing.ZopeTestCase.ZopeLite import app
transaction.begin()
self.app = makerequest(app())
if 'virtual_hosting' not in self.app.objectIds():
if 'virtual_hosting' not in self.app.objectIds():
# If ZopeLite was imported, we have no default virtual
# host monster
from Products.SiteAccess.VirtualHostMonster \
......
......@@ -200,16 +200,15 @@ class ZPublisherExceptionHook:
# ouch, a user saw this conflict error :-(
self.unresolved_conflict_errors += 1
if isinstance(published, list):
# special case for zope root
error_log_url = ''
else:
error_log_url = ''
if not isinstance(published, list):
try:
log = aq_acquire(published, '__error_log__', containment=1)
except AttributeError:
error_log_url = ''
pass
else:
error_log_url = log.raising((t, v, traceback))
if log is not None:
error_log_url = log.raising((t, v, traceback))
if (REQUEST is None or
(getattr(REQUEST.get('RESPONSE', None), '_error_format', '')
......
import unittest
import Testing
import Zope2
Zope2.startup()
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
from Testing.makerequest import makerequest
import transaction
import base64
......@@ -14,24 +14,23 @@ class TestPUTFactory(unittest.TestCase):
def setUp(self):
self.app = makerequest(Zope2.app())
try:
# Make a manager user
uf = self.app.acl_users
uf._doAddUser('manager', 'secret', ['Manager'], [])
# Make a folder to put stuff into
self.app.manage_addFolder('folder', '')
self.folder = self.app.folder
# Fake a WebDAV PUT request
request = self.app.REQUEST
request['PARENTS'] = [self.app]
request['BODY'] = 'bar'
request.environ['CONTENT_TYPE'] = 'text/plain'
request.environ['REQUEST_METHOD'] = 'PUT'
request.environ['WEBDAV_SOURCE_PORT'] = 1
request._auth = auth_info
except:
self.tearDown()
raise
# Make a manager user
uf = self.app.acl_users
uf._doAddUser('manager', 'secret', ['Manager'], [])
# Make a folder to put stuff into
self.app.manage_addFolder('folder', '')
self.folder = self.app.folder
# Setup VHM
vhm = VirtualHostMonster()
vhm.addToContainer(self.app)
# Fake a WebDAV PUT request
request = self.app.REQUEST
request['PARENTS'] = [self.app]
request['BODY'] = 'bar'
request.environ['CONTENT_TYPE'] = 'text/plain'
request.environ['REQUEST_METHOD'] = 'PUT'
request.environ['WEBDAV_SOURCE_PORT'] = 1
request._auth = auth_info
def tearDown(self):
transaction.abort()
......@@ -69,7 +68,6 @@ class TestPUTFactory(unittest.TestCase):
self.assertTrue('doc' in self.folder.objectIds())
def testCollector2261(self):
from OFS.Folder import manage_addFolder
from OFS.DTMLMethod import addDTMLMethod
self.app.manage_addFolder('A', '')
......
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