diff --git a/plone/app/discussion/tests/functional_test_comment_url.txt b/plone/app/discussion/tests/functional_test_comment_url.txt deleted file mode 100644 index b2fde39..0000000 --- a/plone/app/discussion/tests/functional_test_comment_url.txt +++ /dev/null @@ -1,70 +0,0 @@ -=================================== - 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 diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index 76babf9..a424a28 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -699,6 +699,14 @@ class ConversationTest(unittest.TestCase): self.assertEqual('http://nohost/plone/doc1/++conversation++default', conversation.absolute_url()) + def test_unconvertible_id(self): + # make sure the conversation view doesn't break when given comment id + # can't be converted to long + + conversation = self.portal.doc1.restrictedTraverse( + '++conversation++default/ThisCantBeRight') + self.assertEqual(conversation, None) + def test_parent(self): # Check that conversation has a content object as parent diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index f269ec3..0c7f31e 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -21,7 +21,6 @@ optionflags = ( normal_testfiles = [ 'functional_test_comments.txt', 'functional_test_comment_review_workflow.txt', - 'functional_test_comment_url.txt', ]