[CMF-checkins] CVS: CMF/CMFCore/tests - test_utils.py:1.1 test_all.py:1.24

Yvo Schubbe y.2004_ at wcm-solutions.de
Thu Feb 12 03:38:02 EST 2004


Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv30546/CMFCore/tests

Modified Files:
	test_all.py 
Added Files:
	test_utils.py 
Log Message:
- added check for executable owner and proxy roles to _checkPermission


=== Added File CMF/CMFCore/tests/test_utils.py ===
from unittest import TestSuite, makeSuite, main

import Testing
import Zope
try:
    Zope.startup()
except AttributeError:
    # for Zope versions before 2.6.1
    pass

from AccessControl import getSecurityManager
from AccessControl.Owned import Owned
from AccessControl.Permission import Permission

from Products.CMFCore.tests.base.dummy import DummyObject
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyUserFolder
from Products.CMFCore.tests.base.testcase import SecurityTest
from Products.CMFCore.utils import _checkPermission


class DummyObject(Owned, DummyObject):
    pass


class CoreUtilsTests(SecurityTest):

    def setUp(self):
        SecurityTest.setUp(self)
        self.site = DummySite('site').__of__(self.root)
        self.site._setObject( 'acl_users', DummyUserFolder() )
        self.site._setObject('content_dummy', DummyObject(id='content_dummy'))
        self.site._setObject('actions_dummy', DummyObject(id='actions_dummy'))

    def test__checkPermission(self):
        o = self.site.actions_dummy
        Permission('View',(),o).setRoles(('Anonymous',))
        Permission('WebDAV access',(),o).setRoles(('Authenticated',))
        Permission('Manage users',(),o).setRoles(('Manager',))
        eo = self.site.content_dummy
        eo._owner = (['acl_users'], 'user_foo')
        getSecurityManager().addContext(eo)
        self.failUnless( _checkPermission('View', o) )
        self.failIf( _checkPermission('WebDAV access', o) )
        self.failIf( _checkPermission('Manage users', o) )

        eo._proxy_roles = ('Authenticated',)
        self.failIf( _checkPermission('View', o) )
        self.failUnless( _checkPermission('WebDAV access', o) )
        self.failIf( _checkPermission('Manage users', o) )


def test_suite():
    return TestSuite((
        makeSuite(CoreUtilsTests),
        ))

if __name__ == '__main__':
    main(defaultTest='test_suite')


=== CMF/CMFCore/tests/test_all.py 1.23 => 1.24 ===
--- CMF/CMFCore/tests/test_all.py:1.23	Thu Feb  5 10:39:11 2004
+++ CMF/CMFCore/tests/test_all.py	Thu Feb 12 03:37:31 2004
@@ -39,6 +39,7 @@
         'test_TypesTool',
         'test_UndoTool',
         'test_URLTool',
+        'test_utils',
         'test_WorkflowTool',
         ])
 




More information about the CMF-checkins mailing list