launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14866
[Merge] lp:~sinzui/launchpad/create-bug-info-type-api into lp:launchpad
Curtis Hovey has proposed merging lp:~sinzui/launchpad/create-bug-info-type-api into lp:launchpad.
Commit message:
Allow users to create Proprietary bugs using the API.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1092650 in Launchpad itself: "Cannot create a proprietary bug using the API"
https://bugs.launchpad.net/launchpad/+bug/1092650
For more details, see:
https://code.launchpad.net/~sinzui/launchpad/create-bug-info-type-api/+merge/140989
IMaloneApplication.createBug() is not aware of information_type. It can
subvert a project's bug_sharing_policy.
Case 1. It is not possible to create a Proprietary bug on a project with
the bug_sharing_policy set to "Public, can be proprietary".
Case 2. Many pre-sharing scripts always pass the private parameter to
createBug() to ensure ensure the bug is not public and regardless of the
project the bug is reported against. This parameter subverts the
bug_sharing_policy set to "Proprietary, can be public" rule because no
bugs reported via the script will ever be Proprietary. The bugs can
always be shared with another project though that is not the intent.
RULES
Pre-implementation: no one
* Add information_type to IMaloneApplication.createBug()
* Update the documentation to explain what really happens.
QA
* Run this script:
{{{
from launchpadlib.launchpad import Launchpad
lp = Launchpad.login_with(
'testing', service_root='https://api.qastaging.launchpad.net',
version='devel')
project = lp.projects['launchpad-help-moin-theme']
bug = lp.bugs.createBug(
target=project,
title='Created via the API',
description='This bug must be created as Proprietary',
information_type='Proprietary')
print bug.web_link
print bug.information_type
}}}
LINT
lib/lp/systemhomes.py
lib/lp/bugs/interfaces/malone.py
lib/lp/bugs/tests/test_bugs_webservice.py
LoC
I have more than 10,000 lines of credit this week.
TEST
./bin/test -vvc -t BugSetTestCase lp.bugs.tests
IMPLEMENTATION
Added the information_type arg and revised the documentation.
lib/lp/systemhomes.py
lib/lp/bugs/interfaces/malone.py
lib/lp/bugs/tests/test_bugs_webservice.py
--
https://code.launchpad.net/~sinzui/launchpad/create-bug-info-type-api/+merge/140989
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/create-bug-info-type-api into lp:launchpad.
=== modified file 'lib/lp/bugs/interfaces/malone.py'
--- lib/lp/bugs/interfaces/malone.py 2012-08-07 23:33:51 +0000
+++ lib/lp/bugs/interfaces/malone.py 2012-12-20 20:19:24 +0000
@@ -76,24 +76,32 @@
title=u"The project, distribution or source package that has "
"this bug."))
@export_factory_operation(
- IBug, ['title', 'description', 'tags', 'security_related', 'private'])
- def createBug(owner, title, description, target, security_related=None,
- private=None, tags=None):
+ IBug, ['title', 'description', 'tags', 'information_type',
+ 'security_related', 'private'])
+ def createBug(owner, title, description, target, information_type=None,
+ tags=None, security_related=None, private=None):
"""Create a bug (with an appropriate bugtask) and return it.
- :param target: The Product, Distribution or DistributionSourcePackage
+ :param target: The Project, Distribution or DistributionSourcePackage
affected by this bug.
+ :param title: The title shown in bug listings.
+ :param description: The description of the issue.
+ :param information_type: Set the bug's information type to one
+ different from the project's default. The type must conform
+ to the project's bug sharing policy. (optional)
+ :param tags: A list of bug tags. (optional)
+ :param security_related: Is this bug's information type
+ Private Security? (deprecated)
+ :param tags: Is this bug's information type Private
+ user data. (deprecated)
Things to note when using this factory:
- * the owner will be subscribed to the bug
-
- * distribution, product and package contacts (whichever ones are
- applicable based on the bug report target) will be subscribed to
- all *public bugs only*
-
- * for public upstreams bugs where there is no upstream bug contact,
- the product owner will be subscribed instead
+ * The reporter will be subscribed to the bug.
+
+ * Only people that the project shares with will see the bug
+ when the bug's information type is Proprietary, Private, or
+ Private Security.
"""
=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-10-12 14:53:10 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-12-20 20:19:24 +0000
@@ -400,22 +400,38 @@
layer = DatabaseFunctionalLayer
+ def makeAPITarget(self, bug_policy):
+ project = self.factory.makeProduct(
+ licenses=[License.OTHER_PROPRIETARY])
+ target_url = api_url(project)
+ with person_logged_in(project.owner):
+ project.setBugSharingPolicy(bug_policy)
+ return target_url
+
+ def getBugsCollection(self):
+ webservice = launchpadlib_for('test', 'salgado')
+ return webservice.load('/bugs')
+
def test_default_sharing_policy_proprietary(self):
# Verify the path through user submission, to MaloneApplication to
# BugSet, and back to the user creates a private bug according
# to the project's bug sharing policy.
- project = self.factory.makeProduct(
- licenses=[License.OTHER_PROPRIETARY])
- target_url = api_url(project)
- with person_logged_in(project.owner):
- project.setBugSharingPolicy(
- BugSharingPolicy.PROPRIETARY_OR_PUBLIC)
- webservice = launchpadlib_for('test', 'salgado')
- bugs_collection = webservice.load('/bugs')
+ target_url = self.makeAPITarget(BugSharingPolicy.PROPRIETARY_OR_PUBLIC)
+ bugs_collection = self.getBugsCollection()
bug = bugs_collection.createBug(
target=target_url, title='title', description='desc')
self.assertEqual('Proprietary', bug.information_type)
+ def test_override_default_sharing_policy_proprietary(self):
+ # A Proprietary bug can be created if the porject's bug sharing policy
+ # permits it.
+ target_url = self.makeAPITarget(BugSharingPolicy.PUBLIC_OR_PROPRIETARY)
+ bugs_collection = self.getBugsCollection()
+ bug = bugs_collection.createBug(
+ target=target_url, title='title', description='desc',
+ information_type='Proprietary')
+ self.assertEqual('Proprietary', bug.information_type)
+
class TestBugDateLastUpdated(TestCaseWithFactory):
=== modified file 'lib/lp/systemhomes.py'
--- lib/lp/systemhomes.py 2012-09-19 01:19:35 +0000
+++ lib/lp/systemhomes.py 2012-12-20 20:19:24 +0000
@@ -147,12 +147,12 @@
return data
def createBug(self, owner, title, description, target,
- security_related=None, private=None, tags=None):
+ information_type=None, tags=None,
+ security_related=None, private=None):
"""See `IMaloneApplication`."""
- if security_related is None and private is None:
- # Nothing to adapt, let BugSet.createBug() choose the default.
- information_type = None
- else:
+ if (information_type is None
+ and (security_related is not None or private is not None)):
+ # Adapt the deprecated args to information_type.
information_type = convert_to_information_type(
private, security_related)
params = CreateBugParams(
Follow ups