← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/add-maintainer-to-policies into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/add-maintainer-to-policies into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/add-maintainer-to-policies/+merge/112227

Summary
=======
Dislosure has introduced access policies, and has ensured that those policies
exist when a product is made. However, no one is added to those policies by
default. We want the maintainer to be added.

Preimp
======
Spoke with Curtis Hovey.

Implementation
==============
After the policies are created for the product, the owner is added to them.
Because there *isn't* actually a person responsible for doing this, but there
is no option for the grantor to be `None`, the owner is set as both grantee
and grantor. This seemed preferable to creating yet another non-person entity
that was responsible, or using the registrant.

Tests
=====
bin/test -vvct test_product

QA
==
Create a new project and ensure the maintainer has access to the existing
policies.

LoC
===
This is part of the disclosure work, and has already been resourced.

Lint
====

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/model/product.py
  lib/lp/registry/tests/test_product.py
-- 
https://code.launchpad.net/~jcsackett/launchpad/add-maintainer-to-policies/+merge/112227
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/add-maintainer-to-policies into lp:launchpad.
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2012-05-25 21:18:48 +0000
+++ lib/lp/registry/model/product.py	2012-06-26 21:34:27 +0000
@@ -118,7 +118,10 @@
 from lp.code.model.sourcepackagerecipedata import SourcePackageRecipeData
 from lp.registry.enums import InformationType
 from lp.registry.errors import CommercialSubscribersOnly
-from lp.registry.interfaces.accesspolicy import IAccessPolicySource
+from lp.registry.interfaces.accesspolicy import (
+    IAccessPolicySource,
+    IAccessPolicyGrantSource,
+    )
 from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
 from lp.registry.interfaces.person import (
     IPersonSet,
@@ -1518,7 +1521,13 @@
         policies = itertools.product(
             (product,), (InformationType.USERDATA,
                 InformationType.EMBARGOEDSECURITY))
-        getUtility(IAccessPolicySource).create(policies)
+        policies = getUtility(IAccessPolicySource).create(policies)
+
+        # Add the maintainer to the default policies.
+        grants = []
+        for p in policies:
+            grants.append((p, owner, owner))
+        getUtility(IAccessPolicyGrantSource).grant(grants)
 
         return product
 

=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py	2012-05-25 05:01:10 +0000
+++ lib/lp/registry/tests/test_product.py	2012-06-26 21:34:27 +0000
@@ -32,7 +32,10 @@
     CommercialSubscribersOnly,
     OpenTeamLinkageError,
     )
-from lp.registry.interfaces.accesspolicy import IAccessPolicySource
+from lp.registry.interfaces.accesspolicy import (
+    IAccessPolicySource,
+    IAccessPolicyGrantSource,
+    )
 from lp.registry.interfaces.oopsreferences import IHasOOPSReferences
 from lp.registry.interfaces.person import (
     CLOSED_TEAM_POLICY,
@@ -358,6 +361,15 @@
             InformationType.USERDATA, InformationType.EMBARGOEDSECURITY]
         self.assertContentEqual(expected, [policy.type for policy in ap])
 
+    def test_product_creation_grants_maintainer_access(self):
+        # Creating a new product also creates AccessPolicies for it.
+        product = self.factory.makeProduct()
+        policies = getUtility(IAccessPolicySource).findByPillar((product,))
+        grants = getUtility(IAccessPolicyGrantSource).findByPolicy(policies)
+        expected_grantess = set([product.owner])
+        grantees = set([grant.grantee for grant in grants])
+        self.assertEqual(expected_grantess, grantees)
+
 
 class TestProductFiles(TestCase):
     """Tests for downloadable product files."""


Follow ups