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))
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 ) )
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)
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')
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)
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')
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')
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')
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)
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')
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')
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)
def tearDown(self): noSecurityManager() SecurityManager.setSecurityPolicy(self.oldpolicy) del self.root del self.reflecto del self.oldpolicy super(CopyPasteTests, self).tearDown()
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)
def tearDown(self): noSecurityManager() SecurityManager.setSecurityPolicy(self.oldPolicy) del self.oldPolicy del self.policy del self.folder2 del self.folder1 self._cleanApp()
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')
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')
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)
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)
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)
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')
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')
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')
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 )
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')
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)
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')
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)
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
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')
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'))
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
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')
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' ) )
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
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)
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))
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.
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)
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', ) })))
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
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))
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.
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))
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'))
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))
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 ) )
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' ) )
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)
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
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)
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 ) )