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
=== 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 @@
595 >>> verifyObject(ISupportsCommentPushing, bugzilla)595 >>> verifyObject(ISupportsCommentPushing, bugzilla)
596 True596 True
597597
598If an instance of BugzillaAPI does not have suitable credentials set up,
599then that instance does not provide ISupportsCommentPushing.
600
601 >>> verifyObject(ISupportsCommentPushing, BugzillaAPI(
602 ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
603 Traceback (most recent call last):
604 ...
605 DoesNotImplement: ...
606
598ISupportsCommentPushing.addRemoteComment() is the method used to push a607ISupportsCommentPushing.addRemoteComment() is the method used to push a
599comment to the remote server. It takes three parameters: the remote bug608comment to the remote server. It takes three parameters: the remote bug
600ID, the body of the comment to push and the rfc822msgid of the comment609ID, the body of the comment to push and the rfc822msgid of the comment
@@ -647,6 +656,15 @@
647 >>> verifyObject(ISupportsBackLinking, bugzilla)656 >>> verifyObject(ISupportsBackLinking, bugzilla)
648 True657 True
649658
659If an instance of BugzillaAPI does not have suitable credentials set up,
660then that instance does not provide ISupportsBackLinking.
661
662 >>> verifyObject(ISupportsBackLinking, BugzillaAPI(
663 ... 'http://unknown.example.com/', xmlrpc_transport=test_transport))
664 Traceback (most recent call last):
665 ...
666 DoesNotImplement: ...
667
650BugzillaAPI.setLaunchpadBugId() can be used to set the Launchpad bug ID668BugzillaAPI.setLaunchpadBugId() can be used to set the Launchpad bug ID
651for a given bug.669for a given bug.
652670
653671
=== 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 @@
23import pytz23import pytz
24import six24import six
25from zope.component import getUtility25from zope.component import getUtility
26from zope.interface import implementer26from zope.interface import (
27 alsoProvides,
28 implementer,
29 )
2730
28from lp.bugs.externalbugtracker.base import (31from lp.bugs.externalbugtracker.base import (
29 BugNotFound,32 BugNotFound,
@@ -551,8 +554,7 @@
551 return decorator554 return decorator
552555
553556
554@implementer(557@implementer(ISupportsCommentImport)
555 ISupportsBackLinking, ISupportsCommentImport, ISupportsCommentPushing)
556class BugzillaAPI(Bugzilla):558class BugzillaAPI(Bugzilla):
557 """An `ExternalBugTracker` to handle Bugzillas that offer an API."""559 """An `ExternalBugTracker` to handle Bugzillas that offer an API."""
558560
@@ -570,6 +572,14 @@
570 else:572 else:
571 self.xmlrpc_transport = xmlrpc_transport573 self.xmlrpc_transport = xmlrpc_transport
572574
575 try:
576 self.credentials
577 except BugTrackerAuthenticationError:
578 pass
579 else:
580 alsoProvides(self, ISupportsBackLinking)
581 alsoProvides(self, ISupportsCommentPushing)
582
573 def getExternalBugTrackerToUse(self):583 def getExternalBugTrackerToUse(self):
574 """The Bugzilla API has been chosen, so return self."""584 """The Bugzilla API has been chosen, so return self."""
575 return self585 return self
576586
=== 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 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for the checkwatches.bugwatchupdater module."""4"""Tests for the checkwatches.bugwatchupdater module."""
@@ -223,7 +223,7 @@
223 # This test can be removed when bug 578714 is fixed.223 # This test can be removed when bug 578714 is fixed.
224 remote_bug_updater = RemoteBugUpdater(224 remote_bug_updater = RemoteBugUpdater(
225 self.checkwatches_master,225 self.checkwatches_master,
226 BugzillaAPI("http://example.com"),226 BugzillaAPI("http://bugzilla-3.4.example.com"),
227 self.bug_watch.remotebug, [self.bug_watch.id],227 self.bug_watch.remotebug, [self.bug_watch.id],
228 [], datetime.now())228 [], datetime.now())
229 bug_watch_updater = LoggingBugWatchUpdater(229 bug_watch_updater = LoggingBugWatchUpdater(