Merge lp:~wgrant/launchpad/bug-sharing-policy into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 15833
Proposed branch: lp:~wgrant/launchpad/bug-sharing-policy
Merge into: lp:launchpad
Diff against target: 564 lines (+235/-28)
10 files modified
lib/lp/bugs/browser/tests/test_bugs.py (+28/-1)
lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+47/-3)
lib/lp/bugs/interfaces/bugtarget.py (+23/-0)
lib/lp/bugs/mail/tests/test_handler.py (+24/-1)
lib/lp/bugs/tests/test_bugs_webservice.py (+25/-2)
lib/lp/code/model/branchnamespace.py (+2/-5)
lib/lp/code/model/tests/test_branchnamespace.py (+2/-2)
lib/lp/registry/enums.py (+8/-1)
lib/lp/registry/model/product.py (+10/-1)
lib/lp/registry/tests/test_product.py (+66/-12)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-sharing-policy
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+120385@code.launchpad.net

Commit message

Product.getAllowedBugInformationTypes and getDefaultBugInformationType now respect bug_sharing_policy.

Description of the change

This branch adjusts Product.getAllowedBugInformationTypes and Product.getDefaultBugInformationType to respect bug_sharing_policy, if it's set. If it's not set, private_bugs is respected. Not much code, but lots of tests to cover the various bug filing paths.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

I Suppose my branch to remove the commercial admin restriction needs to land after yours so that I can remove the test hacks.

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/browser/tests/test_bugs.py'
2--- lib/lp/bugs/browser/tests/test_bugs.py 2012-08-08 11:48:29 +0000
3+++ lib/lp/bugs/browser/tests/test_bugs.py 2012-08-20 13:34:33 +0000
4@@ -12,7 +12,11 @@
5 from lp.bugs.interfaces.bugtask import BugTaskStatus
6 from lp.bugs.interfaces.malone import IMaloneApplication
7 from lp.bugs.publisher import BugsLayer
8-from lp.registry.enums import InformationType
9+from lp.registry.enums import (
10+ BugSharingPolicy,
11+ InformationType,
12+ )
13+from lp.registry.interfaces.person import IPersonSet
14 from lp.registry.interfaces.product import License
15 from lp.services.webapp.publisher import canonical_url
16 from lp.testing import (
17@@ -24,6 +28,7 @@
18 )
19 from lp.testing.layers import DatabaseFunctionalLayer
20 from lp.testing.pages import find_tag_by_id
21+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
22 from lp.testing.views import create_initialized_view
23
24
25@@ -175,6 +180,28 @@
26 project.owner, 'title', 'description', project, private=False)
27 self.assertEqual(InformationType.PUBLIC, bug.information_type)
28
29+ def test_createBug_default_sharing_policy_proprietary(self):
30+ # createBug() does not adapt the default kwargs when they are none.
31+ project = self.factory.makeProduct(
32+ licenses=[License.OTHER_PROPRIETARY])
33+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
34+ project.setBugSharingPolicy(
35+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
36+ bug = self.application.createBug(
37+ project.owner, 'title', 'description', project)
38+ self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
39+
40+ def test_createBug_public_bug_sharing_policy_proprietary(self):
41+ # createBug() adapts a kwarg to InformationType if one is is not None.
42+ project = self.factory.makeProduct(
43+ licenses=[License.OTHER_PROPRIETARY])
44+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
45+ project.setBugSharingPolicy(
46+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
47+ bug = self.application.createBug(
48+ project.owner, 'title', 'description', project, private=False)
49+ self.assertEqual(InformationType.PUBLIC, bug.information_type)
50+
51 def test_createBug_default_private_bugs_false(self):
52 # createBug() does not adapt the default kwargs when they are none.
53 project = self.factory.makeProduct(
54
55=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
56--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-14 01:57:17 +0000
57+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-08-20 13:34:33 +0000
58@@ -25,9 +25,11 @@
59 )
60 from lp.bugs.publisher import BugsLayer
61 from lp.registry.enums import (
62+ BugSharingPolicy,
63 InformationType,
64 PRIVATE_INFORMATION_TYPES,
65 )
66+from lp.registry.interfaces.person import IPersonSet
67 from lp.registry.interfaces.projectgroup import IProjectGroup
68 from lp.services.webapp.servers import LaunchpadTestRequest
69 from lp.testing import (
70@@ -41,6 +43,7 @@
71 find_main_content,
72 find_tag_by_id,
73 )
74+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
75 from lp.testing.views import (
76 create_initialized_view,
77 create_view,
78@@ -353,7 +356,7 @@
79 self.assertEqual(expected_guidelines, view.bug_reporting_guidelines)
80
81 def filebug_via_view(self, private_bugs=False, information_type=None,
82- extra_data_token=None):
83+ bug_sharing_policy=None, extra_data_token=None):
84 form = {
85 'field.title': 'A bug',
86 'field.comment': 'A comment',
87@@ -364,6 +367,11 @@
88 product = self.factory.makeProduct(official_malone=True)
89 if private_bugs:
90 removeSecurityProxy(product).private_bugs = True
91+ if bug_sharing_policy:
92+ self.factory.makeCommercialSubscription(product=product)
93+ comadmin = getUtility(IPersonSet).getByEmail(
94+ COMMERCIAL_ADMIN_EMAIL)
95+ product.setBugSharingPolicy(bug_sharing_policy, comadmin)
96 with person_logged_in(product.owner):
97 view = create_view(
98 product, '+filebug', method='POST', form=form,
99@@ -397,6 +405,15 @@
100 InformationType.USERDATA, view.default_information_type)
101 self.assertEqual(InformationType.USERDATA, bug.information_type)
102
103+ def test_filebug_information_type_with_bug_sharing_policy(self):
104+ # If we don't specify the bug's information_type, it follows the
105+ # target's getDefaultBugInformationType().
106+ bug, view = self.filebug_via_view(
107+ bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
108+ self.assertEqual(
109+ InformationType.PROPRIETARY, view.default_information_type)
110+ self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
111+
112 def test_filebug_information_type_with_public_blob(self):
113 # Bugs filed with an apport blob that doesn't request privacy
114 # are public by default.
115@@ -414,7 +431,7 @@
116 InformationType.USERDATA, view.default_information_type)
117 self.assertEqual(InformationType.USERDATA, bug.information_type)
118
119- def test_filebug_information_type_normal_projects(self):
120+ def test_filebug_information_type_public_policy(self):
121 # The vocabulary for information_type when filing a bug is created
122 # correctly for non commercial projects.
123 product = self.factory.makeProduct(official_malone=True)
124@@ -425,6 +442,20 @@
125 soup = BeautifulSoup(html)
126 self.assertIsNone(soup.find('label', text="Proprietary"))
127
128+ def test_filebug_information_type_proprietary_policy(self):
129+ # The vocabulary for information_type when filing a bug is created
130+ # correctly for a project with a proprietary sharing policy.
131+ product = self.factory.makeProduct(official_malone=True)
132+ self.factory.makeCommercialSubscription(product=product)
133+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
134+ product.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)
135+ with person_logged_in(product.owner):
136+ view = create_initialized_view(
137+ product, '+filebug', principal=product.owner)
138+ html = view.render()
139+ soup = BeautifulSoup(html)
140+ self.assertIsNotNone(soup.find('label', text="Proprietary"))
141+
142 def test_filebug_information_type_vocabulary(self):
143 # The vocabulary for information_type when filing a bug is created
144 # correctly.
145@@ -455,7 +486,8 @@
146
147 layer = DatabaseFunctionalLayer
148
149- def filebug_via_view(self, private_bugs=False, security_related=False):
150+ def filebug_via_view(self, private_bugs=False, bug_sharing_policy=None,
151+ security_related=False):
152 form = {
153 'field.title': 'A bug',
154 'field.comment': 'A comment',
155@@ -465,6 +497,11 @@
156 product = self.factory.makeProduct(official_malone=True)
157 if private_bugs:
158 removeSecurityProxy(product).private_bugs = True
159+ if bug_sharing_policy:
160+ self.factory.makeCommercialSubscription(product=product)
161+ comadmin = getUtility(IPersonSet).getByEmail(
162+ COMMERCIAL_ADMIN_EMAIL)
163+ product.setBugSharingPolicy(bug_sharing_policy, comadmin)
164 anyone = self.factory.makePerson()
165 with person_logged_in(anyone):
166 view = create_initialized_view(
167@@ -499,6 +536,13 @@
168 bug = self.filebug_via_view(private_bugs=True)
169 self.assertEqual(InformationType.USERDATA, bug.information_type)
170
171+ def test_filebug_with_proprietary_sharing(self):
172+ # Non security related bugs are PROPRIETARY for products with a
173+ # proprietary sharing policy.
174+ bug = self.filebug_via_view(
175+ bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
176+ self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
177+
178 def test_filebug_view_renders_security_related(self):
179 # The security_related checkbox is rendered for non bug supervisors.
180 product = self.factory.makeProduct(official_malone=True)
181
182=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
183--- lib/lp/bugs/interfaces/bugtarget.py 2012-08-08 03:45:16 +0000
184+++ lib/lp/bugs/interfaces/bugtarget.py 2012-08-20 13:34:33 +0000
185@@ -18,6 +18,8 @@
186 'IOfficialBugTagTargetPublic',
187 'IOfficialBugTagTargetRestricted',
188 'ISeriesBugTarget',
189+ 'POLICY_ALLOWED_TYPES',
190+ 'POLICY_DEFAULT_TYPES',
191 ]
192
193
194@@ -59,6 +61,12 @@
195 BugTagsSearchCombinator,
196 IBugTaskSearch,
197 )
198+from lp.registry.enums import (
199+ BugSharingPolicy,
200+ FREE_INFORMATION_TYPES,
201+ InformationType,
202+ NON_EMBARGOED_INFORMATION_TYPES,
203+ )
204 from lp.services.fields import Tag
205
206
207@@ -197,6 +205,21 @@
208 vocabulary=BugBlueprintSearch, required=False))
209
210
211+POLICY_ALLOWED_TYPES = {
212+ BugSharingPolicy.PUBLIC: FREE_INFORMATION_TYPES,
213+ BugSharingPolicy.PUBLIC_OR_PROPRIETARY: NON_EMBARGOED_INFORMATION_TYPES,
214+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC: NON_EMBARGOED_INFORMATION_TYPES,
215+ BugSharingPolicy.PROPRIETARY: (InformationType.PROPRIETARY,),
216+ }
217+
218+POLICY_DEFAULT_TYPES = {
219+ BugSharingPolicy.PUBLIC: InformationType.PUBLIC,
220+ BugSharingPolicy.PUBLIC_OR_PROPRIETARY: InformationType.PUBLIC,
221+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC: InformationType.PROPRIETARY,
222+ BugSharingPolicy.PROPRIETARY: InformationType.PROPRIETARY,
223+ }
224+
225+
226 class IHasBugs(Interface):
227 """An entity which has a collection of bug tasks."""
228
229
230=== modified file 'lib/lp/bugs/mail/tests/test_handler.py'
231--- lib/lp/bugs/mail/tests/test_handler.py 2012-05-04 00:03:07 +0000
232+++ lib/lp/bugs/mail/tests/test_handler.py 2012-08-20 13:34:33 +0000
233@@ -28,7 +28,11 @@
234 MaloneHandler,
235 )
236 from lp.bugs.model.bugnotification import BugNotification
237-from lp.registry.enums import InformationType
238+from lp.registry.enums import (
239+ BugSharingPolicy,
240+ InformationType,
241+ )
242+from lp.registry.interfaces.person import IPersonSet
243 from lp.services.config import config
244 from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
245 from lp.services.mail import stub
246@@ -48,6 +52,7 @@
247 LaunchpadZopelessLayer,
248 )
249 from lp.testing.mail_helpers import pop_notifications
250+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
251
252
253 class TestMaloneHandler(TestCaseWithFactory):
254@@ -253,6 +258,24 @@
255 self.assertEqual(1, len(bug.bugtasks))
256 self.assertEqual(project, bug.bugtasks[0].target)
257
258+ def test_new_bug_with_sharing_policy_proprietary(self):
259+ project = self.factory.makeProduct(name='fnord')
260+ self.factory.makeCommercialSubscription(product=project)
261+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
262+ project.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)
263+ transaction.commit()
264+ handler = MaloneHandler()
265+ with person_logged_in(project.owner):
266+ msg = self.factory.makeSignedMessage(
267+ body='borked\n affects fnord',
268+ subject='subject borked',
269+ to_address='new@bugs.launchpad.dev')
270+ handler.process(msg, msg['To'])
271+ notification = self.getLatestBugNotification()
272+ bug = notification.bug
273+ self.assertEqual([project.owner], list(bug.getDirectSubscribers()))
274+ self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
275+
276 def test_new_bug_with_one_misplaced_affects_line(self):
277 # Affects commands in the wrong position are processed as the user
278 # intended when the bug is new and there is only one affects.
279
280=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
281--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-08 07:22:51 +0000
282+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-08-20 13:34:33 +0000
283@@ -19,11 +19,18 @@
284 Equals,
285 LessThan,
286 )
287-from zope.component import getMultiAdapter
288+from zope.component import (
289+ getMultiAdapter,
290+ getUtility,
291+ )
292
293 from lp.bugs.browser.bugtask import get_comments_for_bugtask
294 from lp.bugs.interfaces.bug import IBug
295-from lp.registry.enums import InformationType
296+from lp.registry.enums import (
297+ BugSharingPolicy,
298+ InformationType,
299+ )
300+from lp.registry.interfaces.person import IPersonSet
301 from lp.registry.interfaces.product import License
302 from lp.services.webapp import snapshot
303 from lp.services.webapp.servers import LaunchpadTestRequest
304@@ -45,6 +52,7 @@
305 from lp.testing.pages import LaunchpadWebServiceCaller
306 from lp.testing.sampledata import (
307 ADMIN_EMAIL,
308+ COMMERCIAL_ADMIN_EMAIL,
309 USER_EMAIL,
310 )
311
312@@ -399,3 +407,18 @@
313 target=api_url(project), title='title', description='desc',
314 private=True)
315 self.assertEqual('Private', bug.information_type)
316+
317+ def test_default_sharing_policy_proprietary(self):
318+ # Verify the path through user submission, to MaloneApplication to
319+ # BugSet, and back to the user creates a private bug according
320+ # to the project's bug sharing policy.
321+ project = self.factory.makeProduct(
322+ licenses=[License.OTHER_PROPRIETARY])
323+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
324+ project.setBugSharingPolicy(
325+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
326+ webservice = launchpadlib_for('test', 'salgado')
327+ bugs_collection = webservice.load('/bugs')
328+ bug = bugs_collection.createBug(
329+ target=api_url(project), title='title', description='desc')
330+ self.assertEqual('Proprietary', bug.information_type)
331
332=== modified file 'lib/lp/code/model/branchnamespace.py'
333--- lib/lp/code/model/branchnamespace.py 2012-08-16 21:57:43 +0000
334+++ lib/lp/code/model/branchnamespace.py 2012-08-20 13:34:33 +0000
335@@ -47,6 +47,8 @@
336 from lp.code.model.branch import Branch
337 from lp.registry.enums import (
338 BranchSharingPolicy,
339+ FREE_INFORMATION_TYPES,
340+ FREE_PRIVATE_INFORMATION_TYPES,
341 InformationType,
342 PersonVisibility,
343 NON_EMBARGOED_INFORMATION_TYPES,
344@@ -82,11 +84,6 @@
345 )
346
347
348-FREE_PRIVATE_INFORMATION_TYPES = (
349- InformationType.PRIVATESECURITY, InformationType.USERDATA)
350-FREE_INFORMATION_TYPES = (
351- PUBLIC_INFORMATION_TYPES + FREE_PRIVATE_INFORMATION_TYPES)
352-
353 POLICY_ALLOWED_TYPES = {
354 BranchSharingPolicy.PUBLIC: FREE_INFORMATION_TYPES,
355 BranchSharingPolicy.PUBLIC_OR_PROPRIETARY: NON_EMBARGOED_INFORMATION_TYPES,
356
357=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
358--- lib/lp/code/model/tests/test_branchnamespace.py 2012-08-17 04:48:04 +0000
359+++ lib/lp/code/model/tests/test_branchnamespace.py 2012-08-20 13:34:33 +0000
360@@ -32,14 +32,14 @@
361 )
362 from lp.code.interfaces.branchtarget import IBranchTarget
363 from lp.code.model.branchnamespace import (
364- FREE_INFORMATION_TYPES,
365- FREE_PRIVATE_INFORMATION_TYPES,
366 PackageNamespace,
367 PersonalNamespace,
368 ProductNamespace,
369 )
370 from lp.registry.enums import (
371 BranchSharingPolicy,
372+ FREE_INFORMATION_TYPES,
373+ FREE_PRIVATE_INFORMATION_TYPES,
374 InformationType,
375 NON_EMBARGOED_INFORMATION_TYPES,
376 PersonVisibility,
377
378=== modified file 'lib/lp/registry/enums.py'
379--- lib/lp/registry/enums.py 2012-08-16 21:57:43 +0000
380+++ lib/lp/registry/enums.py 2012-08-20 13:34:33 +0000
381@@ -10,6 +10,8 @@
382 'DistroSeriesDifferenceStatus',
383 'DistroSeriesDifferenceType',
384 'EXCLUSIVE_TEAM_POLICY',
385+ 'FREE_INFORMATION_TYPES',
386+ 'FREE_PRIVATE_INFORMATION_TYPES',
387 'INCLUSIVE_TEAM_POLICY',
388 'InformationType',
389 'NON_EMBARGOED_INFORMATION_TYPES',
390@@ -77,7 +79,6 @@
391 PUBLIC_INFORMATION_TYPES = (
392 InformationType.PUBLIC, InformationType.PUBLICSECURITY)
393
394-
395 PRIVATE_INFORMATION_TYPES = (
396 InformationType.PRIVATESECURITY, InformationType.USERDATA,
397 InformationType.PROPRIETARY, InformationType.EMBARGOED)
398@@ -90,6 +91,12 @@
399 SECURITY_INFORMATION_TYPES = (
400 InformationType.PUBLICSECURITY, InformationType.PRIVATESECURITY)
401
402+FREE_PRIVATE_INFORMATION_TYPES = (
403+ InformationType.PRIVATESECURITY, InformationType.USERDATA)
404+
405+FREE_INFORMATION_TYPES = (
406+ PUBLIC_INFORMATION_TYPES + FREE_PRIVATE_INFORMATION_TYPES)
407+
408
409 class SharingPermission(DBEnumeratedType):
410 """Sharing permission.
411
412=== modified file 'lib/lp/registry/model/product.py'
413--- lib/lp/registry/model/product.py 2012-08-17 05:05:37 +0000
414+++ lib/lp/registry/model/product.py 2012-08-20 13:34:33 +0000
415@@ -91,6 +91,10 @@
416 from lp.blueprints.model.sprint import HasSprintsMixin
417 from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
418 from lp.bugs.interfaces.bugsupervisor import IHasBugSupervisor
419+from lp.bugs.interfaces.bugtarget import (
420+ POLICY_ALLOWED_TYPES,
421+ POLICY_DEFAULT_TYPES,
422+ )
423 from lp.bugs.interfaces.bugtaskfilter import OrderedBugTask
424 from lp.bugs.model.bugtarget import (
425 BugTargetBase,
426@@ -595,6 +599,9 @@
427
428 def getAllowedBugInformationTypes(self):
429 """See `IProduct.`"""
430+ if self.bug_sharing_policy is not None:
431+ return POLICY_ALLOWED_TYPES[self.bug_sharing_policy]
432+
433 types = set(InformationType.items)
434 types.discard(InformationType.PROPRIETARY)
435 types.discard(InformationType.EMBARGOED)
436@@ -602,7 +609,9 @@
437
438 def getDefaultBugInformationType(self):
439 """See `IDistribution.`"""
440- if self.private_bugs:
441+ if self.bug_sharing_policy is not None:
442+ return POLICY_DEFAULT_TYPES[self.bug_sharing_policy]
443+ elif self.private_bugs:
444 return InformationType.USERDATA
445 else:
446 return InformationType.PUBLIC
447
448=== modified file 'lib/lp/registry/tests/test_product.py'
449--- lib/lp/registry/tests/test_product.py 2012-08-17 05:05:37 +0000
450+++ lib/lp/registry/tests/test_product.py 2012-08-20 13:34:33 +0000
451@@ -32,6 +32,7 @@
452 BranchSharingPolicy,
453 BugSharingPolicy,
454 EXCLUSIVE_TEAM_POLICY,
455+ FREE_INFORMATION_TYPES,
456 INCLUSIVE_TEAM_POLICY,
457 InformationType,
458 )
459@@ -44,6 +45,7 @@
460 IAccessPolicySource,
461 )
462 from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
463+from lp.registry.interfaces.person import IPersonSet
464 from lp.registry.interfaces.product import (
465 IProduct,
466 IProductSet,
467@@ -79,6 +81,7 @@
468 get_feedback_messages,
469 setupBrowser,
470 )
471+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
472 from lp.translations.enums import TranslationPermission
473 from lp.translations.interfaces.customlanguagecode import (
474 IHasCustomLanguageCodes,
475@@ -377,26 +380,77 @@
476 grantees = set([grant.grantee for grant in grants])
477 self.assertEqual(expected_grantess, grantees)
478
479- def test_getAllowedBugInformationTypes(self):
480- # All projects currently support just the non-proprietary
481- # information types.
482+
483+class TestProductBugInformationTypes(TestCaseWithFactory):
484+
485+ layer = DatabaseFunctionalLayer
486+
487+ def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False):
488+ product = self.factory.makeProduct(private_bugs=private_bugs)
489+ self.factory.makeCommercialSubscription(product=product)
490+ comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
491+ product.setBugSharingPolicy(bug_sharing_policy, comadmin)
492+ return product
493+
494+ def test_no_policy(self):
495+ # New projects can only use the non-proprietary information
496+ # types.
497+ product = self.factory.makeProduct()
498 self.assertContentEqual(
499- [InformationType.PUBLIC, InformationType.PUBLICSECURITY,
500- InformationType.PRIVATESECURITY, InformationType.USERDATA],
501- self.factory.makeProduct().getAllowedBugInformationTypes())
502-
503- def test_getDefaultBugInformationType_public(self):
504- # The default information type for normal projects is PUBLIC.
505- product = self.factory.makeProduct()
506+ FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
507 self.assertEqual(
508 InformationType.PUBLIC, product.getDefaultBugInformationType())
509
510- def test_getDefaultBugInformationType_private(self):
511- # private_bugs overrides the default information type to USERDATA.
512+ def test_legacy_private_bugs(self):
513+ # The deprecated private_bugs attribute overrides the default
514+ # information type to USERDATA.
515 product = self.factory.makeProduct(private_bugs=True)
516+ self.assertContentEqual(
517+ FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
518 self.assertEqual(
519 InformationType.USERDATA, product.getDefaultBugInformationType())
520
521+ def test_sharing_policy_overrides_private_bugs(self):
522+ # bug_sharing_policy overrides private_bugs.
523+ product = self.makeProductWithPolicy(
524+ BugSharingPolicy.PUBLIC, private_bugs=True)
525+ self.assertContentEqual(
526+ FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
527+ self.assertEqual(
528+ InformationType.PUBLIC, product.getDefaultBugInformationType())
529+
530+ def test_sharing_policy_public_or_proprietary(self):
531+ # bug_sharing_policy can enable Proprietary.
532+ product = self.makeProductWithPolicy(
533+ BugSharingPolicy.PUBLIC_OR_PROPRIETARY)
534+ self.assertContentEqual(
535+ FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
536+ product.getAllowedBugInformationTypes())
537+ self.assertEqual(
538+ InformationType.PUBLIC,
539+ product.getDefaultBugInformationType())
540+
541+ def test_sharing_policy_proprietary_or_public(self):
542+ # bug_sharing_policy can enable and default to Proprietary.
543+ product = self.makeProductWithPolicy(
544+ BugSharingPolicy.PROPRIETARY_OR_PUBLIC)
545+ self.assertContentEqual(
546+ FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
547+ product.getAllowedBugInformationTypes())
548+ self.assertEqual(
549+ InformationType.PROPRIETARY,
550+ product.getDefaultBugInformationType())
551+
552+ def test_sharing_policy_proprietary(self):
553+ # bug_sharing_policy can enable only Proprietary.
554+ product = self.makeProductWithPolicy(BugSharingPolicy.PROPRIETARY)
555+ self.assertContentEqual(
556+ [InformationType.PROPRIETARY],
557+ product.getAllowedBugInformationTypes())
558+ self.assertEqual(
559+ InformationType.PROPRIETARY,
560+ product.getDefaultBugInformationType())
561+
562
563 class TestProductFiles(TestCase):
564 """Tests for downloadable product files."""