Merge lp:~cjwatson/launchpad/bugzilla-without-credentials into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18491
Proposed branch: lp:~cjwatson/launchpad/bugzilla-without-credentials
Merge into: lp:launchpad
Diff against target: 95 lines (+33/-5)
3 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+18/-0)
lib/lp/bugs/externalbugtracker/bugzilla.py (+13/-3)
lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py (+2/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/bugzilla-without-credentials
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+332735@code.launchpad.net

Commit message

Don't attempt comment pushing or back-linking for BugzillaAPI instances without credentials.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

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-bugzilla-api.txt'
2--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-10-20 11:07:01 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-10-24 18:14:16 +0000
4@@ -595,6 +595,15 @@
5 >>> verifyObject(ISupportsCommentPushing, bugzilla)
6 True
7
8+If an instance of BugzillaAPI does not have suitable credentials set up,
9+then that instance does not provide ISupportsCommentPushing.
10+
11+ >>> verifyObject(ISupportsCommentPushing, BugzillaAPI(
12+ ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
13+ Traceback (most recent call last):
14+ ...
15+ DoesNotImplement: ...
16+
17 ISupportsCommentPushing.addRemoteComment() is the method used to push a
18 comment to the remote server. It takes three parameters: the remote bug
19 ID, the body of the comment to push and the rfc822msgid of the comment
20@@ -647,6 +656,15 @@
21 >>> verifyObject(ISupportsBackLinking, bugzilla)
22 True
23
24+If an instance of BugzillaAPI does not have suitable credentials set up,
25+then that instance does not provide ISupportsBackLinking.
26+
27+ >>> verifyObject(ISupportsBackLinking, BugzillaAPI(
28+ ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
29+ Traceback (most recent call last):
30+ ...
31+ DoesNotImplement: ...
32+
33 BugzillaAPI.setLaunchpadBugId() can be used to set the Launchpad bug ID
34 for a given bug.
35
36
37=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
38--- lib/lp/bugs/externalbugtracker/bugzilla.py 2017-10-24 08:26:00 +0000
39+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2017-10-24 18:14:16 +0000
40@@ -23,7 +23,10 @@
41 import pytz
42 import six
43 from zope.component import getUtility
44-from zope.interface import implementer
45+from zope.interface import (
46+ alsoProvides,
47+ implementer,
48+ )
49
50 from lp.bugs.externalbugtracker.base import (
51 BugNotFound,
52@@ -551,8 +554,7 @@
53 return decorator
54
55
56-@implementer(
57- ISupportsBackLinking, ISupportsCommentImport, ISupportsCommentPushing)
58+@implementer(ISupportsCommentImport)
59 class BugzillaAPI(Bugzilla):
60 """An `ExternalBugTracker` to handle Bugzillas that offer an API."""
61
62@@ -570,6 +572,14 @@
63 else:
64 self.xmlrpc_transport = xmlrpc_transport
65
66+ try:
67+ self.credentials
68+ except BugTrackerAuthenticationError:
69+ pass
70+ else:
71+ alsoProvides(self, ISupportsBackLinking)
72+ alsoProvides(self, ISupportsCommentPushing)
73+
74 def getExternalBugTrackerToUse(self):
75 """The Bugzilla API has been chosen, so return self."""
76 return self
77
78=== modified file 'lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py'
79--- lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2012-01-01 02:58:52 +0000
80+++ lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2017-10-24 18:14:16 +0000
81@@ -1,4 +1,4 @@
82-# Copyright 2010 Canonical Ltd. This software is licensed under the
83+# Copyright 2010-2017 Canonical Ltd. This software is licensed under the
84 # GNU Affero General Public License version 3 (see the file LICENSE).
85
86 """Tests for the checkwatches.bugwatchupdater module."""
87@@ -223,7 +223,7 @@
88 # This test can be removed when bug 578714 is fixed.
89 remote_bug_updater = RemoteBugUpdater(
90 self.checkwatches_master,
91- BugzillaAPI("http://example.com"),
92+ BugzillaAPI("http://bugzilla-3.4.example.com"),
93 self.bug_watch.remotebug, [self.bug_watch.id],
94 [], datetime.now())
95 bug_watch_updater = LoggingBugWatchUpdater(