def test_virtual_hosting(self): from Products.SiteAccess.VirtualHostMonster import manage_addVirtualHostMonster from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster manage_addVirtualHostMonster(self.app) self.assertTrue(VirtualHostMonster.id in self.app.objectIds()) self.portal.invokeFactory('Document', 'a_page') self.assertTrue('a_page' in self.portal.objectIds()) self.portal.invokeFactory('Folder', 'a_folder') self.assertTrue('a_folder' in self.portal.objectIds()) import transaction transaction.commit() browser = Browser(self.app) browser.addHeader( 'Authorization', 'Basic %s:%s' % ( TEST_USER_NAME, TEST_USER_PASSWORD, )) url = self.app.absolute_url( ) + '/VirtualHostBase/http/www.buystuff.com:80/plone/a_page?MIGHT_REDIRECT=1' browser.open(url) self.assertEqual(url, browser.url) url = self.app.absolute_url( ) + '/VirtualHostBase/http/www.buystuff.com:80/plone/a_folder/a_page?MIGHT_REDIRECT=1' browser.open(url) self.assertNotEqual(url, browser.url) browser.handleErrors = False url = self.app.absolute_url( ) + '/VirtualHostBase/http/www.buystuff.com:80/plone/VirtualHostRoot/_vh_z/a_page?MIGHT_REDIRECT=1' browser.open(url) self.assertEqual(url, browser.url)
def test_search_in_vhm(self): # Install a Virtual Host Monster if 'virtual_hosting' not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(self.app, 'virtual_hosting') transaction.commit() # we don't get a result if we do not provide the full physical path response = self.api_session.get('/@search?path=/folder',) self.assertSetEqual(set(), set(result_paths(response.json()))) # If we go through the VHM will will get results if we only use # the part of the path inside the VHM vhm_url = ( '%s/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/%s' % (self.app.absolute_url(), '@search?path=/folder')) response = self.api_session.get(vhm_url) self.assertSetEqual( {u'/folder', u'/folder/doc', u'/folder/other-document'}, set(result_paths(response.json())))
def test_search_use_site_search_settings_with_vhm(self): if "virtual_hosting" not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster import ( manage_addVirtualHostMonster, ) manage_addVirtualHostMonster(self.app, "virtual_hosting") transaction.commit() vhm_url = "{}/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/{}".format( self.app.absolute_url(), "/@search", ) response = self.api_session.get(vhm_url, params={ "use_site_search_settings": 1, "path": "/" }).json() titles = sorted([ "Another Folder", "Doc outside folder", "Document in second folder", "Lorem Ipsum", "Other Document", "Some Folder", ]) self.assertEqual(sorted([item["title"] for item in response["items"]]), titles) noLongerProvides(self.folder, INavigationRoot) transaction.commit()
def setUpZope(self, app, configurationContext): import Products.CMFPlacefulWorkflow xmlconfig.file('configure.zcml', Products.CMFPlacefulWorkflow, context=configurationContext) import ftw.upgrade xmlconfig.file('configure.zcml', ftw.upgrade, context=configurationContext) z2.installProduct(app, 'Products.DateRecurringIndex') import plone.app.contenttypes xmlconfig.file('configure.zcml', plone.app.contenttypes, context=configurationContext) z2.installProduct(app, 'Products.CMFPlacefulWorkflow') try: # Plone 4 with collective.indexing pkg_resources.get_distribution('collective.indexing') except pkg_resources.DistributionNotFound: pass else: import collective.indexing xmlconfig.file('configure.zcml', collective.indexing, context=configurationContext) z2.installProduct(app, 'collective.indexing') manage_addVirtualHostMonster(app, 'virtual_hosting')
def test_search_in_vhm(self): # Install a Virtual Host Monster if "virtual_hosting" not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster import ( manage_addVirtualHostMonster, ) manage_addVirtualHostMonster(self.app, "virtual_hosting") transaction.commit() # we don't get a result if we do not provide the full physical path response = self.api_session.get("/@search?path=/folder") self.assertSetEqual(set(), set(result_paths(response.json()))) # If we go through the VHM will will get results if we only use # the part of the path inside the VHM vhm_url = "{}/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/{}".format( self.app.absolute_url(), "@search?path=/folder", ) response = self.api_session.get(vhm_url) self.assertSetEqual( {"/folder", "/folder/doc", "/folder/other-document"}, set(result_paths(response.json())), )
def setUpZope(self, app, configurationContext): # load ZCML import plone.app.blocks self.loadZCML(package=plone.app.blocks) # Register directory for testing xmlconfig.string("""\ <configure xmlns="http://namespaces.zope.org/zope" xmlns:plone="http://namespaces.plone.org/plone" i18n_domain="plone" package="plone.app.blocks.tests"> <plone:static type="sitelayout" name="testlayout1" directory="resources/sitelayout/testlayout1" /> <plone:static type="sitelayout" name="testlayout2" directory="resources/sitelayout/testlayout2" /> </configure> """, context=configurationContext) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): if PLONE_VERSION.startswith('5'): import plone.app.contenttypes self.loadZCML(package=plone.app.contenttypes) else: # needed by plone.app.linkintegrity under Plone 4.x import plone.app.referenceablebehavior self.loadZCML(package=plone.app.referenceablebehavior) if DEXTERITY_ONLY: import plone.app.contenttypes self.loadZCML(package=plone.app.contenttypes) z2.installProduct(app, 'Products.DateRecurringIndex') if HAS_PFG: import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') import collective.cover self.loadZCML(package=collective.cover) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): if IS_PLONE_5: import plone.app.contenttypes self.loadZCML(package=plone.app.contenttypes) else: # needed by plone.app.linkintegrity under Plone 4.x import plone.app.referenceablebehavior self.loadZCML(package=plone.app.referenceablebehavior) if DEXTERITY_ONLY: import plone.app.contenttypes self.loadZCML(package=plone.app.contenttypes) z2.installProduct(app, 'Products.DateRecurringIndex') if HAS_PFG: import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') import collective.cover self.loadZCML(package=collective.cover) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): super(RobotFixture, self).setUpZope(app, configurationContext) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def test_with_virtualhost(self): manage_addVirtualHostMonster(self.app, 'virtual_hosting') transaction.commit() path = ("/VirtualHostBase/http/some_host:80/%s/VirtualHostRoot/" % self.portal.getId()) host, port = self.layer['zserver_info'] url = "http://%(host)s:%(port)i%(path)s/@@wkpdf" % locals() result = urlopen(url) pdf_data = result.read() self.pdf_contains(pdf_data, 'PdfPortal')
def test_add_manage_addVirtualHostMonster(self): from Products.SiteAccess.VirtualHostMonster import \ manage_addVirtualHostMonster from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster from ZPublisher.BeforeTraverse import queryBeforeTraverse manage_addVirtualHostMonster(self.root) self.assertTrue(VirtualHostMonster.id in self.root.objectIds()) hook = queryBeforeTraverse(self.root, VirtualHostMonster.meta_type) self.assertTrue(hook)
def setUpZope(self, app, configurationContext): # Load ZCML import collective.localheaderandfooter self.loadZCML(package=collective.localheaderandfooter) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def test_search_in_vhm_multiple_paths(self): # Install a Virtual Host Monster if "virtual_hosting" not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster import ( manage_addVirtualHostMonster, ) manage_addVirtualHostMonster(self.app, "virtual_hosting") transaction.commit() # path as a list query = {"path": ["/folder", "/folder2"]} # If we go through the VHM we will get results for multiple paths # if we only use the part of the path inside the VHM vhm_url = "%s/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/%s" % ( self.app.absolute_url(), "@search", ) response = self.api_session.get(vhm_url, params=query) self.assertSetEqual( { u"/folder", u"/folder/doc", u"/folder/other-document", u"/folder2", u"/folder2/doc", }, set(result_paths(response.json())), ) # path as a dict with a query list query = {"path.query": ["/folder", "/folder2"]} # If we go through the VHM we will get results for multiple paths # if we only use the part of the path inside the VHM vhm_url = "%s/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/%s" % ( self.app.absolute_url(), "@search", ) response = self.api_session.get(vhm_url, params=query) self.assertSetEqual( { u"/folder", u"/folder/doc", u"/folder/other-document", u"/folder2", u"/folder2/doc", }, set(result_paths(response.json())), )
def setUpZope(self, app, configurationContext): import Products.CMFPlacefulWorkflow xmlconfig.file('configure.zcml', Products.CMFPlacefulWorkflow, context=configurationContext) import ftw.upgrade xmlconfig.file('configure.zcml', ftw.upgrade, context=configurationContext) z2.installProduct(app, 'Products.CMFPlacefulWorkflow') manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUp(self): transaction.begin() self.app = makerequest(Zope2.app()) try: if not hasattr(self.app, 'virtual_hosting'): # If ZopeLite was imported, we have no default virtual host monster from Products.SiteAccess.VirtualHostMonster import manage_addVirtualHostMonster manage_addVirtualHostMonster(self.app, 'virtual_hosting') self.app.manage_addFolder('folder') self.app.folder.manage_addDTMLMethod('doc', '') self.app.REQUEST.set('PARENTS', [self.app]) self.traverse = self.app.REQUEST.traverse except: self.tearDown()
def setUpZope(self, app, configurationContext): import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') # Load ZCML import collective.cover self.loadZCML(package=collective.cover) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting') import prodam.tiles self.loadZCML(package=prodam.tiles)
def setUp(self): import transaction from Testing.makerequest import makerequest from Testing.ZopeTestCase.ZopeLite import app transaction.begin() self.app = makerequest(app()) if 'virtual_hosting' not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(self.app, 'virtual_hosting') self.app.manage_addFolder('folder') self.app.folder.manage_addDTMLMethod('doc', '') self.app.REQUEST.set('PARENTS', [self.app]) self.traverse = self.app.REQUEST.traverse
def setUpZope(self, app, configurationContext): import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') # Load ZCML import collective.cover self.loadZCML(package=collective.cover) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting') import brasil.gov.tiles self.loadZCML(package=brasil.gov.tiles) self.loadZCML(name='overrides.zcml', package=brasil.gov.tiles)
def setUpZope(self, app, configurationContext): # XXX: do not install (yet) PFG in Plone 5 if HAS_PFG and PLONE_VERSION < '5.0': import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') # Load ZCML import collective.cover self.loadZCML(package=collective.cover) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') # Load ZCML import collective.cover self.loadZCML(package=collective.cover) # XXX: https://github.com/collective/collective.cover/issues/81 #import plone.app.imagetile #self.loadZCML(package=plone.app.imagetile) #import plone.app.texttile #self.loadZCML(package=plone.app.imagetile) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): import Products.PloneFormGen self.loadZCML(package=Products.PloneFormGen) installProduct(app, 'Products.PloneFormGen') # Load ZCML import collective.cover self.loadZCML(package=collective.cover) # XXX: https://github.com/collective/collective.cover/issues/81 #import plone.app.imagetile #self.loadZCML(package=plone.app.imagetile) #import plone.app.texttile #self.loadZCML(package=plone.app.imagetile) if 'virtual_hosting' not in app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(app, 'virtual_hosting')
def setUpZope(self, app, configurationContext): import Products.CMFPlacefulWorkflow xmlconfig.file('configure.zcml', Products.CMFPlacefulWorkflow, context=configurationContext) import ftw.upgrade xmlconfig.file('configure.zcml', ftw.upgrade, context=configurationContext) z2.installProduct(app, 'Products.DateRecurringIndex') import plone.app.contenttypes xmlconfig.file('configure.zcml', plone.app.contenttypes, context=configurationContext) z2.installProduct(app, 'Products.CMFPlacefulWorkflow') manage_addVirtualHostMonster(app, 'virtual_hosting')
def test_search_in_vhm_multiple_paths(self): # Install a Virtual Host Monster if 'virtual_hosting' not in self.app.objectIds(): # If ZopeLite was imported, we have no default virtual # host monster from Products.SiteAccess.VirtualHostMonster \ import manage_addVirtualHostMonster manage_addVirtualHostMonster(self.app, 'virtual_hosting') transaction.commit() # path as a list query = {'path': ['/folder', '/folder2']} # If we go through the VHM we will get results for multiple paths # if we only use the part of the path inside the VHM vhm_url = ( '%s/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/%s' % (self.app.absolute_url(), '@search')) response = self.api_session.get(vhm_url, params=query) self.assertSetEqual( { u'/folder', u'/folder/doc', u'/folder/other-document', u'/folder2', u'/folder2/doc' }, set(result_paths(response.json()))) # path as a dict with a query list query = {'path.query': ['/folder', '/folder2']} # If we go through the VHM we will get results for multiple paths # if we only use the part of the path inside the VHM vhm_url = ( '%s/VirtualHostBase/http/plone.org/plone/VirtualHostRoot/%s' % (self.app.absolute_url(), '@search')) response = self.api_session.get(vhm_url, params=query) self.assertSetEqual( { u'/folder', u'/folder/doc', u'/folder/other-document', u'/folder2', u'/folder2/doc' }, set(result_paths(response.json())))