예제 #1
0
    def test_absolutePrefix_enabled_path_vhosting(self):
        app = self.layer['app']
        portal = self.layer['portal']

        from Products.SiteAccess import VirtualHostMonster
        VirtualHostMonster.manage_addVirtualHostMonster(app, 'virtual_hosting')

        import transaction
        transaction.commit()

        self.settings.enabled = True
        self.settings.absolutePrefix = u'/foo'

        portalURL = portal.absolute_url()
        prefix = '/'.join(portalURL.split('/')[:-1])
        suffix = portalURL.split('/')[-1]

        vhostURL = "%s/VirtualHostBase/http/example.org:80/%s/VirtualHostRoot/_vh_fizz/_vh_buzz/_vh_fizzbuzz/" % (
            prefix, suffix)

        import transaction
        transaction.commit()

        browser = Browser(app)
        browser.open(vhostURL)

        self.assertFalse('<img src="relative.jpg" />' in browser.contents)
        self.assertTrue('<img src="/fizz/buzz/fizzbuzz/foo/relative.jpg" />' in
                        browser.contents)
예제 #2
0
    def test_absolutePrefix_enabled_path_vhosting(self):
        app = self.layer['app']
        portal = self.layer['portal']

        from Products.SiteAccess import VirtualHostMonster
        VirtualHostMonster.manage_addVirtualHostMonster(app, 'virtual_hosting')

        import transaction
        transaction.commit()

        self.settings.enabled = True
        self.settings.absolutePrefix = u'/foo'

        portalURL = portal.absolute_url()
        prefix = '/'.join(portalURL.split('/')[:-1])
        suffix = portalURL.split('/')[-1]

        vhostURL = (
            "{0:s}/VirtualHostBase/http/example.org:80/{1:s}/VirtualHostRoot"
            "/_vh_fizz/_vh_buzz/_vh_fizzbuzz/".format(prefix, suffix)
        )

        import transaction
        transaction.commit()

        browser = Browser(app)
        browser.open(vhostURL)

        self.assertFalse('<img src="relative.jpg" />' in browser.contents)
        self.assertTrue(
            '<img src="/fizz/buzz/fizzbuzz/foo/relative.jpg" />'
            in browser.contents
        )
예제 #3
0
    def test_theme_stored_in_plone_site_works_with_virtual_host(self):
        app = self.layer['app']
        portal = self.layer['portal']

        # We'll upload the theme files to the Plone site root
        rules_contents = open(
            os.path.join(os.path.dirname(__file__), 'localrules.xml')
        )
        theme_contents = open(
            os.path.join(os.path.dirname(__file__), 'theme.html')
        )
        portal.manage_addDTMLMethod('theme.html', file=theme_contents)
        portal.manage_addDTMLMethod('rules.xml', file=rules_contents)

        # These paths should be relative to the Plone site root
        self.settings.rules = u'/rules.xml'
        self.settings.enabled = True

        from Products.SiteAccess import VirtualHostMonster
        VirtualHostMonster.manage_addVirtualHostMonster(app, 'virtual_hosting')

        import transaction
        transaction.commit()

        portalURL = portal.absolute_url()
        prefix = '/'.join(portalURL.split('/')[:-1])
        suffix = portalURL.split('/')[-1]

        vhostURL = (
            "{0:s}/VirtualHostBase/http/example.org:80/{1:s}/VirtualHostRoot"
            "/_vh_fizz/_vh_buzz/_vh_fizzbuzz/".format(prefix, suffix)
        )

        browser = Browser(app)
        browser.open(vhostURL)

        # Title - pulled in with rules.xml
        self.assertTrue(portal.title in browser.contents)

        # Elsewhere - not pulled in
        self.assertFalse("Accessibility" in browser.contents)

        # The theme
        self.assertTrue("This is the theme" in browser.contents)
예제 #4
0
    def test_theme_stored_in_plone_site_works_with_virtual_host(self):
        app = self.layer['app']
        portal = self.layer['portal']

        # We'll upload the theme files to the Plone site root
        rules_contents = open(
            os.path.join(os.path.dirname(__file__), 'localrules.xml'))
        theme_contents = open(
            os.path.join(os.path.dirname(__file__), 'theme.html'))
        portal.manage_addDTMLMethod('theme.html', file=theme_contents)
        portal.manage_addDTMLMethod('rules.xml', file=rules_contents)

        # These paths should be relative to the Plone site root
        self.settings.rules = u'/rules.xml'
        self.settings.enabled = True

        from Products.SiteAccess import VirtualHostMonster
        VirtualHostMonster.manage_addVirtualHostMonster(app, 'virtual_hosting')

        import transaction
        transaction.commit()

        portalURL = portal.absolute_url()
        prefix = '/'.join(portalURL.split('/')[:-1])
        suffix = portalURL.split('/')[-1]

        vhostURL = (
            "{0:s}/VirtualHostBase/http/example.org:80/{1:s}/VirtualHostRoot"
            "/_vh_fizz/_vh_buzz/_vh_fizzbuzz/".format(prefix, suffix))

        browser = Browser(app)
        browser.open(vhostURL)

        # Title - pulled in with rules.xml
        self.assertTrue(portal.title in browser.contents)

        # Elsewhere - not pulled in
        self.assertFalse("Accessibility" in browser.contents)

        # The theme
        self.assertTrue("This is the theme" in browser.contents)