← Back to team overview

launchpad-reviewers team mailing list archive

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

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-sharing-policy into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-sharing-policy/+merge/120385

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.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-sharing-policy/+merge/120385
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-sharing-policy into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/tests/test_bugs.py'
--- lib/lp/bugs/browser/tests/test_bugs.py	2012-08-08 11:48:29 +0000
+++ lib/lp/bugs/browser/tests/test_bugs.py	2012-08-20 13:22:45 +0000
@@ -12,7 +12,11 @@
 from lp.bugs.interfaces.bugtask import BugTaskStatus
 from lp.bugs.interfaces.malone import IMaloneApplication
 from lp.bugs.publisher import BugsLayer
-from lp.registry.enums import InformationType
+from lp.registry.enums import (
+    BugSharingPolicy,
+    InformationType,
+    )
+from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.product import License
 from lp.services.webapp.publisher import canonical_url
 from lp.testing import (
@@ -24,6 +28,7 @@
     )
 from lp.testing.layers import DatabaseFunctionalLayer
 from lp.testing.pages import find_tag_by_id
+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
 from lp.testing.views import create_initialized_view
 
 
@@ -175,6 +180,28 @@
                 project.owner, 'title', 'description', project, private=False)
             self.assertEqual(InformationType.PUBLIC, bug.information_type)
 
+    def test_createBug_default_sharing_policy_proprietary(self):
+        # createBug() does not adapt the default kwargs when they are none.
+        project = self.factory.makeProduct(
+            licenses=[License.OTHER_PROPRIETARY])
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        project.setBugSharingPolicy(
+            BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
+        bug = self.application.createBug(
+            project.owner, 'title', 'description', project)
+        self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
+
+    def test_createBug_public_bug_sharing_policy_proprietary(self):
+        # createBug() adapts a kwarg to InformationType if one is is not None.
+        project = self.factory.makeProduct(
+            licenses=[License.OTHER_PROPRIETARY])
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        project.setBugSharingPolicy(
+            BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
+        bug = self.application.createBug(
+            project.owner, 'title', 'description', project, private=False)
+        self.assertEqual(InformationType.PUBLIC, bug.information_type)
+
     def test_createBug_default_private_bugs_false(self):
         # createBug() does not adapt the default kwargs when they are none.
         project = self.factory.makeProduct(

=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py	2012-08-14 01:57:17 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py	2012-08-20 13:22:45 +0000
@@ -25,9 +25,11 @@
     )
 from lp.bugs.publisher import BugsLayer
 from lp.registry.enums import (
+    BugSharingPolicy,
     InformationType,
     PRIVATE_INFORMATION_TYPES,
     )
+from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.projectgroup import IProjectGroup
 from lp.services.webapp.servers import LaunchpadTestRequest
 from lp.testing import (
@@ -41,6 +43,7 @@
     find_main_content,
     find_tag_by_id,
     )
+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
 from lp.testing.views import (
     create_initialized_view,
     create_view,
@@ -353,7 +356,7 @@
         self.assertEqual(expected_guidelines, view.bug_reporting_guidelines)
 
     def filebug_via_view(self, private_bugs=False, information_type=None,
-                         extra_data_token=None):
+                         bug_sharing_policy=None, extra_data_token=None):
         form = {
             'field.title': 'A bug',
             'field.comment': 'A comment',
@@ -364,6 +367,11 @@
         product = self.factory.makeProduct(official_malone=True)
         if private_bugs:
             removeSecurityProxy(product).private_bugs = True
+        if bug_sharing_policy:
+            self.factory.makeCommercialSubscription(product=product)
+            comadmin = getUtility(IPersonSet).getByEmail(
+                COMMERCIAL_ADMIN_EMAIL)
+            product.setBugSharingPolicy(bug_sharing_policy, comadmin)
         with person_logged_in(product.owner):
             view = create_view(
                 product, '+filebug', method='POST', form=form,
@@ -397,6 +405,15 @@
             InformationType.USERDATA, view.default_information_type)
         self.assertEqual(InformationType.USERDATA, bug.information_type)
 
+    def test_filebug_information_type_with_bug_sharing_policy(self):
+        # If we don't specify the bug's information_type, it follows the
+        # target's getDefaultBugInformationType().
+        bug, view = self.filebug_via_view(
+            bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
+        self.assertEqual(
+            InformationType.PROPRIETARY, view.default_information_type)
+        self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
+
     def test_filebug_information_type_with_public_blob(self):
         # Bugs filed with an apport blob that doesn't request privacy
         # are public by default.
@@ -414,7 +431,7 @@
             InformationType.USERDATA, view.default_information_type)
         self.assertEqual(InformationType.USERDATA, bug.information_type)
 
-    def test_filebug_information_type_normal_projects(self):
+    def test_filebug_information_type_public_policy(self):
         # The vocabulary for information_type when filing a bug is created
         # correctly for non commercial projects.
         product = self.factory.makeProduct(official_malone=True)
@@ -425,6 +442,20 @@
             soup = BeautifulSoup(html)
         self.assertIsNone(soup.find('label', text="Proprietary"))
 
+    def test_filebug_information_type_proprietary_policy(self):
+        # The vocabulary for information_type when filing a bug is created
+        # correctly for a project with a proprietary sharing policy.
+        product = self.factory.makeProduct(official_malone=True)
+        self.factory.makeCommercialSubscription(product=product)
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        product.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)
+        with person_logged_in(product.owner):
+            view = create_initialized_view(
+                product, '+filebug', principal=product.owner)
+            html = view.render()
+            soup = BeautifulSoup(html)
+        self.assertIsNotNone(soup.find('label', text="Proprietary"))
+
     def test_filebug_information_type_vocabulary(self):
         # The vocabulary for information_type when filing a bug is created
         # correctly.
@@ -455,7 +486,8 @@
 
     layer = DatabaseFunctionalLayer
 
-    def filebug_via_view(self, private_bugs=False, security_related=False):
+    def filebug_via_view(self, private_bugs=False, bug_sharing_policy=None,
+                         security_related=False):
         form = {
             'field.title': 'A bug',
             'field.comment': 'A comment',
@@ -465,6 +497,11 @@
         product = self.factory.makeProduct(official_malone=True)
         if private_bugs:
             removeSecurityProxy(product).private_bugs = True
+        if bug_sharing_policy:
+            self.factory.makeCommercialSubscription(product=product)
+            comadmin = getUtility(IPersonSet).getByEmail(
+                COMMERCIAL_ADMIN_EMAIL)
+            product.setBugSharingPolicy(bug_sharing_policy, comadmin)
         anyone = self.factory.makePerson()
         with person_logged_in(anyone):
             view = create_initialized_view(
@@ -499,6 +536,13 @@
         bug = self.filebug_via_view(private_bugs=True)
         self.assertEqual(InformationType.USERDATA, bug.information_type)
 
+    def test_filebug_with_proprietary_sharing(self):
+        # Non security related bugs are PROPRIETARY for products with a
+        # proprietary sharing policy.
+        bug = self.filebug_via_view(
+            bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
+        self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
+
     def test_filebug_view_renders_security_related(self):
         # The security_related checkbox is rendered for non bug supervisors.
         product = self.factory.makeProduct(official_malone=True)

=== modified file 'lib/lp/bugs/interfaces/bugtarget.py'
--- lib/lp/bugs/interfaces/bugtarget.py	2012-08-08 03:45:16 +0000
+++ lib/lp/bugs/interfaces/bugtarget.py	2012-08-20 13:22:45 +0000
@@ -18,6 +18,8 @@
     'IOfficialBugTagTargetPublic',
     'IOfficialBugTagTargetRestricted',
     'ISeriesBugTarget',
+    'POLICY_ALLOWED_TYPES',
+    'POLICY_DEFAULT_TYPES',
     ]
 
 
@@ -59,6 +61,11 @@
     BugTagsSearchCombinator,
     IBugTaskSearch,
     )
+from lp.registry.enums import (
+    BugSharingPolicy,
+    FREE_INFORMATION_TYPES,
+    InformationType,
+    )
 from lp.services.fields import Tag
 
 
@@ -197,6 +204,23 @@
         vocabulary=BugBlueprintSearch, required=False))
 
 
+POLICY_ALLOWED_TYPES = {
+    BugSharingPolicy.PUBLIC: FREE_INFORMATION_TYPES,
+    BugSharingPolicy.PUBLIC_OR_PROPRIETARY:
+        FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
+    BugSharingPolicy.PROPRIETARY_OR_PUBLIC:
+        FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
+    BugSharingPolicy.PROPRIETARY: (InformationType.PROPRIETARY,),
+    }
+
+POLICY_DEFAULT_TYPES = {
+    BugSharingPolicy.PUBLIC: InformationType.PUBLIC,
+    BugSharingPolicy.PUBLIC_OR_PROPRIETARY: InformationType.PUBLIC,
+    BugSharingPolicy.PROPRIETARY_OR_PUBLIC: InformationType.PROPRIETARY,
+    BugSharingPolicy.PROPRIETARY: InformationType.PROPRIETARY,
+    }
+
+
 class IHasBugs(Interface):
     """An entity which has a collection of bug tasks."""
 

=== modified file 'lib/lp/bugs/mail/tests/test_handler.py'
--- lib/lp/bugs/mail/tests/test_handler.py	2012-05-04 00:03:07 +0000
+++ lib/lp/bugs/mail/tests/test_handler.py	2012-08-20 13:22:45 +0000
@@ -28,7 +28,11 @@
     MaloneHandler,
     )
 from lp.bugs.model.bugnotification import BugNotification
-from lp.registry.enums import InformationType
+from lp.registry.enums import (
+    BugSharingPolicy,
+    InformationType,
+    )
+from lp.registry.interfaces.person import IPersonSet
 from lp.services.config import config
 from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
 from lp.services.mail import stub
@@ -48,6 +52,7 @@
     LaunchpadZopelessLayer,
     )
 from lp.testing.mail_helpers import pop_notifications
+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
 
 
 class TestMaloneHandler(TestCaseWithFactory):
@@ -253,6 +258,24 @@
         self.assertEqual(1, len(bug.bugtasks))
         self.assertEqual(project, bug.bugtasks[0].target)
 
+    def test_new_bug_with_sharing_policy_proprietary(self):
+        project = self.factory.makeProduct(name='fnord')
+        self.factory.makeCommercialSubscription(product=project)
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        project.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY, comadmin)
+        transaction.commit()
+        handler = MaloneHandler()
+        with person_logged_in(project.owner):
+            msg = self.factory.makeSignedMessage(
+                body='borked\n affects fnord',
+                subject='subject borked',
+                to_address='new@xxxxxxxxxxxxxxxxxx')
+            handler.process(msg, msg['To'])
+        notification = self.getLatestBugNotification()
+        bug = notification.bug
+        self.assertEqual([project.owner], list(bug.getDirectSubscribers()))
+        self.assertEqual(InformationType.PROPRIETARY, bug.information_type)
+
     def test_new_bug_with_one_misplaced_affects_line(self):
         # Affects commands in the wrong position are processed as the user
         # intended when the bug is new and there is only one affects.

=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py	2012-08-08 07:22:51 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py	2012-08-20 13:22:45 +0000
@@ -19,11 +19,18 @@
     Equals,
     LessThan,
     )
-from zope.component import getMultiAdapter
+from zope.component import (
+    getMultiAdapter,
+    getUtility,
+    )
 
 from lp.bugs.browser.bugtask import get_comments_for_bugtask
 from lp.bugs.interfaces.bug import IBug
-from lp.registry.enums import InformationType
+from lp.registry.enums import (
+    BugSharingPolicy,
+    InformationType,
+    )
+from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.product import License
 from lp.services.webapp import snapshot
 from lp.services.webapp.servers import LaunchpadTestRequest
@@ -45,6 +52,7 @@
 from lp.testing.pages import LaunchpadWebServiceCaller
 from lp.testing.sampledata import (
     ADMIN_EMAIL,
+    COMMERCIAL_ADMIN_EMAIL,
     USER_EMAIL,
     )
 
@@ -399,3 +407,18 @@
             target=api_url(project), title='title', description='desc',
             private=True)
         self.assertEqual('Private', bug.information_type)
+
+    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])
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        project.setBugSharingPolicy(
+            BugSharingPolicy.PROPRIETARY_OR_PUBLIC, comadmin)
+        webservice = launchpadlib_for('test', 'salgado')
+        bugs_collection = webservice.load('/bugs')
+        bug = bugs_collection.createBug(
+            target=api_url(project), title='title', description='desc')
+        self.assertEqual('Proprietary', bug.information_type)

=== modified file 'lib/lp/code/model/branchnamespace.py'
--- lib/lp/code/model/branchnamespace.py	2012-08-16 21:57:43 +0000
+++ lib/lp/code/model/branchnamespace.py	2012-08-20 13:22:45 +0000
@@ -47,6 +47,8 @@
 from lp.code.model.branch import Branch
 from lp.registry.enums import (
     BranchSharingPolicy,
+    FREE_INFORMATION_TYPES,
+    FREE_PRIVATE_INFORMATION_TYPES,
     InformationType,
     PersonVisibility,
     NON_EMBARGOED_INFORMATION_TYPES,
@@ -82,11 +84,6 @@
     )
 
 
-FREE_PRIVATE_INFORMATION_TYPES = (
-    InformationType.PRIVATESECURITY, InformationType.USERDATA)
-FREE_INFORMATION_TYPES = (
-    PUBLIC_INFORMATION_TYPES + FREE_PRIVATE_INFORMATION_TYPES)
-
 POLICY_ALLOWED_TYPES = {
     BranchSharingPolicy.PUBLIC: FREE_INFORMATION_TYPES,
     BranchSharingPolicy.PUBLIC_OR_PROPRIETARY: NON_EMBARGOED_INFORMATION_TYPES,

=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
--- lib/lp/code/model/tests/test_branchnamespace.py	2012-08-17 04:48:04 +0000
+++ lib/lp/code/model/tests/test_branchnamespace.py	2012-08-20 13:22:45 +0000
@@ -32,14 +32,14 @@
     )
 from lp.code.interfaces.branchtarget import IBranchTarget
 from lp.code.model.branchnamespace import (
-    FREE_INFORMATION_TYPES,
-    FREE_PRIVATE_INFORMATION_TYPES,
     PackageNamespace,
     PersonalNamespace,
     ProductNamespace,
     )
 from lp.registry.enums import (
     BranchSharingPolicy,
+    FREE_INFORMATION_TYPES,
+    FREE_PRIVATE_INFORMATION_TYPES,
     InformationType,
     NON_EMBARGOED_INFORMATION_TYPES,
     PersonVisibility,

=== modified file 'lib/lp/registry/enums.py'
--- lib/lp/registry/enums.py	2012-08-16 21:57:43 +0000
+++ lib/lp/registry/enums.py	2012-08-20 13:22:45 +0000
@@ -9,8 +9,13 @@
     'BugSharingPolicy',
     'DistroSeriesDifferenceStatus',
     'DistroSeriesDifferenceType',
+<<<<<<< TREE
     'EXCLUSIVE_TEAM_POLICY',
     'INCLUSIVE_TEAM_POLICY',
+=======
+    'FREE_INFORMATION_TYPES',
+    'FREE_PRIVATE_INFORMATION_TYPES',
+>>>>>>> MERGE-SOURCE
     'InformationType',
     'NON_EMBARGOED_INFORMATION_TYPES',
     'PersonTransferJobType',
@@ -77,19 +82,27 @@
 PUBLIC_INFORMATION_TYPES = (
     InformationType.PUBLIC, InformationType.PUBLICSECURITY)
 
-
 PRIVATE_INFORMATION_TYPES = (
     InformationType.PRIVATESECURITY, InformationType.USERDATA,
     InformationType.PROPRIETARY, InformationType.EMBARGOED)
 
+<<<<<<< TREE
 NON_EMBARGOED_INFORMATION_TYPES = (
     PUBLIC_INFORMATION_TYPES +
     (InformationType.PRIVATESECURITY, InformationType.USERDATA,
      InformationType.PROPRIETARY))
 
+=======
+>>>>>>> MERGE-SOURCE
 SECURITY_INFORMATION_TYPES = (
     InformationType.PUBLICSECURITY, InformationType.PRIVATESECURITY)
 
+FREE_PRIVATE_INFORMATION_TYPES = (
+    InformationType.PRIVATESECURITY, InformationType.USERDATA)
+
+FREE_INFORMATION_TYPES = (
+    PUBLIC_INFORMATION_TYPES + FREE_PRIVATE_INFORMATION_TYPES)
+
 
 class SharingPermission(DBEnumeratedType):
     """Sharing permission.

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2012-08-17 05:05:37 +0000
+++ lib/lp/registry/model/product.py	2012-08-20 13:22:45 +0000
@@ -91,6 +91,10 @@
 from lp.blueprints.model.sprint import HasSprintsMixin
 from lp.bugs.interfaces.bugsummary import IBugSummaryDimension
 from lp.bugs.interfaces.bugsupervisor import IHasBugSupervisor
+from lp.bugs.interfaces.bugtarget import (
+    POLICY_ALLOWED_TYPES,
+    POLICY_DEFAULT_TYPES,
+    )
 from lp.bugs.interfaces.bugtaskfilter import OrderedBugTask
 from lp.bugs.model.bugtarget import (
     BugTargetBase,
@@ -595,6 +599,9 @@
 
     def getAllowedBugInformationTypes(self):
         """See `IProduct.`"""
+        if self.bug_sharing_policy is not None:
+            return POLICY_ALLOWED_TYPES[self.bug_sharing_policy]
+
         types = set(InformationType.items)
         types.discard(InformationType.PROPRIETARY)
         types.discard(InformationType.EMBARGOED)
@@ -602,7 +609,9 @@
 
     def getDefaultBugInformationType(self):
         """See `IDistribution.`"""
-        if self.private_bugs:
+        if self.bug_sharing_policy is not None:
+            return POLICY_DEFAULT_TYPES[self.bug_sharing_policy]
+        elif self.private_bugs:
             return InformationType.USERDATA
         else:
             return InformationType.PUBLIC

=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py	2012-08-17 05:05:37 +0000
+++ lib/lp/registry/tests/test_product.py	2012-08-20 13:22:45 +0000
@@ -31,8 +31,12 @@
 from lp.registry.enums import (
     BranchSharingPolicy,
     BugSharingPolicy,
+<<<<<<< TREE
     EXCLUSIVE_TEAM_POLICY,
     INCLUSIVE_TEAM_POLICY,
+=======
+    FREE_INFORMATION_TYPES,
+>>>>>>> MERGE-SOURCE
     InformationType,
     )
 from lp.registry.errors import (
@@ -44,6 +48,14 @@
     IAccessPolicySource,
     )
 from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
+<<<<<<< TREE
+=======
+from lp.registry.interfaces.person import (
+    CLOSED_TEAM_POLICY,
+    IPersonSet,
+    OPEN_TEAM_POLICY,
+    )
+>>>>>>> MERGE-SOURCE
 from lp.registry.interfaces.product import (
     IProduct,
     IProductSet,
@@ -79,6 +91,7 @@
     get_feedback_messages,
     setupBrowser,
     )
+from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL
 from lp.translations.enums import TranslationPermission
 from lp.translations.interfaces.customlanguagecode import (
     IHasCustomLanguageCodes,
@@ -377,26 +390,77 @@
         grantees = set([grant.grantee for grant in grants])
         self.assertEqual(expected_grantess, grantees)
 
-    def test_getAllowedBugInformationTypes(self):
-        # All projects currently support just the non-proprietary
-        # information types.
+
+class TestProductBugInformationTypes(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def makeProductWithPolicy(self, bug_sharing_policy, private_bugs=False):
+        product = self.factory.makeProduct(private_bugs=private_bugs)
+        self.factory.makeCommercialSubscription(product=product)
+        comadmin = getUtility(IPersonSet).getByEmail(COMMERCIAL_ADMIN_EMAIL)
+        product.setBugSharingPolicy(bug_sharing_policy, comadmin)
+        return product
+
+    def test_no_policy(self):
+        # New projects can only use the non-proprietary information
+        # types.
+        product = self.factory.makeProduct()
         self.assertContentEqual(
-            [InformationType.PUBLIC, InformationType.PUBLICSECURITY,
-             InformationType.PRIVATESECURITY, InformationType.USERDATA],
-            self.factory.makeProduct().getAllowedBugInformationTypes())
-
-    def test_getDefaultBugInformationType_public(self):
-        # The default information type for normal projects is PUBLIC.
-        product = self.factory.makeProduct()
+            FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
         self.assertEqual(
             InformationType.PUBLIC, product.getDefaultBugInformationType())
 
-    def test_getDefaultBugInformationType_private(self):
-        # private_bugs overrides the default information type to USERDATA.
+    def test_legacy_private_bugs(self):
+        # The deprecated private_bugs attribute overrides the default
+        # information type to USERDATA.
         product = self.factory.makeProduct(private_bugs=True)
+        self.assertContentEqual(
+            FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
         self.assertEqual(
             InformationType.USERDATA, product.getDefaultBugInformationType())
 
+    def test_sharing_policy_overrides_private_bugs(self):
+        # bug_sharing_policy overrides private_bugs.
+        product = self.makeProductWithPolicy(
+            BugSharingPolicy.PUBLIC, private_bugs=True)
+        self.assertContentEqual(
+            FREE_INFORMATION_TYPES, product.getAllowedBugInformationTypes())
+        self.assertEqual(
+            InformationType.PUBLIC, product.getDefaultBugInformationType())
+
+    def test_sharing_policy_public_or_proprietary(self):
+        # bug_sharing_policy can enable Proprietary.
+        product = self.makeProductWithPolicy(
+            BugSharingPolicy.PUBLIC_OR_PROPRIETARY)
+        self.assertContentEqual(
+            FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
+            product.getAllowedBugInformationTypes())
+        self.assertEqual(
+            InformationType.PUBLIC,
+            product.getDefaultBugInformationType())
+
+    def test_sharing_policy_proprietary_or_public(self):
+        # bug_sharing_policy can enable and default to Proprietary.
+        product = self.makeProductWithPolicy(
+            BugSharingPolicy.PROPRIETARY_OR_PUBLIC)
+        self.assertContentEqual(
+            FREE_INFORMATION_TYPES + (InformationType.PROPRIETARY,),
+            product.getAllowedBugInformationTypes())
+        self.assertEqual(
+            InformationType.PROPRIETARY,
+            product.getDefaultBugInformationType())
+
+    def test_sharing_policy_proprietary(self):
+        # bug_sharing_policy can enable only Proprietary.
+        product = self.makeProductWithPolicy(BugSharingPolicy.PROPRIETARY)
+        self.assertContentEqual(
+            [InformationType.PROPRIETARY],
+            product.getAllowedBugInformationTypes())
+        self.assertEqual(
+            InformationType.PROPRIETARY,
+            product.getDefaultBugInformationType())
+
 
 class TestProductFiles(TestCase):
     """Tests for downloadable product files."""


Follow ups