コード例 #1
0
 def setUp(self):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     self.root = self.connection.root()['Application']
     newSecurityManager(None, UnitTestUser().__of__(self.root))
コード例 #2
0
ファイル: test_PortalFolder.py プロジェクト: goschtl/zope
 def setUp( self ):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     self.root = self.connection.root()[ 'Application' ]
     newSecurityManager( None, UnitTestUser().__of__( self.root ) )
コード例 #3
0
ファイル: testTraverse.py プロジェクト: telfia/Zope
 def _setupSecurity(self, policy=None):
     from AccessControl import SecurityManager
     from AccessControl.SecurityManagement import noSecurityManager
     if policy is None:
         policy = self.oldPolicy
     noSecurityManager()
     SecurityManager.setSecurityPolicy(policy)
コード例 #4
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToSimpleAttrValue(self):
     # Verify it's possible to use __bobo_traverse__ to a simple
     # python value
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     bb = BoboTraversable()
     self.assertEqual(bb.restrictedTraverse('bb_status'), 'screechy')
コード例 #5
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToMethod(self):
     # Verify it's possible to use __bobo_traverse__ to a method.
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     bb = BoboTraversable()
     self.failUnless(
         bb.restrictedTraverse('bb_method') is not bb.bb_method)
コード例 #6
0
 def testDefaultValueWhenNotFound(self):
     # Test that traversing to a non-existent object returns
     # the default when provided
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     self.assertEqual(self.root.restrictedTraverse('happy/happy', 'joy'),
                      'joy')
コード例 #7
0
 def testBoboTraverseToSimpleAttrValue(self):
     # Verify it's possible to use __bobo_traverse__ to a simple
     # python value
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     bb = BoboTraversable()
     self.assertEqual(bb.restrictedTraverse('bb_status'), 'screechy')
コード例 #8
0
ファイル: testTraverse.py プロジェクト: zopefoundation/Zope
 def _setupSecurity(self, policy=None):
     from AccessControl import SecurityManager
     from AccessControl.SecurityManagement import noSecurityManager
     if policy is None:
         policy = self.oldPolicy
     noSecurityManager()
     SecurityManager.setSecurityPolicy(policy)
コード例 #9
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testDefaultValueWhenNotFound(self):
     # Test that traversing to a non-existent object returns
     # the default when provided
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     self.assertEqual(
         self.root.restrictedTraverse('happy/happy', 'joy'), 'joy')
コード例 #10
0
 def testDefaultValueWhenUnathorized(self):
     # Test that traversing to an unauthorized object returns
     # the default when provided
     noSecurityManager()
     SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
     newSecurityManager(None, UnitTestUser().__of__(self.root))
     self.root.stuff = 'stuff here'
     self.assertEqual(self.root.folder1.restrictedTraverse('stuff', 42), 42)
コード例 #11
0
 def testTraverseThroughBoboTraverse(self):
     # Verify it's possible to use __bobo_traverse__ with the
     # Zope security policy.
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     bb = BoboTraversable()
     self.failUnlessRaises(KeyError, bb.restrictedTraverse, 'notfound')
     bb.restrictedTraverse('bb_subitem')
コード例 #12
0
 def testBoboTraverseToWrappedSubObj(self):
     # Verify it's possible to use __bobo_traverse__ with the
     # Zope security policy.
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     bb = BoboTraversable()
     self.failUnlessRaises(KeyError, bb.restrictedTraverse, 'notfound')
     bb.restrictedTraverse('bb_subitem')
コード例 #13
0
 def testBoboTraverseToNonAttrValue(self):
     # Verify it's possible to use __bobo_traverse__ to an
     # arbitrary manufactured object
     noSecurityManager()
     # Default security policy always seems to deny in this case, which
     # is fine, but to test the code branch we sub in the forgiving one
     SecurityManager.setSecurityPolicy(UnitTestSecurityPolicy())
     bb = BoboTraversable()
     self.failUnless(bb.restrictedTraverse('manufactured') is 42)
コード例 #14
0
    def tearDown(self):
        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldpolicy)

        del self.root
        del self.reflecto
        del self.oldpolicy

        super(CopyPasteTests, self).tearDown()
コード例 #15
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testDefaultValueWhenUnathorized(self):
     # Test that traversing to an unauthorized object returns
     # the default when provided
     noSecurityManager()
     SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
     newSecurityManager( None, UnitTestUser().__of__( self.root ) )
     self.root.stuff = 'stuff here'
     self.assertEqual(
         self.root.folder1.restrictedTraverse('stuff', 42), 42)
コード例 #16
0
ファイル: testCopySupport.py プロジェクト: dhavlik/Zope
    def tearDown(self):
        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldPolicy)
        del self.oldPolicy
        del self.policy
        del self.folder2
        del self.folder1

        self._cleanApp()
コード例 #17
0
    def tearDown(self):
        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldpolicy)

        del self.root
        del self.reflecto
        del self.oldpolicy

        super(CopyPasteTests, self).tearDown()
コード例 #18
0
    def tearDown(self):
        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldPolicy)
        del self.oldPolicy
        del self.policy
        del self.folder2
        del self.folder1

        self._cleanApp()
コード例 #19
0
 def testTraverseMethodRestricted(self):
     self.root.my = Restricted('my')
     my = self.root.my
     my.id = 'my'
     noSecurityManager()
     SecurityManager.setSecurityPolicy(ProtectedMethodSecurityPolicy())
     r = my.restrictedTraverse('getId')
     self.assertEquals(r(), 'my')
     self.assertRaises(Unauthorized, my.restrictedTraverse, 'private')
     self.assertRaises(Unauthorized, my.restrictedTraverse, 'ohno')
コード例 #20
0
 def testBoboTraverseToAcquiredAttribute(self):
     # Verify it's possible to use __bobo_traverse__ to an acquired
     # attribute
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     folder = self.root.folder1
     folder.stuff = 'stuff here'
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(folder)
     self.assertEqual(bb.restrictedTraverse('stuff'), 'stuff here')
コード例 #21
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToNonAttrValue(self):
     # Verify it's possible to use __bobo_traverse__ to an
     # arbitrary manufactured object
     noSecurityManager()
     # Default security policy always seems to deny in this case, which
     # is fine, but to test the code branch we sub in the forgiving one
     SecurityManager.setSecurityPolicy(UnitTestSecurityPolicy())
     bb = BoboTraversable()
     self.failUnless(
         bb.restrictedTraverse('manufactured') is 42)
コード例 #22
0
 def testBoboTraverseToAcquiredObject(self):
     # Verify it's possible to use a __bobo_traverse__ which retrieves
     # objects by acquisition
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(self.root)
     self.assertEqual(bb.restrictedTraverse('folder1'), bb.folder1)
     self.assertEqual(
         Acquisition.aq_inner(bb.restrictedTraverse('folder1')),
         self.root.folder1)
コード例 #23
0
 def tearDown(self):
     del self.types_tool
     del self.workflow_tool
     del self.url_tool
     del self.discussion_tool
     del self.catalog_tool
     del self.root
     del self._policy
     get_transaction().abort()
     self.connection.close()
     SecurityManager.setSecurityPolicy(self._oldPolicy)
コード例 #24
0
 def testBoboTraverseToAcquiredProtectedObject(self):
     # Verify it's possible to use a __bobo_traverse__ which retrieves
     # objects by acquisition
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     folder = self.root.folder1
     # restrict the ability to access the retrieved object itself
     folder.manage_permission(access_contents_information, [], 0)
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(self.root)
     self.failUnlessRaises(Unauthorized, bb.restrictedTraverse, 'folder1')
コード例 #25
0
 def testAcquiredAttributeDenial(self):
     # Verify that restrictedTraverse raises the right kind of exception
     # on denial of access to an acquired attribute.  If it raises
     # AttributeError instead of Unauthorized, the user may never
     # be prompted for HTTP credentials.
     noSecurityManager()
     SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
     newSecurityManager(None, UnitTestUser().__of__(self.root))
     self.root.stuff = 'stuff here'
     self.failUnlessRaises(Unauthorized,
                           self.app.folder1.restrictedTraverse, 'stuff')
コード例 #26
0
 def testAcquiredAttributeDenial(self):
     # Verify that restrictedTraverse raises the right kind of exception
     # on denial of access to an acquired attribute.  If it raises
     # AttributeError instead of Unauthorized, the user may never
     # be prompted for HTTP credentials.
     noSecurityManager()
     SecurityManager.setSecurityPolicy(CruelSecurityPolicy())
     newSecurityManager( None, UnitTestUser().__of__( self.root ) )
     self.root.stuff = 'stuff here'
     self.failUnlessRaises(Unauthorized,
                           self.root.folder1.restrictedTraverse, 'stuff')
コード例 #27
0
ファイル: test_Discussions.py プロジェクト: goschtl/zope
 def tearDown( self ):
     del self.types_tool
     del self.workflow_tool
     del self.url_tool
     del self.discussion_tool
     del self.catalog_tool
     del self.root
     del self._policy
     get_transaction().abort()
     self.connection.close()
     SecurityManager.setSecurityPolicy( self._oldPolicy )
コード例 #28
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToAcquiredAttribute(self):
     # Verify it's possible to use __bobo_traverse__ to an acquired
     # attribute
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     folder = self.root.folder1
     folder.stuff = 'stuff here'
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(folder)
     self.assertEqual(
         bb.restrictedTraverse('stuff'), 'stuff here')
コード例 #29
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToAcquiredObject(self):
     # Verify it's possible to use a __bobo_traverse__ which retrieves
     # objects by acquisition
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(self.root)
     self.assertEqual(
         bb.restrictedTraverse('folder1'), bb.folder1)
     self.assertEqual(
         Acquisition.aq_inner(bb.restrictedTraverse('folder1')),
         self.root.folder1)
コード例 #30
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToAcquiredProtectedObject(self):
     # Verify it's possible to use a __bobo_traverse__ which retrieves
     # objects by acquisition
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     folder = self.root.folder1
     # restrict the ability to access the retrieved object itself
     folder.manage_permission(access_contents_information, [], 0)
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(self.root)
     self.failUnlessRaises(Unauthorized,
                           self.root.folder1.restrictedTraverse, 'folder1')
コード例 #31
0
    def tearDown(self):

        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldPolicy)
        del self.oldPolicy
        del self.policy
        del self.folder2
        del self.folder1

        self._cleanApp()
        componenttesting.tearDown()
        CopySupportTestBase.tearDown(self)
コード例 #32
0
    def tearDown(self):

        noSecurityManager()
        SecurityManager.setSecurityPolicy(self.oldPolicy)
        del self.oldPolicy
        del self.policy
        del self.folder2
        del self.folder1

        self._cleanApp()
        componenttesting.tearDown()
        CopySupportTestBase.tearDown(self)
コード例 #33
0
 def tearDown(self):
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     del self.oldPolicy
     del self.policy
     del self.folder1
     transaction.abort()
     self.app._p_jar.sync()
     self.connection.close()
     del self.app
     del self.responseOut
     del self.root
     del self.connection
コード例 #34
0
 def testBoboTraverseToAcquiredProtectedAttribute(self):
     # Verify that using __bobo_traverse__ to get an acquired but
     # protected attribute results in Unauthorized
     noSecurityManager()
     SecurityManager.setSecurityPolicy(self.oldPolicy)
     folder = self.root.folder1
     # We protect the the attribute by restricting access to the parent
     folder.manage_permission(access_contents_information, [], 0)
     folder.stuff = 'stuff here'
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(folder)
     self.failUnlessRaises(Unauthorized,
                           self.root.folder1.restrictedTraverse, 'stuff')
コード例 #35
0
 def setUp(self):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     self.root = self.connection.root()['Application']
     self.manager = UnitTestUser().__of__(self.root)
     self.member = LimitedUnitTestUser().__of__(self.root)
     self.root._setObject('folder', PortalFolder('folder', ''))
     self.folder = self.root.folder
     self.folder._setObject('doc1', DummyContent('doc1'))
     self.folder._setObject('doc2', DummyContent('doc2'))
     self.folder._setObject('doc3', DummyContent('doc3'))
コード例 #36
0
 def tearDown( self ):
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     del self.oldPolicy
     del self.policy
     del self.folder1
     get_transaction().abort()
     self.app._p_jar.sync()
     self.connection.close()
     del self.app
     del self.responseOut
     del self.root
     del self.connection
コード例 #37
0
ファイル: testTraverse.py プロジェクト: wpjunior/proled
 def testBoboTraverseToAcquiredProtectedAttribute(self):
     # Verify that using __bobo_traverse__ to get an acquired but
     # protected attribute results in Unauthorized
     noSecurityManager()
     SecurityManager.setSecurityPolicy( self.oldPolicy )
     folder = self.root.folder1
     # We protect the the attribute by restricting access to the parent
     folder.manage_permission(access_contents_information, [], 0)
     folder.stuff = 'stuff here'
     bb = BoboTraversableWithAcquisition()
     bb = bb.__of__(folder)
     self.failUnlessRaises(Unauthorized,
                           self.root.folder1.restrictedTraverse, 'stuff')
コード例 #38
0
ファイル: test_PortalFolder.py プロジェクト: goschtl/zope
 def setUp( self ):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     self.root = self.connection.root()[ 'Application' ]
     self.manager = UnitTestUser().__of__( self.root )
     self.member = LimitedUnitTestUser().__of__( self.root )
     self.root._setObject( 'folder', PortalFolder( 'folder', '' ) )
     self.folder = self.root.folder
     self.folder._setObject( 'doc1', DummyContent( 'doc1' ) )
     self.folder._setObject( 'doc2', DummyContent( 'doc2' ) )
     self.folder._setObject( 'doc3', DummyContent( 'doc3' ) )
コード例 #39
0
ファイル: test_Discussions.py プロジェクト: bendavis78/zope
 def setUp(self):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy(self._policy)
     self.root = Zope.app()
     self.root._setObject('portal_discussion', DiscussionTool())
     self.discussion_tool = self.root.portal_discussion
     self.root._setObject('portal_catalog', CatalogTool())
     self.catalog_tool = self.root.portal_catalog
     self.root._setObject('portal_url', URLTool())
     self.url_tool = self.root.portal_url
     self.root._setObject('portal_workflow', WorkflowTool())
     self.workflow_tool = self.root.portal_workflow
     self.root._setObject('portal_types', TypesTool())
     types_tool = self.types_tool = self.root.portal_types
コード例 #40
0
    def setUp(self):
        componenttesting.setUp()
        eventtesting.setUp()
        zcml.load_config("meta.zcml", zope.component)
        zcml.load_config("configure.zcml", Products.StandardCacheManagers)

        folder1, folder2 = self._initFolders()

        folder1.all_meta_types = folder2.all_meta_types = CACHE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)

        cm_id = "cache"
        manager = self._makeOne(cm_id)
        self.folder1._setObject(cm_id, manager)
        self.cachemanager = self.folder1[cm_id]
        transaction.savepoint(optimistic=True)

        newSecurityManager(None, UnitTestUser().__of__(self.root))

        CopySupportTestBase.setUp(self)
コード例 #41
0
    def setUp(self):
        super(CopyPasteTests, self).setUp()

        from Products.Reflecto.content.reflector import Reflector

        self.root = FakeRoot()
        self.root.reflecto = self.reflecto
        self.reflecto = self.root.reflecto  # Acquisition wrapped

        # Second reflector, using the subdir as it's filesystem path
        self.root.reflecto2 = Reflector('reflecto2')
        self.reflecto2 = self.root.reflecto2
        self.reflecto2.setRelativePath(os.path.join(self.tmppath, 'subdir'))
        self.indexview2 = MockIndexView()

        # duplicate fake @@index work for reflecto2
        if DefaultTraversable is not None:
            # ease use of ITraversable by setting REQUEST to None
            self.reflecto2.REQUEST = None
            # DefaultTraversable will look up the view as 'index'
            setattr(self.reflecto2, 'index', self.indexview2)
        else:
            setattr(self.reflecto2, '@@index', self.indexview2)

        self.oldpolicy = SecurityManager.setSecurityPolicy(
            UnitTestSecurityPolicy())
        newSecurityManager(None, UnitTestUser().__of__(self.root))
コード例 #42
0
    def setUp(self):
        super(CopyPasteTests, self).setUp()

        from Products.Reflecto.content.reflector import Reflector

        self.root = FakeRoot()
        self.root.reflecto = self.reflecto
        self.reflecto = self.root.reflecto # Acquisition wrapped

        # Second reflector, using the subdir as it's filesystem path
        self.root.reflecto2 = Reflector('reflecto2')
        self.reflecto2 = self.root.reflecto2
        self.reflecto2.setRelativePath(os.path.join(self.tmppath, 'subdir'))
        self.indexview2 = MockIndexView()

        # duplicate fake @@index work for reflecto2
        if DefaultTraversable is not None:
            # ease use of ITraversable by setting REQUEST to None
            self.reflecto2.REQUEST = None
            # DefaultTraversable will look up the view as 'index'
            setattr(self.reflecto2, 'index', self.indexview2)
        else:
            setattr(self.reflecto2, '@@index', self.indexview2)

        self.oldpolicy = SecurityManager.setSecurityPolicy(
            UnitTestSecurityPolicy())
        newSecurityManager(None, UnitTestUser().__of__(self.root))
コード例 #43
0
 def setUp(self):
     self.folder = f = Folder()
     f.laf = AqPageTemplate()
     f.t = AqPageTemplate()
     self.policy = UnitTestSecurityPolicy()
     self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
     noSecurityManager()  # Use the new policy.
コード例 #44
0
    def setUp(self):
        componenttesting.setUp()
        eventtesting.setUp()
        zcml.load_config('meta.zcml', zope.component)
        zcml.load_config('configure.zcml', Products.StandardCacheManagers)

        folder1, folder2 = self._initFolders()

        folder1.all_meta_types = folder2.all_meta_types = CACHE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)

        cm_id = 'cache'
        manager = self._makeOne(cm_id)
        self.folder1._setObject(cm_id, manager)
        self.cachemanager = self.folder1[cm_id]
        transaction.savepoint(optimistic=True)

        newSecurityManager(None, UnitTestUser().__of__(self.root))

        CopySupportTestBase.setUp(self)
コード例 #45
0
ファイル: test_TypesTool.py プロジェクト: bendavis78/zope
    def setUp(self):
        get_transaction().begin()
        self._policy = PermissiveSecurityPolicy()
        self._oldPolicy = SecurityManager.setSecurityPolicy(self._policy)
        self.connection = Zope.DB.open()
        root = self.root = self.connection.root()['Application']
        newSecurityManager(None, UnitTestUser().__of__(self.root))

        env = {'SERVER_NAME': 'http://localhost', 'SERVER_PORT': '80'}
        root.REQUEST = ZPublisher.HTTPRequest.HTTPRequest(None, env, None)

        root.addDummy = addDummy

        root._setObject('portal_types', TypesTool())
        tool = root.portal_types
        FTI = FactoryTypeInformation
        tool._setObject(
            'Dummy',
            FTI('Dummy',
                meta_type=DummyContent.meta_type,
                product='CMFDefault',
                factory='addDocument',
                actions=({
                    'name': 'View',
                    'action': 'view',
                    'permissions': ('View', )
                }, {
                    'name': 'View2',
                    'action': 'view2',
                    'permissions': ('View', )
                }, {
                    'name': 'Edit',
                    'action': 'edit',
                    'permissions': ('forbidden permission', )
                })))
コード例 #46
0
ファイル: test_Discussions.py プロジェクト: goschtl/zope
 def setUp( self ):
     get_transaction().begin()
     self._policy = UnitTestSecurityPolicy()
     SecurityManager.setSecurityPolicy( self._policy )
     self.connection = Zope.DB.open()
     self.root = self.connection.root()[ 'Application' ]
     self.root._setObject( 'portal_discussion', DiscussionTool() )
     self.discussion_tool = self.root.portal_discussion
     self.root._setObject( 'portal_catalog', CatalogTool() )
     self.catalog_tool = self.root.portal_catalog
     self.root._setObject( 'portal_url', URLTool() )
     self.url_tool = self.root.portal_url
     self.root._setObject( 'portal_workflow', WorkflowTool() ) 
     self.workflow_tool = self.root.portal_workflow
     self.root._setObject( 'portal_types', TypesTool() )
     types_tool = self.types_tool = self.root.portal_types
コード例 #47
0
ファイル: test_uidannotation.py プロジェクト: bendavis78/zope
    def _initPolicyAndUser(self, a_lambda=None, v_lambda=None, c_lambda=None):
        def _promiscuous(*args, **kw):
            return 1

        if a_lambda is None:
            a_lambda = _promiscuous

        if v_lambda is None:
            v_lambda = _promiscuous

        if c_lambda is None:
            c_lambda = _promiscuous

        scp = _SensitiveSecurityPolicy(v_lambda, c_lambda)
        SecurityManager.setSecurityPolicy(scp)
        newSecurityManager(None,
                           _AllowedUser(a_lambda).__of__(self.app.acl_users))
コード例 #48
0
ファイル: testDTMLTests.py プロジェクト: tseaver/Zope-RFA
    def setUp(self):
        super(DTMLTests, self).setUp()
        zope.component.provideAdapter(DefaultTraversable, (None,))
        provideUtility(DefaultUnicodeEncodingConflictResolver, IUnicodeEncodingConflictResolver)

        self.t = AqPageTemplate()
        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
        noSecurityManager()  # Use the new policy.
コード例 #49
0
ファイル: testDTMLTests.py プロジェクト: asajohnston/Zope
    def setUp(self):
        super(DTMLTests, self).setUp()
        zope.component.provideAdapter(DefaultTraversable, (None,))
        provideUtility(DefaultUnicodeEncodingConflictResolver, IUnicodeEncodingConflictResolver)

        self.t = AqPageTemplate()
        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
        noSecurityManager()  # Use the new policy.
コード例 #50
0
    def _initPolicyAndUser(self, a_lambda=None, v_lambda=None, c_lambda=None):

        def _promiscuous(*args, **kw):
            return 1

        if a_lambda is None:
            a_lambda = _promiscuous

        if v_lambda is None:
            v_lambda = _promiscuous

        if c_lambda is None:
            c_lambda = _promiscuous

        scp = _SensitiveSecurityPolicy(v_lambda, c_lambda)
        SecurityManager.setSecurityPolicy(scp)
        newSecurityManager(None,
                           _AllowedUser(a_lambda).__of__(self.app.acl_users))
コード例 #51
0
ファイル: testCopySupport.py プロジェクト: dhavlik/Zope
    def setUp(self):
        folder1, folder2 = self._initFolders()
        folder1.all_meta_types = folder2.all_meta_types = FILE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
        newSecurityManager(None, UnitTestUser().__of__(self.root))
コード例 #52
0
    def setUp(self):
        folder1, folder2 = self._initFolders()
        folder1.all_meta_types = folder2.all_meta_types = FILE_META_TYPES

        self.folder1 = folder1
        self.folder2 = folder2

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
        newSecurityManager(None, UnitTestUser().__of__(self.root))
コード例 #53
0
    def setUp(self):
        get_transaction().begin()
        self._policy = UnitTestSecurityPolicy()
        SecurityManager.setSecurityPolicy(self._policy)
        root = self.root = Zope.app()

        env = {'SERVER_NAME': 'http://localhost', 'SERVER_PORT': '80'}
        root.REQUEST = ZPublisher.HTTPRequest.HTTPRequest(None, env, None)

        root.addDummy = addDummy

        root._setObject('portal_types', TypesTool())
        tool = root.portal_types
        FTI = FactoryTypeInformation
        tool._setObject(
            'Dummy',
            FTI('Dummy',
                meta_type=DummyContent.meta_type,
                product='OFSP',
                factory='addDTMLDocument'))
コード例 #54
0
ファイル: testTraverse.py プロジェクト: denishom12/decorator
    def setUp(self):
        import io

        import transaction
        from AccessControl import SecurityManager
        from AccessControl.SecurityManagement import newSecurityManager
        from OFS.Application import Application
        from OFS.Folder import manage_addFolder
        from OFS.Image import manage_addFile
        from Testing.makerequest import makerequest
        from ZODB.DB import DB
        from ZODB.DemoStorage import DemoStorage

        s = DemoStorage()
        self.connection = DB(s).open()

        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            responseOut = self.responseOut = io.BytesIO()
            self.app = makerequest(self.root, stdout=responseOut)
            manage_addFolder(self.app, 'folder1')
            folder1 = getattr(self.app, 'folder1')
            setattr(folder1, '+something', 'plus')

            folder1.all_meta_types = ({
                'name': 'File',
                'action': 'manage_addFile',
                'permission': 'Add images and files'
            }, )

            manage_addFile(folder1,
                           'file',
                           file=b'',
                           content_type='text/plain')

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            transaction.commit()
        except Exception:
            self.connection.close()
            raise
        transaction.begin()
        self.folder1 = getattr(self.app, 'folder1')

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
        newSecurityManager(None, self._makeUser().__of__(self.root))
コード例 #55
0
    def setUp( self ):
        import cStringIO
        import transaction
        from AccessControl import SecurityManager
        from AccessControl.SecurityManagement import newSecurityManager
        from OFS.Application import Application
        from OFS.Folder import manage_addFolder
        from OFS.Image import manage_addFile
        from Testing.makerequest import makerequest
        from ZODB.DB import DB
        from ZODB.DemoStorage import DemoStorage

        s = DemoStorage()
        self.connection = DB(s).open()

        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            responseOut = self.responseOut = cStringIO.StringIO()
            self.app = makerequest( self.root, stdout=responseOut )
            manage_addFolder( self.app, 'folder1' )
            folder1 = getattr( self.app, 'folder1' )
            setattr(folder1, '+something', 'plus')

            folder1.all_meta_types = \
                                    ({ 'name'        : 'File'
                                     , 'action'      : 'manage_addFile'
                                     , 'permission'  : 'Add images and files'
                                     }
                                    ,
                                    )

            manage_addFile( folder1, 'file'
                          , file='', content_type='text/plain')

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            transaction.commit()
        except:
            self.connection.close()
            raise
        transaction.begin()
        self.folder1 = getattr( self.app, 'folder1' )

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
        newSecurityManager( None, self._makeUser().__of__( self.root ) )
コード例 #56
0
ファイル: test_TypesTool.py プロジェクト: goschtl/zope
    def setUp( self ):
        get_transaction().begin()
        self._policy = UnitTestSecurityPolicy()
        SecurityManager.setSecurityPolicy(self._policy)
        root = self.root = Zope.app()

        env = { 'SERVER_NAME' : 'http://localhost'
              , 'SERVER_PORT' : '80'
              }
        root.REQUEST = ZPublisher.HTTPRequest.HTTPRequest( None, env, None )
        
        root.addDummy = addDummy

        root._setObject( 'portal_types', TypesTool() )
        tool = root.portal_types
        FTI = FactoryTypeInformation
        tool._setObject( 'Dummy'
                       , FTI( 'Dummy'
                            , meta_type=DummyContent.meta_type
                            , product='OFSP'
                            , factory='addDTMLDocument'
                            )
                       )
コード例 #57
0
ファイル: test_Expression.py プロジェクト: bendavis78/zope
 def setUp(self):
     get_transaction().begin()
     self._policy = PermissiveSecurityPolicy()
     self._oldPolicy = SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     root = self.root = self.connection.root()['Application']
     newSecurityManager(None, UnitTestUser().__of__(self.root))
     root._setObject('portal', DummyContent('portal', 'url_portal'))
     portal = self.portal = self.root.portal
     self.folder = DummyContent('foo', 'url_foo')
     self.object = DummyContent('bar', 'url_bar')
     self.ai = ActionInformation(id='view',
                                 title='View',
                                 action=Expression(text='view'),
                                 condition=Expression(text='member'),
                                 category='global',
                                 visible=1)
コード例 #58
0
 def afterSetUp(self):
     print "DEBUG afterSetUp"
     self.policy = UnitTestSecurityPolicy()
     self.oldPolicy = SecurityManager.setSecurityPolicy(self.policy)
     newSecurityManager(None, UnitTestUser().__of__(self.folder))
     REQUEST = UnitTestRequest({
         'btn': 'Add',
         'lang': 'eng',
         'lang_label': 'English',
         'manage_lang': 'eng',
         'theme': 'myZMStheme5.zexp',
         'folder_id': 'myzmsx',
         'initialization': 1,
     })
     factory = self.folder.manage_addProduct['zms']
     factory.manage_addZMS('eng', 'eng', REQUEST)
     zms = self.folder['myzmsx']
     print zms
コード例 #59
0
ファイル: test_Expression.py プロジェクト: goschtl/zope
 def setUp( self ):
     get_transaction().begin()
     self._policy = PermissiveSecurityPolicy()
     self._oldPolicy = SecurityManager.setSecurityPolicy(self._policy)
     self.connection = Zope.DB.open()
     root = self.root = self.connection.root()[ 'Application' ]
     newSecurityManager(None, UnitTestUser().__of__( self.root ))
     root._setObject('portal', DummyContent('portal', 'url_portal'))
     portal = self.portal = self.root.portal
     self.folder = DummyContent('foo', 'url_foo')
     self.object = DummyContent('bar', 'url_bar')
     self.ai = ActionInformation(id='view'
                               , title='View'
                               , action=Expression(
               text='view')
                               , condition=Expression(
               text='member')
                               , category='global'
                               , visible=1)
コード例 #60
0
    def setUp( self ):

        self.connection = makeConnection()
        try:
            r = self.connection.root()
            a = Application()
            r['Application'] = a
            self.root = a
            responseOut = self.responseOut = cStringIO.StringIO()
            self.app = makerequest( self.root, stdout=responseOut )
            manage_addFolder( self.app, 'folder1' )
            folder1 = getattr( self.app, 'folder1' )

            folder1.all_meta_types = \
                                    ( { 'name'        : 'File'
                                      , 'action'      : 'manage_addFile'
                                      , 'permission'  : 'Add images and files'
                                      }
                                    ,
                                    )

            manage_addFile( folder1, 'file'
                          , file='', content_type='text/plain')

            # Hack, we need a _p_mtime for the file, so we make sure that it
            # has one. We use a subtransaction, which means we can rollback
            # later and pretend we didn't touch the ZODB.
            get_transaction().commit()
        except:
            self.connection.close()
            raise
        get_transaction().begin()
        self.folder1 = getattr( self.app, 'folder1' )

        self.policy = UnitTestSecurityPolicy()
        self.oldPolicy = SecurityManager.setSecurityPolicy( self.policy )
        newSecurityManager( None, UnitTestUser().__of__( self.root ) )