launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14887
[Merge] lp:~stevenk/launchpad/no-public-for-all-projects into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/no-public-for-all-projects into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1095318 in Launchpad itself: "undefined policy_name shown on +sharing page"
https://bugs.launchpad.net/launchpad/+bug/1095318
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/no-public-for-all-projects/+merge/141700
If a product is created with a PROPRIETARY or EMBARGOED information type and then has its information type set to PUBLIC, it will create a AccessPolicy with a type of PUBLIC for the pillar, which is nonsense, since public artefacts do not require them. To solve this, we intersect the missing policies with PRIVATE_INFORMATION_TYPES.
Drive by some clean-up in _pruneUnusedPolicies too.
--
https://code.launchpad.net/~stevenk/launchpad/no-public-for-all-projects/+merge/141700
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/no-public-for-all-projects into lp:launchpad.
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-12-26 01:04:05 +0000
+++ lib/lp/registry/model/product.py 2013-01-03 04:29:23 +0000
@@ -788,7 +788,8 @@
existing_types = set([
access_policy.type for access_policy in existing_policies])
# Create the missing policies.
- required_types = set(information_types).difference(existing_types)
+ required_types = set(information_types).difference(
+ existing_types).intersection(PRIVATE_INFORMATION_TYPES)
policies = itertools.product((self,), required_types)
policies = getUtility(IAccessPolicySource).create(policies)
@@ -805,12 +806,11 @@
allowed_branch_types = set(
BRANCH_POLICY_ALLOWED_TYPES.get(
self.branch_sharing_policy, FREE_INFORMATION_TYPES))
- allowed_specification_types = set(
+ allowed_spec_types = set(
SPECIFICATION_POLICY_ALLOWED_TYPES.get(
- self.specification_sharing_policy, [InformationType.PUBLIC])
- )
- allowed_types = allowed_bug_types.union(allowed_branch_types)
- allowed_types = allowed_types.union(allowed_specification_types)
+ self.specification_sharing_policy, [InformationType.PUBLIC]))
+ allowed_types = (
+ allowed_bug_types | allowed_branch_types | allowed_spec_types)
allowed_types.add(self.information_type)
# Fetch all APs, and after filtering out ones that are forbidden
# by the bug, branch, and specification policies, the APs that have no
=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py 2012-12-26 01:04:05 +0000
+++ lib/lp/registry/tests/test_product.py 2013-01-03 04:29:23 +0000
@@ -428,11 +428,10 @@
spec = self.factory.makeSpecification(product=product)
for info_type in PROPRIETARY_INFORMATION_TYPES:
with ExpectedException(
- CannotChangeInformationType,
- 'Some blueprints are public.'):
+ CannotChangeInformationType, 'Some blueprints are public.'):
product.information_type = info_type
- spec.transitionToInformationType(InformationType.PROPRIETARY,
- product.owner)
+ spec.transitionToInformationType(
+ InformationType.PROPRIETARY, product.owner)
bug = self.factory.makeBug(target=product)
for bug_info_type in FREE_INFORMATION_TYPES:
bug.transitionToInformationType(bug_info_type, product.owner)
@@ -656,6 +655,22 @@
self.assertEqual(InformationType.PROPRIETARY, product.information_type)
self.assertTrue(product.private)
+ def test_switching_product_to_public_does_not_create_policy(self):
+ # Creating a Embargoed product and switching it to Public does not
+ # create a PUBLIC AccessPolicy.
+ product = self.createProduct(
+ information_type=InformationType.EMBARGOED,
+ license=License.OTHER_PROPRIETARY)
+ aps = getUtility(IAccessPolicySource).findByPillar([product])
+ self.assertContentEqual(
+ [InformationType.PROPRIETARY, InformationType.EMBARGOED],
+ [ap.type for ap in aps])
+ removeSecurityProxy(product).information_type = InformationType.PUBLIC
+ aps = getUtility(IAccessPolicySource).findByPillar([product])
+ self.assertContentEqual(
+ [InformationType.PROPRIETARY, InformationType.EMBARGOED],
+ [ap.type for ap in aps])
+
def test_product_information_type_default(self):
# Default information_type is PUBLIC
owner = self.factory.makePerson()