← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/fixed-message-chain into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/fixed-message-chain into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/fixed-message-chain/+merge/55589

Summary
=======

Adds a test that provides coverage of bug messages on the webservice when accessed by attachment.

This was an area involved in a bug earlier, that has been incidentally fixed. This test both proves the fix and makes sure we won't have the failure again.

Implementation
==============
  
lib/lp/bugs/tests/test_bug_messages_webservice.py
-------------------------------------------------
Added the test.

Demo & QA
=========

This is qa-untestable; it's just a test.

Tests
=====
bin/test -vvct test_bug_messages_webservice

Lint
====
make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/tests/test_bug_messages_webservice.py
-- 
https://code.launchpad.net/~jcsackett/launchpad/fixed-message-chain/+merge/55589
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/fixed-message-chain into lp:launchpad.
=== modified file 'lib/lp/bugs/tests/test_bug_messages_webservice.py'
--- lib/lp/bugs/tests/test_bug_messages_webservice.py	2011-03-23 16:28:51 +0000
+++ lib/lp/bugs/tests/test_bug_messages_webservice.py	2011-03-30 16:22:36 +0000
@@ -10,8 +10,12 @@
 from lazr.restfulclient.errors import HTTPError
 from zope.component import getUtility
 from zope.security.management import endInteraction
+from zope.security.proxy import removeSecurityProxy
 
-from canonical.testing.layers import DatabaseFunctionalLayer
+from canonical.testing.layers import (
+    DatabaseFunctionalLayer,
+    LaunchpadFunctionalLayer,
+    )
 from lp.bugs.interfaces.bugmessage import IBugMessageSet
 from lp.registry.interfaces.person import IPersonSet
 from lp.testing import (
@@ -20,6 +24,37 @@
     TestCaseWithFactory,
     )
 
+class TestMessageTraversal(TestCaseWithFactory):
+    """Tests safe traversal of bugs.
+
+    See bug 607438."""
+    
+    layer = LaunchpadFunctionalLayer
+
+    def setUp(self):
+        super(TestMessageTraversal, self).setUp()
+        self.bugowner = self.factory.makePerson()
+        self.bug = self.factory.makeBug(owner=self.bugowner)
+
+    def test_message_with_attachments(self):
+        # Traversal over bug messages attachments has no errors.
+        expected_messages = []
+        with person_logged_in(self.bugowner):
+            for i in range(3):
+                att = self.factory.makeBugAttachment(self.bug)
+                expected_messages.append(att.message.subject)
+
+        lp_user = self.factory.makePerson()
+        lp = launchpadlib_for("test", lp_user, version="devel")
+        lp_bug = lp.bugs[self.bug.id]
+
+        attachments = lp_bug.attachments
+        messages = [a.message.subject for a in attachments if a.message is not None]
+        self.assertEqual(
+            sorted(messages),
+            sorted(expected_messages))
+
+        
 
 class TestSetCommentVisibility(TestCaseWithFactory):
     """Tests who can successfully set comment visibility."""


Follow ups