############################################################################## # # Copyright (c) 2004 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Container View Permissions Tests $Id: $ """ import unittest import transaction from zope.security.interfaces import Unauthorized from zope.app.testing.functional import BrowserTestCase from zope.app.file import File from zope.dublincore.interfaces import IZopeDublinCore from zope.app.securitypolicy.interfaces import IRolePermissionManager class Tests(BrowserTestCase): def test_default_view_permissions(self): """Tests the default view permissions. See zope/app/securitypolicy/configure.zcml for the grants of zope.View and zope.app.dublincore.view to zope.Anonymous. These ensure that, by default, anonymous users can view container contents. """ # add an item that can be viewed from the root folder file = File() self.getRootFolder()['file'] = file IZopeDublinCore(file).title = u'My File' transaction.commit() response = self.publish('/') self.assertEquals(response.getStatus(), 200) body = response.getBody() # confirm we can see the file name self.assert_(body.find('file') != -1) # confirm we can see the metadata title self.assert_(body.find('