launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21967
[Merge] lp:~cjwatson/launchpad/bugzilla-without-credentials into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bugzilla-without-credentials into lp:launchpad.
Commit message:
Don't attempt comment pushing or back-linking for BugzillaAPI instances without credentials.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1678486 in Launchpad itself: "Enable watching Red Hat Bugzilla bugs"
https://bugs.launchpad.net/launchpad/+bug/1678486
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bugzilla-without-credentials/+merge/332735
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bugzilla-without-credentials into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-10-20 11:07:01 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-10-24 18:14:16 +0000
@@ -595,6 +595,15 @@
>>> verifyObject(ISupportsCommentPushing, bugzilla)
True
+If an instance of BugzillaAPI does not have suitable credentials set up,
+then that instance does not provide ISupportsCommentPushing.
+
+ >>> verifyObject(ISupportsCommentPushing, BugzillaAPI(
+ ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
+ Traceback (most recent call last):
+ ...
+ DoesNotImplement: ...
+
ISupportsCommentPushing.addRemoteComment() is the method used to push a
comment to the remote server. It takes three parameters: the remote bug
ID, the body of the comment to push and the rfc822msgid of the comment
@@ -647,6 +656,15 @@
>>> verifyObject(ISupportsBackLinking, bugzilla)
True
+If an instance of BugzillaAPI does not have suitable credentials set up,
+then that instance does not provide ISupportsBackLinking.
+
+ >>> verifyObject(ISupportsBackLinking, BugzillaAPI(
+ ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
+ Traceback (most recent call last):
+ ...
+ DoesNotImplement: ...
+
BugzillaAPI.setLaunchpadBugId() can be used to set the Launchpad bug ID
for a given bug.
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2017-10-24 08:26:00 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2017-10-24 18:14:16 +0000
@@ -23,7 +23,10 @@
import pytz
import six
from zope.component import getUtility
-from zope.interface import implementer
+from zope.interface import (
+ alsoProvides,
+ implementer,
+ )
from lp.bugs.externalbugtracker.base import (
BugNotFound,
@@ -551,8 +554,7 @@
return decorator
-@implementer(
- ISupportsBackLinking, ISupportsCommentImport, ISupportsCommentPushing)
+@implementer(ISupportsCommentImport)
class BugzillaAPI(Bugzilla):
"""An `ExternalBugTracker` to handle Bugzillas that offer an API."""
@@ -570,6 +572,14 @@
else:
self.xmlrpc_transport = xmlrpc_transport
+ try:
+ self.credentials
+ except BugTrackerAuthenticationError:
+ pass
+ else:
+ alsoProvides(self, ISupportsBackLinking)
+ alsoProvides(self, ISupportsCommentPushing)
+
def getExternalBugTrackerToUse(self):
"""The Bugzilla API has been chosen, so return self."""
return self
=== modified file 'lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py'
--- lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2017-10-24 18:14:16 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2017 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for the checkwatches.bugwatchupdater module."""
@@ -223,7 +223,7 @@
# This test can be removed when bug 578714 is fixed.
remote_bug_updater = RemoteBugUpdater(
self.checkwatches_master,
- BugzillaAPI("http://example.com"),
+ BugzillaAPI("http://bugzilla-3.4.example.com"),
self.bug_watch.remotebug, [self.bug_watch.id],
[], datetime.now())
bug_watch_updater = LoggingBugWatchUpdater(
Follow ups