Merge lp:~wgrant/launchpad/death-to-embargoed into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17597
Proposed branch: lp:~wgrant/launchpad/death-to-embargoed
Merge into: lp:launchpad
Diff against target: 1062 lines (+137/-249)
12 files modified
lib/lp/app/enums.py (+4/-1)
lib/lp/registry/browser/product.py (+5/-9)
lib/lp/registry/browser/tests/test_product.py (+15/-23)
lib/lp/registry/javascript/tests/test_product_views.js (+6/-10)
lib/lp/registry/model/product.py (+4/-7)
lib/lp/registry/services/tests/test_sharingservice.py (+1/-1)
lib/lp/registry/tests/test_packaging.py (+0/-14)
lib/lp/registry/tests/test_person.py (+11/-11)
lib/lp/registry/tests/test_product.py (+74/-137)
lib/lp/registry/tests/test_product_vocabularies.py (+6/-10)
lib/lp/registry/tests/test_productseries.py (+9/-24)
lib/lp/translations/browser/tests/test_product_view.py (+2/-2)
To merge this branch: bzr merge lp:~wgrant/launchpad/death-to-embargoed
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+263083@code.launchpad.net

Commit message

Remove Embargoed as a legal value for Product.information_type.

Description of the change

Remove Embargoed as a legal value for Product.information_type.

InformationType.EMBARGOED exists to give proprietary projects two different levels of protection: eg. a partner project might share bugs with the customer, but code only with employees until the project is done. There's no difference between Proprietary and Embargoed as a pillar information type except the sharing policy defaults. It confuses many project creators, and it's only used by a dozen projects -- all of them look like mistakes.

We should UPDATE Product SET information_type = 5 WHERE information_type = 6; before this is deployed.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

The product__valid_information_type constraint should also be changed, possibly after this is deployed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/app/enums.py'
--- lib/lp/app/enums.py 2012-09-17 15:19:10 +0000
+++ lib/lp/app/enums.py 2015-07-02 02:01:38 +0000
@@ -11,6 +11,7 @@
11 'NON_EMBARGOED_INFORMATION_TYPES',11 'NON_EMBARGOED_INFORMATION_TYPES',
12 'PRIVATE_INFORMATION_TYPES',12 'PRIVATE_INFORMATION_TYPES',
13 'PROPRIETARY_INFORMATION_TYPES',13 'PROPRIETARY_INFORMATION_TYPES',
14 'PILLAR_INFORMATION_TYPES',
14 'PUBLIC_INFORMATION_TYPES',15 'PUBLIC_INFORMATION_TYPES',
15 'PUBLIC_PROPRIETARY_INFORMATION_TYPES',16 'PUBLIC_PROPRIETARY_INFORMATION_TYPES',
16 'SECURITY_INFORMATION_TYPES',17 'SECURITY_INFORMATION_TYPES',
@@ -67,7 +68,6 @@
67 Only shared with users permitted to see embargoed information.68 Only shared with users permitted to see embargoed information.
68 """)69 """)
6970
70
71PUBLIC_INFORMATION_TYPES = (71PUBLIC_INFORMATION_TYPES = (
72 InformationType.PUBLIC, InformationType.PUBLICSECURITY)72 InformationType.PUBLIC, InformationType.PUBLICSECURITY)
7373
@@ -97,6 +97,9 @@
97 (InformationType.PUBLIC,) + PROPRIETARY_INFORMATION_TYPES97 (InformationType.PUBLIC,) + PROPRIETARY_INFORMATION_TYPES
98)98)
9999
100PILLAR_INFORMATION_TYPES = (
101 InformationType.PUBLIC, InformationType.PROPRIETARY)
102
100103
101class ServiceUsage(DBEnumeratedType):104class ServiceUsage(DBEnumeratedType):
102 """Launchpad application usages.105 """Launchpad application usages.
103106
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2015-07-01 09:31:48 +0000
+++ lib/lp/registry/browser/product.py 2015-07-02 02:01:38 +0000
@@ -106,7 +106,7 @@
106from lp.app.enums import (106from lp.app.enums import (
107 InformationType,107 InformationType,
108 PROPRIETARY_INFORMATION_TYPES,108 PROPRIETARY_INFORMATION_TYPES,
109 PUBLIC_PROPRIETARY_INFORMATION_TYPES,109 PILLAR_INFORMATION_TYPES,
110 ServiceUsage,110 ServiceUsage,
111 )111 )
112from lp.app.errors import (112from lp.app.errors import (
@@ -1376,8 +1376,7 @@
1376 custom_widget('license_info', GhostWidget)1376 custom_widget('license_info', GhostWidget)
1377 custom_widget(1377 custom_widget(
1378 'information_type', LaunchpadRadioWidgetWithDescription,1378 'information_type', LaunchpadRadioWidgetWithDescription,
1379 vocabulary=InformationTypeVocabulary(1379 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))
1380 types=PUBLIC_PROPRIETARY_INFORMATION_TYPES))
13811380
1382 @property1381 @property
1383 def next_url(self):1382 def next_url(self):
@@ -1401,8 +1400,7 @@
1401 # the form is rendered during LaunchpadFormView's initialize()1400 # the form is rendered during LaunchpadFormView's initialize()
1402 # when an action is invoked.1401 # when an action is invoked.
1403 cache = IJSONRequestCache(self.request)1402 cache = IJSONRequestCache(self.request)
1404 json_dump_information_types(1403 json_dump_information_types(cache, PILLAR_INFORMATION_TYPES)
1405 cache, PUBLIC_PROPRIETARY_INFORMATION_TYPES)
1406 super(ProductEditView, self).initialize()1404 super(ProductEditView, self).initialize()
14071405
1408 def validate(self, data):1406 def validate(self, data):
@@ -2279,8 +2277,7 @@
2279 custom_widget(2277 custom_widget(
2280 'information_type',2278 'information_type',
2281 LaunchpadRadioWidgetWithDescription,2279 LaunchpadRadioWidgetWithDescription,
2282 vocabulary=InformationTypeVocabulary(2280 vocabulary=InformationTypeVocabulary(types=PILLAR_INFORMATION_TYPES))
2283 types=PUBLIC_PROPRIETARY_INFORMATION_TYPES))
22842281
2285 custom_widget(2282 custom_widget(
2286 'owner', PersonPickerWidget, header="Select the maintainer",2283 'owner', PersonPickerWidget, header="Select the maintainer",
@@ -2299,8 +2296,7 @@
2299 # the form is rendered during LaunchpadFormView's initialize()2296 # the form is rendered during LaunchpadFormView's initialize()
2300 # when an action is invoked.2297 # when an action is invoked.
2301 cache = IJSONRequestCache(self.request)2298 cache = IJSONRequestCache(self.request)
2302 json_dump_information_types(2299 json_dump_information_types(cache, PILLAR_INFORMATION_TYPES)
2303 cache, PUBLIC_PROPRIETARY_INFORMATION_TYPES)
2304 super(ProjectAddStepTwo, self).initialize()2300 super(ProjectAddStepTwo, self).initialize()
23052301
2306 @property2302 @property
23072303
=== modified file 'lib/lp/registry/browser/tests/test_product.py'
--- lib/lp/registry/browser/tests/test_product.py 2015-06-29 02:00:53 +0000
+++ lib/lp/registry/browser/tests/test_product.py 2015-07-02 02:01:38 +0000
@@ -106,12 +106,12 @@
106106
107 def test_configure_answers_skips_launchpad_for_proprietary(self):107 def test_configure_answers_skips_launchpad_for_proprietary(self):
108 # Proprietary projects forbid LAUNCHPAD for answers.108 # Proprietary projects forbid LAUNCHPAD for answers.
109 for info_type in PROPRIETARY_INFORMATION_TYPES:109 product = self.factory.makeProduct(
110 product = self.factory.makeProduct(information_type=info_type)110 information_type=InformationType.PROPRIETARY)
111 with person_logged_in(None):111 with person_logged_in(None):
112 browser = self.getViewBrowser(product, '+configure-answers',112 browser = self.getViewBrowser(product, '+configure-answers',
113 user=removeSecurityProxy(product).owner)113 user=removeSecurityProxy(product).owner)
114 self.assertThat(browser.contents, Not(HTMLContains(self.lp_tag)))114 self.assertThat(browser.contents, Not(HTMLContains(self.lp_tag)))
115115
116116
117def make_product_form(person=None, action=1, proprietary=False):117def make_product_form(person=None, action=1, proprietary=False):
@@ -482,14 +482,14 @@
482 }482 }
483483
484 def test_limited_information_types_allowed(self):484 def test_limited_information_types_allowed(self):
485 """Products can only be PUBLIC_PROPRIETARY_INFORMATION_TYPES"""485 """Products can only be PILLAR_INFORMATION_TYPES"""
486 product = self.factory.makeProduct()486 product = self.factory.makeProduct()
487 login_person(product.owner)487 login_person(product.owner)
488 view = create_initialized_view(488 view = create_initialized_view(
489 product, '+edit', principal=product.owner)489 product, '+edit', principal=product.owner)
490 vocabulary = view.widgets['information_type'].vocabulary490 vocabulary = view.widgets['information_type'].vocabulary
491 info_types = [t.name for t in vocabulary]491 info_types = [t.name for t in vocabulary]
492 expected = ['PUBLIC', 'PROPRIETARY', 'EMBARGOED']492 expected = ['PUBLIC', 'PROPRIETARY']
493 self.assertEqual(expected, info_types)493 self.assertEqual(expected, info_types)
494494
495 def test_change_information_type_proprietary(self):495 def test_change_information_type_proprietary(self):
@@ -683,52 +683,46 @@
683 information_type=InformationType.PUBLIC, owner=owner)683 information_type=InformationType.PUBLIC, owner=owner)
684 proprietary = self.factory.makeProduct(684 proprietary = self.factory.makeProduct(
685 information_type=InformationType.PROPRIETARY, owner=owner)685 information_type=InformationType.PROPRIETARY, owner=owner)
686 embargoed = self.factory.makeProduct(686 return owner, public, proprietary
687 information_type=InformationType.EMBARGOED, owner=owner)
688 return owner, public, proprietary, embargoed
689687
690 def test_proprietary_products_skipped(self):688 def test_proprietary_products_skipped(self):
691 # Ignore proprietary products for anonymous users689 # Ignore proprietary products for anonymous users
692 owner, public, proprietary, embargoed = self.makeAllInformationTypes()690 owner, public, proprietary = self.makeAllInformationTypes()
693 browser = self.getViewBrowser(getUtility(IProductSet))691 browser = self.getViewBrowser(getUtility(IProductSet))
694 with person_logged_in(owner):692 with person_logged_in(owner):
695 self.assertIn(public.name, browser.contents)693 self.assertIn(public.name, browser.contents)
696 self.assertNotIn(proprietary.name, browser.contents)694 self.assertNotIn(proprietary.name, browser.contents)
697 self.assertNotIn(embargoed.name, browser.contents)
698695
699 def test_proprietary_products_shown_to_owners(self):696 def test_proprietary_products_shown_to_owners(self):
700 # Owners will see their proprietary products listed697 # Owners will see their proprietary products listed
701 owner, public, proprietary, embargoed = self.makeAllInformationTypes()698 owner, public, proprietary = self.makeAllInformationTypes()
702 transaction.commit()699 transaction.commit()
703 browser = self.getViewBrowser(getUtility(IProductSet), user=owner)700 browser = self.getViewBrowser(getUtility(IProductSet), user=owner)
704 with person_logged_in(owner):701 with person_logged_in(owner):
705 self.assertIn(public.name, browser.contents)702 self.assertIn(public.name, browser.contents)
706 self.assertIn(proprietary.name, browser.contents)703 self.assertIn(proprietary.name, browser.contents)
707 self.assertIn(embargoed.name, browser.contents)
708704
709 def test_proprietary_products_skipped_all(self):705 def test_proprietary_products_skipped_all(self):
710 # Ignore proprietary products for anonymous users706 # Ignore proprietary products for anonymous users
711 owner, public, proprietary, embargoed = self.makeAllInformationTypes()707 owner, public, proprietary = self.makeAllInformationTypes()
712 product_set = getUtility(IProductSet)708 product_set = getUtility(IProductSet)
713 browser = self.getViewBrowser(product_set, view_name='+all')709 browser = self.getViewBrowser(product_set, view_name='+all')
714 with person_logged_in(owner):710 with person_logged_in(owner):
715 self.assertIn(public.name, browser.contents)711 self.assertIn(public.name, browser.contents)
716 self.assertNotIn(proprietary.name, browser.contents)712 self.assertNotIn(proprietary.name, browser.contents)
717 self.assertNotIn(embargoed.name, browser.contents)
718713
719 def test_proprietary_products_shown_to_owners_all(self):714 def test_proprietary_products_shown_to_owners_all(self):
720 # Owners will see their proprietary products listed715 # Owners will see their proprietary products listed
721 owner, public, proprietary, embargoed = self.makeAllInformationTypes()716 owner, public, proprietary = self.makeAllInformationTypes()
722 transaction.commit()717 transaction.commit()
723 browser = self.getViewBrowser(getUtility(IProductSet), user=owner,718 browser = self.getViewBrowser(getUtility(IProductSet), user=owner,
724 view_name='+all')719 view_name='+all')
725 with person_logged_in(owner):720 with person_logged_in(owner):
726 self.assertIn(public.name, browser.contents)721 self.assertIn(public.name, browser.contents)
727 self.assertIn(proprietary.name, browser.contents)722 self.assertIn(proprietary.name, browser.contents)
728 self.assertIn(embargoed.name, browser.contents)
729723
730 def test_review_exclude_proprietary_for_expert(self):724 def test_review_exclude_proprietary_for_expert(self):
731 owner, public, proprietary, embargoed = self.makeAllInformationTypes()725 owner, public, proprietary = self.makeAllInformationTypes()
732 transaction.commit()726 transaction.commit()
733 expert = self.factory.makeRegistryExpert()727 expert = self.factory.makeRegistryExpert()
734 browser = self.getViewBrowser(getUtility(IProductSet),728 browser = self.getViewBrowser(getUtility(IProductSet),
@@ -737,10 +731,9 @@
737 with person_logged_in(owner):731 with person_logged_in(owner):
738 self.assertIn(public.name, browser.contents)732 self.assertIn(public.name, browser.contents)
739 self.assertNotIn(proprietary.name, browser.contents)733 self.assertNotIn(proprietary.name, browser.contents)
740 self.assertNotIn(embargoed.name, browser.contents)
741734
742 def test_review_include_proprietary_for_admin(self):735 def test_review_include_proprietary_for_admin(self):
743 owner, public, proprietary, embargoed = self.makeAllInformationTypes()736 owner, public, proprietary = self.makeAllInformationTypes()
744 transaction.commit()737 transaction.commit()
745 admin = self.factory.makeAdministrator()738 admin = self.factory.makeAdministrator()
746 browser = self.getViewBrowser(getUtility(IProductSet),739 browser = self.getViewBrowser(getUtility(IProductSet),
@@ -749,4 +742,3 @@
749 with person_logged_in(owner):742 with person_logged_in(owner):
750 self.assertIn(public.name, browser.contents)743 self.assertIn(public.name, browser.contents)
751 self.assertIn(proprietary.name, browser.contents)744 self.assertIn(proprietary.name, browser.contents)
752 self.assertIn(embargoed.name, browser.contents)
753745
=== modified file 'lib/lp/registry/javascript/tests/test_product_views.js'
--- lib/lp/registry/javascript/tests/test_product_views.js 2013-03-20 03:41:40 +0000
+++ lib/lp/registry/javascript/tests/test_product_views.js 2015-07-02 02:01:38 +0000
@@ -21,11 +21,6 @@
21 is_private: false, order: 1,21 is_private: false, order: 1,
22 description: 'Public Description'22 description: 'Public Description'
23 },23 },
24 EMBARGOED: {
25 value: 'EMBARGOED', name: 'Embargoed',
26 is_private: true, order: 2,
27 description: 'Something embargoed'
28 },
29 PROPRIETARY: {24 PROPRIETARY: {
30 value: 'PROPRIETARY', name: 'Proprietary',25 value: 'PROPRIETARY', name: 'Proprietary',
31 is_private: true, order: 3,26 is_private: true, order: 3,
@@ -50,7 +45,8 @@
50 var licenses_cont = licenses.ancestor('td').ancestor('td');45 var licenses_cont = licenses.ancestor('td').ancestor('td');
51 Y.Assert.areEqual('none',46 Y.Assert.areEqual('none',
52 licenses_cont.getComputedStyle('display'),47 licenses_cont.getComputedStyle('display'),
53 'License is hidden when EMBARGOED is selected.');48 'License is hidden when PROPRIETARY is ' +
49 'selected.');
5450
55 var new_license = Y.one('input[name="field.licenses"]');51 var new_license = Y.one('input[name="field.licenses"]');
56 Y.Assert.areEqual('OTHER_PROPRIETARY', new_license.get('value'),52 Y.Assert.areEqual('OTHER_PROPRIETARY', new_license.get('value'),
@@ -133,7 +129,7 @@
133129
134 // Force the value to change to a private value and make sure the130 // Force the value to change to a private value and make sure the
135 // UI is updated.131 // UI is updated.
136 widget._saveData('EMBARGOED');132 widget._saveData('PROPRIETARY');
137 shared.assert_license_updates();133 shared.assert_license_updates();
138134
139 var bug_super = Y.one('input[name="field.bug_supervisor"]');135 var bug_super = Y.one('input[name="field.bug_supervisor"]');
@@ -141,14 +137,14 @@
141 Y.Assert.areNotEqual(137 Y.Assert.areNotEqual(
142 'none',138 'none',
143 bug_super_cont.getComputedStyle('display'),139 bug_super_cont.getComputedStyle('display'),
144 'Bug Supervisor is shown when EMBARGOED is selected.');140 'Bug Supervisor is shown when PROPRIETARY is selected.');
145141
146 var driver = Y.one('input[name="field.driver"]');142 var driver = Y.one('input[name="field.driver"]');
147 var driver_cont = driver.ancestor('td');143 var driver_cont = driver.ancestor('td');
148 Y.Assert.areNotEqual(144 Y.Assert.areNotEqual(
149 'none',145 'none',
150 driver_cont.getComputedStyle('display'),146 driver_cont.getComputedStyle('display'),
151 'Driver is shown when EMBARGOED is selected.');147 'Driver is shown when PROPRIETARY is selected.');
152 }148 }
153 }));149 }));
154150
@@ -180,7 +176,7 @@
180176
181 // Force the value to change to a private value and make sure the177 // Force the value to change to a private value and make sure the
182 // UI is updated.178 // UI is updated.
183 widget._saveData('EMBARGOED');179 widget._saveData('PROPRIETARY');
184 shared.assert_license_updates();180 shared.assert_license_updates();
185 }181 }
186 }));182 }));
187183
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2015-07-01 12:00:10 +0000
+++ lib/lp/registry/model/product.py 2015-07-02 02:01:38 +0000
@@ -70,10 +70,10 @@
70from lp.app.enums import (70from lp.app.enums import (
71 FREE_INFORMATION_TYPES,71 FREE_INFORMATION_TYPES,
72 InformationType,72 InformationType,
73 PILLAR_INFORMATION_TYPES,
73 PRIVATE_INFORMATION_TYPES,74 PRIVATE_INFORMATION_TYPES,
74 PROPRIETARY_INFORMATION_TYPES,75 PROPRIETARY_INFORMATION_TYPES,
75 PUBLIC_INFORMATION_TYPES,76 PUBLIC_INFORMATION_TYPES,
76 PUBLIC_PROPRIETARY_INFORMATION_TYPES,
77 service_uses_launchpad,77 service_uses_launchpad,
78 ServiceUsage,78 ServiceUsage,
79 )79 )
@@ -341,21 +341,17 @@
341bug_policy_default = {341bug_policy_default = {
342 InformationType.PUBLIC: BugSharingPolicy.PUBLIC,342 InformationType.PUBLIC: BugSharingPolicy.PUBLIC,
343 InformationType.PROPRIETARY: BugSharingPolicy.PROPRIETARY,343 InformationType.PROPRIETARY: BugSharingPolicy.PROPRIETARY,
344 InformationType.EMBARGOED: BugSharingPolicy.EMBARGOED_OR_PROPRIETARY,
345}344}
346345
347346
348branch_policy_default = {347branch_policy_default = {
349 InformationType.PUBLIC: BranchSharingPolicy.PUBLIC,348 InformationType.PUBLIC: BranchSharingPolicy.PUBLIC,
350 InformationType.EMBARGOED: BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY,
351 InformationType.PROPRIETARY: BranchSharingPolicy.PROPRIETARY,349 InformationType.PROPRIETARY: BranchSharingPolicy.PROPRIETARY,
352}350}
353351
354352
355specification_policy_default = {353specification_policy_default = {
356 InformationType.PUBLIC: SpecificationSharingPolicy.PUBLIC,354 InformationType.PUBLIC: SpecificationSharingPolicy.PUBLIC,
357 InformationType.EMBARGOED:
358 SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY,
359 InformationType.PROPRIETARY: SpecificationSharingPolicy.PROPRIETARY,355 InformationType.PROPRIETARY: SpecificationSharingPolicy.PROPRIETARY,
360}356}
361357
@@ -484,7 +480,7 @@
484 changed. Has the side-effect of creating a commercial subscription if480 changed. Has the side-effect of creating a commercial subscription if
485 permitted.481 permitted.
486 """482 """
487 if value not in PUBLIC_PROPRIETARY_INFORMATION_TYPES:483 if value not in PILLAR_INFORMATION_TYPES:
488 yield CannotChangeInformationType('Not supported for Projects.')484 yield CannotChangeInformationType('Not supported for Projects.')
489 if value in PROPRIETARY_INFORMATION_TYPES:485 if value in PROPRIETARY_INFORMATION_TYPES:
490 if self.answers_usage == ServiceUsage.LAUNCHPAD:486 if self.answers_usage == ServiceUsage.LAUNCHPAD:
@@ -1933,7 +1929,8 @@
1933 licenses = set()1929 licenses = set()
1934 if information_type is None:1930 if information_type is None:
1935 information_type = InformationType.PUBLIC1931 information_type = InformationType.PUBLIC
1936 if information_type in PROPRIETARY_INFORMATION_TYPES:1932 if (information_type in PILLAR_INFORMATION_TYPES
1933 and information_type in PROPRIETARY_INFORMATION_TYPES):
1937 # This check is skipped in _valid_product_information_type during1934 # This check is skipped in _valid_product_information_type during
1938 # creation, so done here. It predicts whether a commercial1935 # creation, so done here. It predicts whether a commercial
1939 # subscription will be generated based on the selected license,1936 # subscription will be generated based on the selected license,
19401937
=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
--- lib/lp/registry/services/tests/test_sharingservice.py 2015-06-26 06:32:03 +0000
+++ lib/lp/registry/services/tests/test_sharingservice.py 2015-07-02 02:01:38 +0000
@@ -248,7 +248,7 @@
248 # proprietary.248 # proprietary.
249 owner = self.factory.makePerson()249 owner = self.factory.makePerson()
250 product = self.factory.makeProduct(250 product = self.factory.makeProduct(
251 information_type=InformationType.EMBARGOED,251 information_type=InformationType.PROPRIETARY,
252 owner=owner,252 owner=owner,
253 branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY)253 branch_sharing_policy=BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY)
254 with person_logged_in(owner):254 with person_logged_in(owner):
255255
=== modified file 'lib/lp/registry/tests/test_packaging.py'
--- lib/lp/registry/tests/test_packaging.py 2012-10-18 14:39:18 +0000
+++ lib/lp/registry/tests/test_packaging.py 2015-07-02 02:01:38 +0000
@@ -188,20 +188,6 @@
188 series, self.sourcepackagename, self.distroseries,188 series, self.sourcepackagename, self.distroseries,
189 PackagingType.PRIME, owner=self.owner)189 PackagingType.PRIME, owner=self.owner)
190190
191 def test_createPackaging_refuses_EMBARGOED(self):
192 """Packaging cannot be created for EMBARGOED productseries"""
193 owner = self.factory.makePerson()
194 product = self.factory.makeProduct(
195 owner=owner,
196 information_type=InformationType.EMBARGOED)
197 series = self.factory.makeProductSeries(product=product)
198 with person_logged_in(owner):
199 with ExpectedException(CannotPackageProprietaryProduct,
200 'Only Public project series can be packaged, not Embargoed.'):
201 self.packaging_util.createPackaging(
202 series, self.sourcepackagename, self.distroseries,
203 PackagingType.PRIME, owner=self.owner)
204
205191
206class TestPackagingEntryExists(PackagingUtilMixin, TestCaseWithFactory):192class TestPackagingEntryExists(PackagingUtilMixin, TestCaseWithFactory):
207 """Test PackagingUtil.packagingEntryExists."""193 """Test PackagingUtil.packagingEntryExists."""
208194
=== modified file 'lib/lp/registry/tests/test_person.py'
--- lib/lp/registry/tests/test_person.py 2015-05-11 13:17:41 +0000
+++ lib/lp/registry/tests/test_person.py 2015-07-02 02:01:38 +0000
@@ -412,12 +412,12 @@
412 user.getAffiliatedPillars(user)]412 user.getAffiliatedPillars(user)]
413 self.assertEqual(expected_pillars, received_pillars)413 self.assertEqual(expected_pillars, received_pillars)
414414
415 def test_getAffiliatedPillars_minus_embargoed(self):415 def test_getAffiliatedPillars_minus_proprietary(self):
416 # Skip non public products if not allowed to see them.416 # Skip non public products if not allowed to see them.
417 owner = self.factory.makePerson()417 owner = self.factory.makePerson()
418 user = self.factory.makePerson()418 user = self.factory.makePerson()
419 self.factory.makeProduct(419 self.factory.makeProduct(
420 information_type=InformationType.EMBARGOED,420 information_type=InformationType.PROPRIETARY,
421 owner=owner)421 owner=owner)
422 public = self.factory.makeProduct(422 public = self.factory.makeProduct(
423 information_type=InformationType.PUBLIC,423 information_type=InformationType.PUBLIC,
@@ -432,15 +432,15 @@
432 # Users can see their own non-public affiliated products.432 # Users can see their own non-public affiliated products.
433 owner = self.factory.makePerson()433 owner = self.factory.makePerson()
434 self.factory.makeProduct(434 self.factory.makeProduct(
435 name=u'embargoed',435 name=u'proprietary',
436 information_type=InformationType.EMBARGOED,436 information_type=InformationType.PROPRIETARY,
437 owner=owner)437 owner=owner)
438 self.factory.makeProduct(438 self.factory.makeProduct(
439 name=u'public',439 name=u'public',
440 information_type=InformationType.PUBLIC,440 information_type=InformationType.PUBLIC,
441 owner=owner)441 owner=owner)
442442
443 expected_pillars = [u'embargoed', u'public']443 expected_pillars = [u'proprietary', u'public']
444 received_pillars = [pillar.name for pillar in444 received_pillars = [pillar.name for pillar in
445 owner.getAffiliatedPillars(owner)]445 owner.getAffiliatedPillars(owner)]
446 self.assertEqual(expected_pillars, received_pillars)446 self.assertEqual(expected_pillars, received_pillars)
@@ -450,15 +450,15 @@
450 owner = self.factory.makePerson()450 owner = self.factory.makePerson()
451 admin = self.factory.makeAdministrator()451 admin = self.factory.makeAdministrator()
452 self.factory.makeProduct(452 self.factory.makeProduct(
453 name=u'embargoed',453 name=u'proprietary',
454 information_type=InformationType.EMBARGOED,454 information_type=InformationType.PROPRIETARY,
455 owner=owner)455 owner=owner)
456 self.factory.makeProduct(456 self.factory.makeProduct(
457 name=u'public',457 name=u'public',
458 information_type=InformationType.PUBLIC,458 information_type=InformationType.PUBLIC,
459 owner=owner)459 owner=owner)
460460
461 expected_pillars = [u'embargoed', u'public']461 expected_pillars = [u'proprietary', u'public']
462 received_pillars = [pillar.name for pillar in462 received_pillars = [pillar.name for pillar in
463 owner.getAffiliatedPillars(admin)]463 owner.getAffiliatedPillars(admin)]
464 self.assertEqual(expected_pillars, received_pillars)464 self.assertEqual(expected_pillars, received_pillars)
@@ -468,15 +468,15 @@
468 owner = self.factory.makePerson()468 owner = self.factory.makePerson()
469 admin = self.factory.makeCommercialAdmin()469 admin = self.factory.makeCommercialAdmin()
470 self.factory.makeProduct(470 self.factory.makeProduct(
471 name=u'embargoed',471 name=u'proprietary',
472 information_type=InformationType.EMBARGOED,472 information_type=InformationType.PROPRIETARY,
473 owner=owner)473 owner=owner)
474 self.factory.makeProduct(474 self.factory.makeProduct(
475 name=u'public',475 name=u'public',
476 information_type=InformationType.PUBLIC,476 information_type=InformationType.PUBLIC,
477 owner=owner)477 owner=owner)
478478
479 expected_pillars = [u'embargoed', u'public']479 expected_pillars = [u'proprietary', u'public']
480 received_pillars = [pillar.name for pillar in480 received_pillars = [pillar.name for pillar in
481 owner.getAffiliatedPillars(admin)]481 owner.getAffiliatedPillars(admin)]
482 self.assertEqual(expected_pillars, received_pillars)482 self.assertEqual(expected_pillars, received_pillars)
483483
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2015-07-01 12:00:10 +0000
+++ lib/lp/registry/tests/test_product.py 2015-07-02 02:01:38 +0000
@@ -27,8 +27,7 @@
27from lp.app.enums import (27from lp.app.enums import (
28 FREE_INFORMATION_TYPES,28 FREE_INFORMATION_TYPES,
29 InformationType,29 InformationType,
30 PROPRIETARY_INFORMATION_TYPES,30 PILLAR_INFORMATION_TYPES,
31 PUBLIC_PROPRIETARY_INFORMATION_TYPES,
32 ServiceUsage,31 ServiceUsage,
33 )32 )
34from lp.app.errors import ServiceUsageForbidden33from lp.app.errors import ServiceUsageForbidden
@@ -127,6 +126,8 @@
127 TranslationsBranchImportMode,126 TranslationsBranchImportMode,
128 )127 )
129128
129PRIVATE_PROJECT_TYPES = [InformationType.PROPRIETARY]
130
130131
131class ValidationTestCase(TestCase):132class ValidationTestCase(TestCase):
132 """Test IProduct validators."""133 """Test IProduct validators."""
@@ -383,29 +384,6 @@
383 expected = [InformationType.PROPRIETARY]384 expected = [InformationType.PROPRIETARY]
384 self.assertContentEqual(expected, [policy.type for policy in aps])385 self.assertContentEqual(expected, [policy.type for policy in aps])
385386
386 def test_embargoed_product_creation_sharing_policies(self):
387 # Creating a new embargoed product sets the branch and
388 # specification sharing polices to embargoed or proprietary, and the
389 # bug sharing policy to proprietary.
390 owner = self.factory.makePerson()
391 with person_logged_in(owner):
392 product = getUtility(IProductSet).createProduct(
393 owner, 'carrot', 'Carrot', 'Carrot', 'testing',
394 licenses=[License.OTHER_PROPRIETARY],
395 information_type=InformationType.EMBARGOED)
396 self.assertEqual(
397 BugSharingPolicy.EMBARGOED_OR_PROPRIETARY,
398 product.bug_sharing_policy)
399 self.assertEqual(
400 BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY,
401 product.branch_sharing_policy)
402 self.assertEqual(
403 SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY,
404 product.specification_sharing_policy)
405 aps = getUtility(IAccessPolicySource).findByPillar([product])
406 expected = [InformationType.PROPRIETARY, InformationType.EMBARGOED]
407 self.assertContentEqual(expected, [policy.type for policy in aps])
408
409 def test_other_proprietary_product_creation_sharing_policies(self):387 def test_other_proprietary_product_creation_sharing_policies(self):
410 # Creating a new product with other/proprietary license leaves bug388 # Creating a new product with other/proprietary license leaves bug
411 # and branch sharing polices at their default.389 # and branch sharing polices at their default.
@@ -433,7 +411,7 @@
433 )411 )
434 self.useContext(person_logged_in(product.owner))412 self.useContext(person_logged_in(product.owner))
435 spec = self.factory.makeSpecification(product=product)413 spec = self.factory.makeSpecification(product=product)
436 for info_type in PROPRIETARY_INFORMATION_TYPES:414 for info_type in PRIVATE_PROJECT_TYPES:
437 with ExpectedException(415 with ExpectedException(
438 CannotChangeInformationType, 'Some blueprints are public.'):416 CannotChangeInformationType, 'Some blueprints are public.'):
439 product.information_type = info_type417 product.information_type = info_type
@@ -442,7 +420,7 @@
442 bug = self.factory.makeBug(target=product)420 bug = self.factory.makeBug(target=product)
443 for bug_info_type in FREE_INFORMATION_TYPES:421 for bug_info_type in FREE_INFORMATION_TYPES:
444 bug.transitionToInformationType(bug_info_type, product.owner)422 bug.transitionToInformationType(bug_info_type, product.owner)
445 for info_type in PROPRIETARY_INFORMATION_TYPES:423 for info_type in PRIVATE_PROJECT_TYPES:
446 with ExpectedException(424 with ExpectedException(
447 CannotChangeInformationType,425 CannotChangeInformationType,
448 'Some bugs are neither proprietary nor embargoed.'):426 'Some bugs are neither proprietary nor embargoed.'):
@@ -453,14 +431,14 @@
453 for branch_info_type in FREE_INFORMATION_TYPES:431 for branch_info_type in FREE_INFORMATION_TYPES:
454 branch.transitionToInformationType(branch_info_type,432 branch.transitionToInformationType(branch_info_type,
455 product.owner)433 product.owner)
456 for info_type in PROPRIETARY_INFORMATION_TYPES:434 for info_type in PRIVATE_PROJECT_TYPES:
457 with ExpectedException(435 with ExpectedException(
458 CannotChangeInformationType,436 CannotChangeInformationType,
459 'Some branches are neither proprietary nor embargoed.'):437 'Some branches are neither proprietary nor embargoed.'):
460 product.information_type = info_type438 product.information_type = info_type
461 branch.transitionToInformationType(InformationType.PROPRIETARY,439 branch.transitionToInformationType(InformationType.PROPRIETARY,
462 product.owner)440 product.owner)
463 for info_type in PROPRIETARY_INFORMATION_TYPES:441 for info_type in PRIVATE_PROJECT_TYPES:
464 product.information_type = info_type442 product.information_type = info_type
465443
466 def test_change_info_type_proprietary_check_translations(self):444 def test_change_info_type_proprietary_check_translations(self):
@@ -470,7 +448,7 @@
470 for usage in ServiceUsage:448 for usage in ServiceUsage:
471 product.information_type = InformationType.PUBLIC449 product.information_type = InformationType.PUBLIC
472 product.translations_usage = usage.value450 product.translations_usage = usage.value
473 for info_type in PROPRIETARY_INFORMATION_TYPES:451 for info_type in PRIVATE_PROJECT_TYPES:
474 if product.translations_usage == ServiceUsage.LAUNCHPAD:452 if product.translations_usage == ServiceUsage.LAUNCHPAD:
475 with ExpectedException(453 with ExpectedException(
476 CannotChangeInformationType,454 CannotChangeInformationType,
@@ -493,22 +471,6 @@
493 SpecificationSharingPolicy.PROPRIETARY,471 SpecificationSharingPolicy.PROPRIETARY,
494 product.specification_sharing_policy)472 product.specification_sharing_policy)
495473
496 def test_change_info_type_embargoed_sets_policies(self):
497 # Changing information type from public to embargoed sets the
498 # appropriate policies
499 product = self.factory.makeProduct()
500 with person_logged_in(product.owner):
501 product.information_type = InformationType.EMBARGOED
502 self.assertEqual(
503 BranchSharingPolicy.EMBARGOED_OR_PROPRIETARY,
504 product.branch_sharing_policy)
505 self.assertEqual(
506 BugSharingPolicy.EMBARGOED_OR_PROPRIETARY,
507 product.bug_sharing_policy)
508 self.assertEqual(
509 SpecificationSharingPolicy.EMBARGOED_OR_PROPRIETARY,
510 product.specification_sharing_policy)
511
512 def test_proprietary_to_public_leaves_policies(self):474 def test_proprietary_to_public_leaves_policies(self):
513 # Changing information type from public leaves sharing policies475 # Changing information type from public leaves sharing policies
514 # unchanged.476 # unchanged.
@@ -557,11 +519,13 @@
557 naked_product.information_type = InformationType.PUBLIC519 naked_product.information_type = InformationType.PUBLIC
558 self.assertIs(None, get_aps(naked_product))520 self.assertIs(None, get_aps(naked_product))
559521
560 # Projects can also be Embargoed because of reasons. Since they522 # Proprietary projects can have both Proprietary and Embargoed
561 # can have both Proprietary and Embargoed artifacts, and someone523 # artifacts, and someone who can see either needs LimitedView on
562 # who can see either needs LimitedView on the pillar they're on,524 # the pillar they're on. So both policies are permissible if
563 # both policies are permissible.525 # they exist.
564 naked_product.information_type = InformationType.EMBARGOED526 naked_product.information_type = InformationType.PROPRIETARY
527 naked_product.setBugSharingPolicy(
528 BugSharingPolicy.EMBARGOED_OR_PROPRIETARY)
565 [emb_policy] = aps.find([(product, InformationType.EMBARGOED)])529 [emb_policy] = aps.find([(product, InformationType.EMBARGOED)])
566 self.assertContentEqual(530 self.assertContentEqual(
567 [prop_policy.id, emb_policy.id], get_aps(naked_product))531 [prop_policy.id, emb_policy.id], get_aps(naked_product))
@@ -574,7 +538,7 @@
574 for policy in (token.value for token in TeamMembershipPolicy):538 for policy in (token.value for token in TeamMembershipPolicy):
575 with person_logged_in(team.teamowner):539 with person_logged_in(team.teamowner):
576 team.membership_policy = policy540 team.membership_policy = policy
577 for info_type in PROPRIETARY_INFORMATION_TYPES:541 for info_type in PRIVATE_PROJECT_TYPES:
578 with person_logged_in(product.owner):542 with person_logged_in(product.owner):
579 errors = list(product.checkInformationType(info_type))543 errors = list(product.checkInformationType(info_type))
580 if policy in EXCLUSIVE_TEAM_POLICY:544 if policy in EXCLUSIVE_TEAM_POLICY:
@@ -588,12 +552,12 @@
588 def test_checkInformationType_questions(self):552 def test_checkInformationType_questions(self):
589 # Proprietary products must not have questions.553 # Proprietary products must not have questions.
590 product = self.factory.makeProduct()554 product = self.factory.makeProduct()
591 for info_type in PROPRIETARY_INFORMATION_TYPES:555 for info_type in PRIVATE_PROJECT_TYPES:
592 with person_logged_in(product.owner):556 with person_logged_in(product.owner):
593 self.assertEqual([],557 self.assertEqual([],
594 list(product.checkInformationType(info_type)))558 list(product.checkInformationType(info_type)))
595 self.factory.makeQuestion(target=product)559 self.factory.makeQuestion(target=product)
596 for info_type in PROPRIETARY_INFORMATION_TYPES:560 for info_type in PRIVATE_PROJECT_TYPES:
597 with person_logged_in(product.owner):561 with person_logged_in(product.owner):
598 error, = list(product.checkInformationType(info_type))562 error, = list(product.checkInformationType(info_type))
599 with ExpectedException(563 with ExpectedException(
@@ -604,12 +568,12 @@
604 # Proprietary products must not have translations.568 # Proprietary products must not have translations.
605 productseries = self.factory.makeProductSeries()569 productseries = self.factory.makeProductSeries()
606 product = productseries.product570 product = productseries.product
607 for info_type in PROPRIETARY_INFORMATION_TYPES:571 for info_type in PRIVATE_PROJECT_TYPES:
608 with person_logged_in(product.owner):572 with person_logged_in(product.owner):
609 self.assertEqual([],573 self.assertEqual([],
610 list(product.checkInformationType(info_type)))574 list(product.checkInformationType(info_type)))
611 self.factory.makePOTemplate(productseries=productseries)575 self.factory.makePOTemplate(productseries=productseries)
612 for info_type in PROPRIETARY_INFORMATION_TYPES:576 for info_type in PRIVATE_PROJECT_TYPES:
613 with person_logged_in(product.owner):577 with person_logged_in(product.owner):
614 error, = list(product.checkInformationType(info_type))578 error, = list(product.checkInformationType(info_type))
615 with ExpectedException(579 with ExpectedException(
@@ -622,7 +586,7 @@
622 product = productseries.product586 product = productseries.product
623 entry = self.factory.makeTranslationImportQueueEntry(587 entry = self.factory.makeTranslationImportQueueEntry(
624 productseries=productseries)588 productseries=productseries)
625 for info_type in PROPRIETARY_INFORMATION_TYPES:589 for info_type in PRIVATE_PROJECT_TYPES:
626 with person_logged_in(product.owner):590 with person_logged_in(product.owner):
627 error, = list(product.checkInformationType(info_type))591 error, = list(product.checkInformationType(info_type))
628 with ExpectedException(592 with ExpectedException(
@@ -631,7 +595,7 @@
631 raise error595 raise error
632 removeSecurityProxy(entry).delete(entry.id)596 removeSecurityProxy(entry).delete(entry.id)
633 with person_logged_in(product.owner):597 with person_logged_in(product.owner):
634 for info_type in PROPRIETARY_INFORMATION_TYPES:598 for info_type in PRIVATE_PROJECT_TYPES:
635 self.assertContentEqual(599 self.assertContentEqual(
636 [], product.checkInformationType(info_type))600 [], product.checkInformationType(info_type))
637601
@@ -644,7 +608,7 @@
644 if mode == TranslationsBranchImportMode.NO_IMPORT:608 if mode == TranslationsBranchImportMode.NO_IMPORT:
645 continue609 continue
646 productseries.translations_autoimport_mode = mode610 productseries.translations_autoimport_mode = mode
647 for info_type in PROPRIETARY_INFORMATION_TYPES:611 for info_type in PRIVATE_PROJECT_TYPES:
648 error, = list(product.checkInformationType(info_type))612 error, = list(product.checkInformationType(info_type))
649 with ExpectedException(613 with ExpectedException(
650 CannotChangeInformationType,614 CannotChangeInformationType,
@@ -652,7 +616,7 @@
652 raise error616 raise error
653 productseries.translations_autoimport_mode = (617 productseries.translations_autoimport_mode = (
654 TranslationsBranchImportMode.NO_IMPORT)618 TranslationsBranchImportMode.NO_IMPORT)
655 for info_type in PROPRIETARY_INFORMATION_TYPES:619 for info_type in PRIVATE_PROJECT_TYPES:
656 self.assertContentEqual(620 self.assertContentEqual(
657 [], product.checkInformationType(info_type))621 [], product.checkInformationType(info_type))
658622
@@ -664,7 +628,7 @@
664 with person_logged_in(series.owner):628 with person_logged_in(series.owner):
665 bug.addTask(series.owner, series)629 bug.addTask(series.owner, series)
666 bug.default_bugtask.delete()630 bug.default_bugtask.delete()
667 for info_type in PROPRIETARY_INFORMATION_TYPES:631 for info_type in PRIVATE_PROJECT_TYPES:
668 error, = list(series.product.checkInformationType(info_type))632 error, = list(series.product.checkInformationType(info_type))
669 with ExpectedException(633 with ExpectedException(
670 CannotChangeInformationType,634 CannotChangeInformationType,
@@ -675,7 +639,7 @@
675 owner = self.factory.makePerson()639 owner = self.factory.makePerson()
676 product = self.factory.makeProduct(owner=owner)640 product = self.factory.makeProduct(owner=owner)
677 self.useContext(person_logged_in(owner))641 self.useContext(person_logged_in(owner))
678 for info_type in PROPRIETARY_INFORMATION_TYPES:642 for info_type in PRIVATE_PROJECT_TYPES:
679 product.information_type = info_type643 product.information_type = info_type
680 with ExpectedException(644 with ExpectedException(
681 ProprietaryProduct,645 ProprietaryProduct,
@@ -703,35 +667,35 @@
703 def test_product_information_type(self):667 def test_product_information_type(self):
704 # Product is created with specified information_type668 # Product is created with specified information_type
705 product = self.createProduct(669 product = self.createProduct(
706 information_type=InformationType.EMBARGOED,670 information_type=InformationType.PROPRIETARY,
707 license=License.OTHER_PROPRIETARY)671 license=License.OTHER_PROPRIETARY)
708 self.assertEqual(InformationType.EMBARGOED, product.information_type)672 self.assertEqual(InformationType.PROPRIETARY, product.information_type)
709 # Owner can set information_type673 # Owner can set information_type
710 with person_logged_in(removeSecurityProxy(product).owner):674 with person_logged_in(removeSecurityProxy(product).owner):
711 product.information_type = InformationType.PROPRIETARY675 product.information_type = InformationType.PUBLIC
712 self.assertEqual(InformationType.PROPRIETARY, product.information_type)676 self.assertEqual(InformationType.PUBLIC, product.information_type)
713 # Database persists information_type value677 # Database persists information_type value
714 store = Store.of(product)678 store = Store.of(product)
715 store.flush()679 store.flush()
716 store.reset()680 store.reset()
717 product = store.get(Product, product.id)681 product = store.get(Product, product.id)
718 self.assertEqual(InformationType.PROPRIETARY, product.information_type)682 self.assertEqual(InformationType.PUBLIC, product.information_type)
719 self.assertTrue(product.private)683 self.assertFalse(product.private)
720684
721 def test_switching_product_to_public_does_not_create_policy(self):685 def test_switching_product_to_public_does_not_create_policy(self):
722 # Creating a Embargoed product and switching it to Public does not686 # Creating a Proprietary product and switching it to Public does
723 # create a PUBLIC AccessPolicy.687 # not create a PUBLIC AccessPolicy.
724 product = self.createProduct(688 product = self.createProduct(
725 information_type=InformationType.EMBARGOED,689 information_type=InformationType.PROPRIETARY,
726 license=License.OTHER_PROPRIETARY)690 license=License.OTHER_PROPRIETARY)
727 aps = getUtility(IAccessPolicySource).findByPillar([product])691 aps = getUtility(IAccessPolicySource).findByPillar([product])
728 self.assertContentEqual(692 self.assertContentEqual(
729 [InformationType.PROPRIETARY, InformationType.EMBARGOED],693 [InformationType.PROPRIETARY],
730 [ap.type for ap in aps])694 [ap.type for ap in aps])
731 removeSecurityProxy(product).information_type = InformationType.PUBLIC695 removeSecurityProxy(product).information_type = InformationType.PUBLIC
732 aps = getUtility(IAccessPolicySource).findByPillar([product])696 aps = getUtility(IAccessPolicySource).findByPillar([product])
733 self.assertContentEqual(697 self.assertContentEqual(
734 [InformationType.PROPRIETARY, InformationType.EMBARGOED],698 [InformationType.PROPRIETARY],
735 [ap.type for ap in aps])699 [ap.type for ap in aps])
736700
737 def test_product_information_type_default(self):701 def test_product_information_type_default(self):
@@ -742,9 +706,9 @@
742 self.assertEqual(InformationType.PUBLIC, product.information_type)706 self.assertEqual(InformationType.PUBLIC, product.information_type)
743 self.assertFalse(product.private)707 self.assertFalse(product.private)
744708
745 invalid_information_types = [info_type for info_type in709 invalid_information_types = [
746 InformationType.items if info_type not in710 info_type for info_type in InformationType.items
747 PUBLIC_PROPRIETARY_INFORMATION_TYPES]711 if info_type not in PILLAR_INFORMATION_TYPES]
748712
749 def test_product_information_type_init_invalid_values(self):713 def test_product_information_type_init_invalid_values(self):
750 # Cannot create Product.information_type with invalid values.714 # Cannot create Product.information_type with invalid values.
@@ -796,41 +760,39 @@
796760
797 # However we can't change it back to a Proprietary because our761 # However we can't change it back to a Proprietary because our
798 # commercial subscription has expired.762 # commercial subscription has expired.
799 for info_type in PROPRIETARY_INFORMATION_TYPES:763 with ExpectedException(
800 with ExpectedException(
801 CommercialSubscribersOnly,764 CommercialSubscribersOnly,
802 'A valid commercial subscription is required for private'765 'A valid commercial subscription is required for private'
803 ' Projects.'):766 ' Projects.'):
804 product.information_type = info_type767 product.information_type = InformationType.PROPRIETARY
805768
806 def test_product_information_init_proprietary_requires_commercial(self):769 def test_product_information_init_proprietary_requires_commercial(self):
807 # Cannot create a product with proprietary types without specifying770 # Cannot create a product with proprietary types without specifying
808 # Other/Proprietary license.771 # Other/Proprietary license.
809 for info_type in PROPRIETARY_INFORMATION_TYPES:772 with ExpectedException(
810 with ExpectedException(
811 CommercialSubscribersOnly,773 CommercialSubscribersOnly,
812 'A valid commercial subscription is required for private'774 'A valid commercial subscription is required for private'
813 ' Projects.'):775 ' Projects.'):
814 self.createProduct(info_type)776 self.createProduct(InformationType.PROPRIETARY)
815 for info_type in PROPRIETARY_INFORMATION_TYPES:777 product = self.createProduct(
816 product = self.createProduct(info_type, License.OTHER_PROPRIETARY)778 InformationType.PROPRIETARY, License.OTHER_PROPRIETARY)
817 self.assertEqual(info_type, product.information_type)779 self.assertEqual(InformationType.PROPRIETARY, product.information_type)
818780
819 def test_no_answers_for_proprietary(self):781 def test_no_answers_for_proprietary(self):
820 # Enabling Answers is forbidden while information_type is proprietary.782 # Enabling Answers is forbidden while information_type is proprietary.
821 for info_type in PROPRIETARY_INFORMATION_TYPES:783 product = self.factory.makeProduct(
822 product = self.factory.makeProduct(information_type=info_type)784 information_type=InformationType.PROPRIETARY)
823 with person_logged_in(removeSecurityProxy(product).owner):785 with person_logged_in(removeSecurityProxy(product).owner):
824 self.assertEqual(ServiceUsage.UNKNOWN, product.answers_usage)786 self.assertEqual(ServiceUsage.UNKNOWN, product.answers_usage)
825 for usage in ServiceUsage.items:787 for usage in ServiceUsage.items:
826 if usage == ServiceUsage.LAUNCHPAD:788 if usage == ServiceUsage.LAUNCHPAD:
827 with ExpectedException(789 with ExpectedException(
828 ServiceUsageForbidden,790 ServiceUsageForbidden,
829 "Answers not allowed for non-public projects."):791 "Answers not allowed for non-public projects."):
830 product.answers_usage = ServiceUsage.LAUNCHPAD792 product.answers_usage = ServiceUsage.LAUNCHPAD
831 else:793 else:
832 # all other values are permitted.794 # all other values are permitted.
833 product.answers_usage = usage795 product.answers_usage = usage
834796
835 def test_answers_for_public(self):797 def test_answers_for_public(self):
836 # Enabling answers is permitted while information_type is PUBLIC.798 # Enabling answers is permitted while information_type is PUBLIC.
@@ -1265,14 +1227,14 @@
1265 # Access policies for Product.information_type are not pruned.1227 # Access policies for Product.information_type are not pruned.
1266 owner = self.factory.makePerson()1228 owner = self.factory.makePerson()
1267 product = self.factory.makeProduct(1229 product = self.factory.makeProduct(
1268 information_type=InformationType.EMBARGOED, owner=owner)1230 information_type=InformationType.PROPRIETARY, owner=owner)
1269 with person_logged_in(owner):1231 with person_logged_in(owner):
1270 product.setBugSharingPolicy(BugSharingPolicy.PROPRIETARY)1232 product.setBugSharingPolicy(BugSharingPolicy.FORBIDDEN)
1271 product.setSpecificationSharingPolicy(1233 product.setSpecificationSharingPolicy(
1272 SpecificationSharingPolicy.PROPRIETARY)1234 SpecificationSharingPolicy.FORBIDDEN)
1273 product.setBranchSharingPolicy(BranchSharingPolicy.PROPRIETARY)1235 product.setBranchSharingPolicy(BranchSharingPolicy.FORBIDDEN)
1274 self.assertIsNot(None, getUtility(IAccessPolicySource).find(1236 self.assertIsNot(None, getUtility(IAccessPolicySource).find(
1275 [(product, InformationType.EMBARGOED)]).one())1237 [(product, InformationType.PROPRIETARY)]).one())
12761238
12771239
1278class TestProductBugInformationTypes(TestCaseWithFactory):1240class TestProductBugInformationTypes(TestCaseWithFactory):
@@ -1833,12 +1795,6 @@
1833 with ExpectedException(1795 with ExpectedException(
1834 ProprietaryProduct, "The project is Proprietary."):1796 ProprietaryProduct, "The project is Proprietary."):
1835 self.setSharingPolicy(policy, owner)1797 self.setSharingPolicy(policy, owner)
1836 with person_logged_in(owner):
1837 self.product.information_type = InformationType.EMBARGOED
1838 for policy in policies_permitting_public:
1839 with ExpectedException(
1840 ProprietaryProduct, "The project is Embargoed."):
1841 self.setSharingPolicy(policy, owner)
18421798
18431799
1844class ProductBugSharingPolicyTestCase(BaseSharingPolicyTests,1800class ProductBugSharingPolicyTestCase(BaseSharingPolicyTests,
@@ -2255,11 +2211,9 @@
2255 def makeAllInformationTypes(self):2211 def makeAllInformationTypes(self):
2256 proprietary = self.factory.makeProduct(2212 proprietary = self.factory.makeProduct(
2257 information_type=InformationType.PROPRIETARY)2213 information_type=InformationType.PROPRIETARY)
2258 embargoed = self.factory.makeProduct(
2259 information_type=InformationType.EMBARGOED)
2260 public = self.factory.makeProduct(2214 public = self.factory.makeProduct(
2261 information_type=InformationType.PUBLIC)2215 information_type=InformationType.PUBLIC)
2262 return proprietary, embargoed, public2216 return proprietary, public
22632217
2264 @staticmethod2218 @staticmethod
2265 def filterFind(user):2219 def filterFind(user):
@@ -2275,22 +2229,15 @@
2275 proprietary = self.factory.makeProduct(2229 proprietary = self.factory.makeProduct(
2276 information_type=InformationType.PROPRIETARY,2230 information_type=InformationType.PROPRIETARY,
2277 owner=owner)2231 owner=owner)
2278 embargoed = self.factory.makeProduct(
2279 information_type=InformationType.EMBARGOED,
2280 owner=owner)
2281 result = ProductSet.get_users_private_products(owner)2232 result = ProductSet.get_users_private_products(owner)
2282 self.assertIn(proprietary, result)2233 self.assertIn(proprietary, result)
2283 self.assertIn(embargoed, result)
22842234
2285 def test_get_all_active_omits_proprietary(self):2235 def test_get_all_active_omits_proprietary(self):
2286 # Ignore proprietary products for anonymous users2236 # Ignore proprietary products for anonymous users
2287 proprietary = self.factory.makeProduct(2237 proprietary = self.factory.makeProduct(
2288 information_type=InformationType.PROPRIETARY)2238 information_type=InformationType.PROPRIETARY)
2289 embargoed = self.factory.makeProduct(
2290 information_type=InformationType.EMBARGOED)
2291 result = ProductSet.get_all_active(None)2239 result = ProductSet.get_all_active(None)
2292 self.assertNotIn(proprietary, result)2240 self.assertNotIn(proprietary, result)
2293 self.assertNotIn(embargoed, result)
22942241
2295 def test_search_respects_privacy(self):2242 def test_search_respects_privacy(self):
2296 # Proprietary products are filtered from the results for people who2243 # Proprietary products are filtered from the results for people who
@@ -2305,19 +2252,17 @@
23052252
2306 def test_getProductPrivacyFilterAnonymous(self):2253 def test_getProductPrivacyFilterAnonymous(self):
2307 # Ignore proprietary products for anonymous users2254 # Ignore proprietary products for anonymous users
2308 proprietary, embargoed, public = self.makeAllInformationTypes()2255 proprietary, public = self.makeAllInformationTypes()
2309 result = self.filterFind(None)2256 result = self.filterFind(None)
2310 self.assertIn(public, result)2257 self.assertIn(public, result)
2311 self.assertNotIn(embargoed, result)
2312 self.assertNotIn(proprietary, result)2258 self.assertNotIn(proprietary, result)
23132259
2314 def test_getProductPrivacyFilter_excludes_random_users(self):2260 def test_getProductPrivacyFilter_excludes_random_users(self):
2315 # Exclude proprietary products for anonymous users2261 # Exclude proprietary products for anonymous users
2316 random = self.factory.makePerson()2262 random = self.factory.makePerson()
2317 proprietary, embargoed, public = self.makeAllInformationTypes()2263 proprietary, public = self.makeAllInformationTypes()
2318 result = self.filterFind(random)2264 result = self.filterFind(random)
2319 self.assertIn(public, result)2265 self.assertIn(public, result)
2320 self.assertNotIn(embargoed, result)
2321 self.assertNotIn(proprietary, result)2266 self.assertNotIn(proprietary, result)
23222267
2323 def grant(self, pillar, information_type, grantee):2268 def grant(self, pillar, information_type, grantee):
@@ -2329,61 +2274,53 @@
2329 def test_getProductPrivacyFilter_respects_grants(self):2274 def test_getProductPrivacyFilter_respects_grants(self):
2330 # Include proprietary products for users with right grants.2275 # Include proprietary products for users with right grants.
2331 grantee = self.factory.makePerson()2276 grantee = self.factory.makePerson()
2332 proprietary, embargoed, public = self.makeAllInformationTypes()2277 proprietary, public = self.makeAllInformationTypes()
2333 self.grant(embargoed, InformationType.EMBARGOED, grantee)
2334 self.grant(proprietary, InformationType.PROPRIETARY, grantee)2278 self.grant(proprietary, InformationType.PROPRIETARY, grantee)
2335 result = self.filterFind(grantee)2279 result = self.filterFind(grantee)
2336 self.assertIn(public, result)2280 self.assertIn(public, result)
2337 self.assertIn(embargoed, result)
2338 self.assertIn(proprietary, result)2281 self.assertIn(proprietary, result)
23392282
2340 def test_getProductPrivacyFilter_ignores_wrong_product(self):2283 def test_getProductPrivacyFilter_ignores_wrong_product(self):
2341 # Exclude proprietary products if grant is on wrong product.2284 # Exclude proprietary products if grant is on wrong product.
2342 grantee = self.factory.makePerson()2285 grantee = self.factory.makePerson()
2343 proprietary, embargoed, public = self.makeAllInformationTypes()2286 proprietary, public = self.makeAllInformationTypes()
2344 self.factory.makeAccessPolicyGrant(grantee=grantee)2287 self.factory.makeAccessPolicyGrant(grantee=grantee)
2345 result = self.filterFind(grantee)2288 result = self.filterFind(grantee)
2346 self.assertIn(public, result)2289 self.assertIn(public, result)
2347 self.assertNotIn(embargoed, result)
2348 self.assertNotIn(proprietary, result)2290 self.assertNotIn(proprietary, result)
23492291
2350 def test_getProductPrivacyFilter_ignores_wrong_info_type(self):2292 def test_getProductPrivacyFilter_ignores_wrong_info_type(self):
2351 # Exclude proprietary products if grant is on wrong information type.2293 # Exclude proprietary products if grant is on wrong information type.
2352 grantee = self.factory.makePerson()2294 grantee = self.factory.makePerson()
2353 proprietary, embargoed, public = self.makeAllInformationTypes()2295 proprietary, public = self.makeAllInformationTypes()
2354 self.factory.makeAccessPolicy(2296 self.factory.makeAccessPolicy(
2355 proprietary, InformationType.PRIVATESECURITY)2297 proprietary, InformationType.PRIVATESECURITY)
2356 self.grant(proprietary, InformationType.PRIVATESECURITY, grantee)2298 self.grant(proprietary, InformationType.PRIVATESECURITY, grantee)
2357 result = self.filterFind(grantee)2299 result = self.filterFind(grantee)
2358 self.assertIn(public, result)2300 self.assertIn(public, result)
2359 self.assertNotIn(embargoed, result)
2360 self.assertNotIn(proprietary, result)2301 self.assertNotIn(proprietary, result)
23612302
2362 def test_getProductPrivacyFilter_respects_team_grants(self):2303 def test_getProductPrivacyFilter_respects_team_grants(self):
2363 # Include proprietary products for users in teams with right grants.2304 # Include proprietary products for users in teams with right grants.
2364 grantee = self.factory.makeTeam()2305 grantee = self.factory.makeTeam()
2365 proprietary, embargoed, public = self.makeAllInformationTypes()2306 proprietary, public = self.makeAllInformationTypes()
2366 self.grant(embargoed, InformationType.EMBARGOED, grantee)
2367 self.grant(proprietary, InformationType.PROPRIETARY, grantee)2307 self.grant(proprietary, InformationType.PROPRIETARY, grantee)
2368 result = self.filterFind(grantee.teamowner)2308 result = self.filterFind(grantee.teamowner)
2369 self.assertIn(public, result)2309 self.assertIn(public, result)
2370 self.assertIn(embargoed, result)
2371 self.assertIn(proprietary, result)2310 self.assertIn(proprietary, result)
23722311
2373 def test_getProductPrivacyFilter_includes_admins(self):2312 def test_getProductPrivacyFilter_includes_admins(self):
2374 # Launchpad admins can see everything.2313 # Launchpad admins can see everything.
2375 proprietary, embargoed, public = self.makeAllInformationTypes()2314 proprietary, public = self.makeAllInformationTypes()
2376 result = self.filterFind(self.factory.makeAdministrator())2315 result = self.filterFind(self.factory.makeAdministrator())
2377 self.assertIn(public, result)2316 self.assertIn(public, result)
2378 self.assertIn(embargoed, result)
2379 self.assertIn(proprietary, result)2317 self.assertIn(proprietary, result)
23802318
2381 def test_getProductPrivacyFilter_includes_commercial_admins(self):2319 def test_getProductPrivacyFilter_includes_commercial_admins(self):
2382 # Commercial admins can see everything.2320 # Commercial admins can see everything.
2383 proprietary, embargoed, public = self.makeAllInformationTypes()2321 proprietary, public = self.makeAllInformationTypes()
2384 result = self.filterFind(self.factory.makeCommercialAdmin())2322 result = self.filterFind(self.factory.makeCommercialAdmin())
2385 self.assertIn(public, result)2323 self.assertIn(public, result)
2386 self.assertIn(embargoed, result)
2387 self.assertIn(proprietary, result)2324 self.assertIn(proprietary, result)
23882325
23892326
23902327
=== modified file 'lib/lp/registry/tests/test_product_vocabularies.py'
--- lib/lp/registry/tests/test_product_vocabularies.py 2012-10-19 10:34:55 +0000
+++ lib/lp/registry/tests/test_product_vocabularies.py 2015-07-02 02:01:38 +0000
@@ -104,10 +104,6 @@
104 # Embargoed and proprietary products are only returned if104 # Embargoed and proprietary products are only returned if
105 # the current user can see them.105 # the current user can see them.
106 public_product = self.factory.makeProduct('quux-public')106 public_product = self.factory.makeProduct('quux-public')
107 embargoed_owner = self.factory.makePerson()
108 embargoed_product = self.factory.makeProduct(
109 name='quux-embargoed', owner=embargoed_owner,
110 information_type=InformationType.EMBARGOED)
111 proprietary_owner = self.factory.makePerson()107 proprietary_owner = self.factory.makePerson()
112 proprietary_product = self.factory.makeProduct(108 proprietary_product = self.factory.makeProduct(
113 name='quux-proprietary', owner=proprietary_owner,109 name='quux-proprietary', owner=proprietary_owner,
@@ -125,17 +121,17 @@
125 self.assertEqual([public_product], list(result))121 self.assertEqual([public_product], list(result))
126122
127 # People with grants on a private product can see this product.123 # People with grants on a private product can see this product.
128 with person_logged_in(embargoed_owner):124 with person_logged_in(proprietary_owner):
129 getUtility(IService, 'sharing').sharePillarInformation(125 getUtility(IService, 'sharing').sharePillarInformation(
130 embargoed_product, user, embargoed_owner,126 proprietary_product, user, proprietary_owner,
131 {InformationType.EMBARGOED: SharingPermission.ALL})127 {InformationType.PROPRIETARY: SharingPermission.ALL})
132 with person_logged_in(user):128 with person_logged_in(user):
133 result = self.vocabulary.search('quux')129 result = self.vocabulary.search('quux')
134 self.assertEqual([embargoed_product, public_product], list(result))130 self.assertEqual(
131 [proprietary_product, public_product], list(result))
135132
136 # Admins can see all products.133 # Admins can see all products.
137 with celebrity_logged_in('admin'):134 with celebrity_logged_in('admin'):
138 result = self.vocabulary.search('quux')135 result = self.vocabulary.search('quux')
139 self.assertEqual(136 self.assertEqual(
140 [embargoed_product, proprietary_product, public_product],137 [proprietary_product, public_product], list(result))
141 list(result))
142138
=== modified file 'lib/lp/registry/tests/test_productseries.py'
--- lib/lp/registry/tests/test_productseries.py 2015-01-29 14:14:01 +0000
+++ lib/lp/registry/tests/test_productseries.py 2015-07-02 02:01:38 +0000
@@ -16,10 +16,7 @@
16from zope.security.interfaces import Unauthorized16from zope.security.interfaces import Unauthorized
17from zope.security.proxy import removeSecurityProxy17from zope.security.proxy import removeSecurityProxy
1818
19from lp.app.enums import (19from lp.app.enums import InformationType
20 InformationType,
21 PROPRIETARY_INFORMATION_TYPES,
22 )
23from lp.app.interfaces.informationtype import IInformationType20from lp.app.interfaces.informationtype import IInformationType
24from lp.app.interfaces.services import IService21from lp.app.interfaces.services import IService
25from lp.registry.enums import SharingPermission22from lp.registry.enums import SharingPermission
@@ -74,15 +71,14 @@
74 # Autoimports are forbidden if products are proprietary/embargoed.71 # Autoimports are forbidden if products are proprietary/embargoed.
75 series = self.factory.makeProductSeries()72 series = self.factory.makeProductSeries()
76 self.useContext(person_logged_in(series.product.owner))73 self.useContext(person_logged_in(series.product.owner))
77 for info_type in PROPRIETARY_INFORMATION_TYPES:74 series.product.information_type = InformationType.PROPRIETARY
78 series.product.information_type = info_type75 for mode in TranslationsBranchImportMode.items:
79 for mode in TranslationsBranchImportMode.items:76 if mode == TranslationsBranchImportMode.NO_IMPORT:
80 if mode == TranslationsBranchImportMode.NO_IMPORT:77 continue
81 continue78 with ExpectedException(ProprietaryProduct,
82 with ExpectedException(ProprietaryProduct,79 'Translations are disabled for proprietary'
83 'Translations are disabled for proprietary'80 ' projects.'):
84 ' projects.'):81 series.translations_autoimport_mode = mode
85 series.translations_autoimport_mode = mode
8682
8783
88class ProductSeriesReleasesTestCase(TestCaseWithFactory):84class ProductSeriesReleasesTestCase(TestCaseWithFactory):
@@ -201,17 +197,6 @@
201 series.setPackaging(197 series.setPackaging(
202 sp.distroseries, sp.sourcepackagename, series.owner)198 sp.distroseries, sp.sourcepackagename, series.owner)
203199
204 def test_refuses_EMBARGOED(self):
205 """Packaging cannot be created for EMBARGOED productseries"""
206 product = self.factory.makeProduct(
207 information_type=InformationType.EMBARGOED)
208 sp = self.makeSourcePackage()
209 series = self.factory.makeProductSeries(product=product)
210 with ExpectedException(CannotPackageProprietaryProduct,
211 'Only Public project series can be packaged, not Embargoed.'):
212 series.setPackaging(
213 sp.distroseries, sp.sourcepackagename, series.owner)
214
215 def test_setPackaging_two_packagings(self):200 def test_setPackaging_two_packagings(self):
216 # More than one sourcepackage from the same distroseries201 # More than one sourcepackage from the same distroseries
217 # can be linked to a productseries.202 # can be linked to a productseries.
218203
=== modified file 'lib/lp/translations/browser/tests/test_product_view.py'
--- lib/lp/translations/browser/tests/test_product_view.py 2014-02-19 04:01:46 +0000
+++ lib/lp/translations/browser/tests/test_product_view.py 2015-07-02 02:01:38 +0000
@@ -12,7 +12,7 @@
1212
13from lp.app.enums import (13from lp.app.enums import (
14 InformationType,14 InformationType,
15 PUBLIC_PROPRIETARY_INFORMATION_TYPES,15 PILLAR_INFORMATION_TYPES,
16 ServiceUsage,16 ServiceUsage,
17 )17 )
18from lp.registry.interfaces.series import SeriesStatus18from lp.registry.interfaces.series import SeriesStatus
@@ -132,7 +132,7 @@
132 def test_launchpad_not_listed_for_proprietary(self):132 def test_launchpad_not_listed_for_proprietary(self):
133 product = self.factory.makeProduct()133 product = self.factory.makeProduct()
134 with person_logged_in(product.owner):134 with person_logged_in(product.owner):
135 for info_type in PUBLIC_PROPRIETARY_INFORMATION_TYPES:135 for info_type in PILLAR_INFORMATION_TYPES:
136 product.information_type = info_type136 product.information_type = info_type
137 view = create_initialized_view(137 view = create_initialized_view(
138 product, '+configure-translations')138 product, '+configure-translations')