plone.app.discussion/plone/app/discussion/tests/functional_test_comment_url.txt

71 lines
2.0 KiB
Plaintext

===================================
Dealing with faulty comment links
===================================
Make sure that calling specially crafted URLs doesn't break the conversation
view.
See also https://dev.plone.org/ticket/13327
Setting up and logging in
=========================
First we have to set up some things and login.
>>> app = layer['app']
>>> from plone.testing.z2 import Browser
>>> browser = Browser(app)
>>> browser.addHeader('Authorization', 'Basic admin:secret')
>>> portal = layer['portal']
>>> portal_url = 'http://nohost/plone'
As we're expecting to see 404s, the test should not break on HTTP errors.
>>> browser.raiseHttpErrors = False
Enable commenting.
>>> from zope.component import queryUtility
>>> from plone.registry.interfaces import IRegistry
>>> from plone.app.discussion.interfaces import IDiscussionSettings
>>> registry = queryUtility(IRegistry)
>>> settings = registry.forInterface(IDiscussionSettings)
>>> settings.globally_enabled = True
Create a public page with comments allowed.
>>> browser.open(portal_url)
>>> browser.getLink(id='document').click()
>>> browser.getControl(name='title').value = "Doc1"
>>> browser.getControl(name='allowDiscussion:boolean').value = True
>>> browser.getControl(name='form.button.save').click()
>>> urldoc1 = browser.url
Check that the form has been properly submitted
>>> browser.url
'http://nohost/plone/doc1'
Checking invalid comment links
==============================
URL has invalid comment id
--------------------------
Test a URL with a comment id that cannot be converted to long integer.
>>> url_invalid_comment_id = "%s/++conversation++default/ThisCantBeRight" % urldoc1
>>> browser.open(url_invalid_comment_id)
We should not get an error,
>>> "500 Internal Server Error" in str(browser.headers)
False
but we should get a 404:
>>> "404 Not Found" in str(browser.headers)
True