Merge lp:~allenap/launchpad/mantis-no-return-path-exception-bug-227334-2 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 12249
Proposed branch: lp:~allenap/launchpad/mantis-no-return-path-exception-bug-227334-2
Merge into: lp:launchpad
Diff against target: 118 lines (+23/-15)
3 files modified
lib/lp/bugs/doc/externalbugtracker-mantis-logging-in.txt (+8/-4)
lib/lp/bugs/externalbugtracker/mantis.py (+8/-6)
lib/lp/bugs/tests/test_bugtracker.py (+7/-5)
To merge this branch: bzr merge lp:~allenap/launchpad/mantis-no-return-path-exception-bug-227334-2
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+46994@code.launchpad.net

Commit message

[r=allenap][ui=none][bug=227334] Raise a BugTrackerConnectError in MantisLoginHandler instead of raising BugWatchUpdateWarning.

Description of the change

Changes the exception that comes out when Launchpad fails to log-in to a remote Mantis instance.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/doc/externalbugtracker-mantis-logging-in.txt'
2--- lib/lp/bugs/doc/externalbugtracker-mantis-logging-in.txt 2009-06-12 16:36:02 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-mantis-logging-in.txt 2011-01-20 23:23:56 +0000
4@@ -1,10 +1,13 @@
5-= Logging into a Mantis instance =
6+Logging into a Mantis instance
7+------------------------------
8
9 Mantis is... special. In a headless/batch environment we must do a
10 little dance in order to log in. Thankfully, we can encapsulate this
11 neatly in a urllib2-style handler.
12
13-== MantisLoginHandler ==
14+
15+MantisLoginHandler
16+==================
17
18 >>> from lp.bugs.externalbugtracker import (
19 ... MantisLoginHandler)
20@@ -47,8 +50,9 @@
21 ... 'http://mantis.example.com/login_page.php')
22 Traceback (most recent call last):
23 ...
24- BugWatchUpdateWarning: Mantis redirected us to the login page but
25- did not set a return path.
26+ BugTrackerConnectError: http://mantis.example.com/login_page.php:
27+ Mantis redirected us to the login page but did not set a return
28+ path.
29
30 In all likelihood, this warning will be followed in the log by an
31 error.
32
33=== modified file 'lib/lp/bugs/externalbugtracker/mantis.py'
34--- lib/lp/bugs/externalbugtracker/mantis.py 2011-01-19 00:10:48 +0000
35+++ lib/lp/bugs/externalbugtracker/mantis.py 2011-01-20 23:23:56 +0000
36@@ -23,7 +23,6 @@
37 BugNotFound,
38 BugTrackerConnectError,
39 BugWatchUpdateError,
40- BugWatchUpdateWarning,
41 ExternalBugTracker,
42 InvalidBugId,
43 LookupTree,
44@@ -50,10 +49,13 @@
45 https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3301
46
47 2. Mantis redirects us to:
48- .../alsa-bug/login_page.php?return=%2Falsa-bug%2Fview.php%3Fid%3D3301
49+ .../alsa-bug/login_page.php?
50+ return=%2Falsa-bug%2Fview.php%3Fid%3D3301
51
52 3. We notice this, rewrite the query, and skip to login.php:
53- .../alsa-bug/login.php?return=%2Falsa-bug%2Fview.php%3Fid%3D3301&username=guest&password=guest
54+ .../alsa-bug/login.php?
55+ return=%2Falsa-bug%2Fview.php%3Fid%3D3301&
56+ username=guest&password=guest
57
58 4. Mantis accepts our credentials then redirects us to the bug
59 view page via a cookie test page (login_cookie_test.php)
60@@ -73,9 +75,9 @@
61 query = cgi.parse_qs(query, True)
62 query['username'] = query['password'] = ['guest']
63 if 'return' not in query:
64- raise BugWatchUpdateWarning(
65- "Mantis redirected us to the login page "
66- "but did not set a return path.")
67+ raise BugTrackerConnectError(
68+ url, ("Mantis redirected us to the login page "
69+ "but did not set a return path."))
70
71 query = urllib.urlencode(query, True)
72 url = urlunparse(
73
74=== modified file 'lib/lp/bugs/tests/test_bugtracker.py'
75--- lib/lp/bugs/tests/test_bugtracker.py 2010-10-04 19:50:45 +0000
76+++ lib/lp/bugs/tests/test_bugtracker.py 2011-01-20 23:23:56 +0000
77@@ -3,8 +3,6 @@
78
79 __metaclass__ = type
80
81-import unittest
82-import transaction
83 from datetime import (
84 datetime,
85 timedelta,
86@@ -14,6 +12,7 @@
87 ELLIPSIS,
88 NORMALIZE_WHITESPACE,
89 )
90+import unittest
91 from urllib2 import (
92 HTTPError,
93 Request,
94@@ -21,12 +20,11 @@
95
96 from lazr.lifecycle.snapshot import Snapshot
97 from pytz import utc
98-
99+import transaction
100 from zope.component import getUtility
101 from zope.security.interfaces import Unauthorized
102 from zope.security.proxy import removeSecurityProxy
103
104-from canonical.launchpad.ftests import login_person
105 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
106 from canonical.testing.layers import (
107 DatabaseFunctionalLayer,
108@@ -44,7 +42,11 @@
109 from lp.bugs.model.bugtracker import BugTrackerSet
110 from lp.bugs.tests.externalbugtracker import Urlib2TransportTestHandler
111 from lp.registry.interfaces.person import IPersonSet
112-from lp.testing import login, login_person, TestCaseWithFactory
113+from lp.testing import (
114+ login,
115+ login_person,
116+ TestCaseWithFactory,
117+ )
118 from lp.testing.sampledata import ADMIN_EMAIL
119
120