Merge lp:~abentley/launchpad/user-blueprints-privacy into lp:launchpad

Proposed by Aaron Bentley on 2012-10-16
Status: Merged
Approved by: Aaron Bentley on 2012-10-16
Approved revision: no longer in the source branch.
Merged at revision: 16157
Proposed branch: lp:~abentley/launchpad/user-blueprints-privacy
Merge into: lp:launchpad
Prerequisite: lp:~abentley/launchpad/user-blueprints
Diff against target: 48 lines (+29/-1)
2 files modified
lib/lp/registry/model/person.py (+1/-1)
lib/lp/registry/tests/test_person.py (+28/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/user-blueprints-privacy
Reviewer Review Type Date Requested Status
Deryck Hodge (community) 2012-10-16 Approve on 2012-10-16
Review via email: mp+129967@code.launchpad.net

Commit Message

Use privacy filter for Person.specifications.

Description of the Change

= Summary =
Fix bug #1063275: user blueprints page cannot be viewed

== Proposed fix ==
Use get_specification_privacy_filter

== Pre-implementation notes ==
None

== LOC Rationale ==
Part of Private Projects

== Implementation details ==
Reinstated privacy tests from r16149, added privacy filter

== Tests ==
bin/test test_product -t Specifications

== Demo and Q/A ==
Create a proprietary blueprint. It should be listed on blueprints.launchpad.net/~USER. Log out. It should no longer be listed.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/testing/factory.py
  lib/lp/blueprints/model/specification.py
  lib/lp/blueprints/model/sprint.py
  lib/lp/registry/model/person.py
  lib/lp/registry/tests/test_person.py

To post a comment you must log in.
Deryck Hodge (deryck) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/person.py'
2--- lib/lp/registry/model/person.py 2012-10-17 00:08:30 +0000
3+++ lib/lp/registry/model/person.py 2012-10-17 00:08:30 +0000
4@@ -865,7 +865,7 @@
5 Select(SpecificationSubscription.specificationID,
6 [SpecificationSubscription.person == self]
7 )))
8- clauses = [Or(*role_clauses)]
9+ clauses = [Or(*role_clauses), get_specification_privacy_filter(user)]
10 clauses.extend(get_specification_filters(filter))
11 results = Store.of(self).find(Specification, *clauses)
12 # The default sort is priority descending, so only explictly sort for
13
14=== modified file 'lib/lp/registry/tests/test_person.py'
15--- lib/lp/registry/tests/test_person.py 2012-10-17 00:08:30 +0000
16+++ lib/lp/registry/tests/test_person.py 2012-10-17 00:08:30 +0000
17@@ -1783,3 +1783,31 @@
18 self.assertEqual([blueprint1], result)
19 result = list_result(owner, ['def'])
20 self.assertEqual([blueprint2], result)
21+
22+ def test_proprietary_not_listed(self):
23+ # Proprietary blueprints are not listed for random users
24+ blueprint1 = self.makeSpec(
25+ information_type=InformationType.PROPRIETARY)
26+ self.assertEqual([], list_result(blueprint1.owner))
27+
28+ def test_proprietary_listed_for_artifact_grant(self):
29+ # Proprietary blueprints are listed for users with an artifact grant.
30+ blueprint1 = self.makeSpec(
31+ information_type=InformationType.PROPRIETARY)
32+ grant = self.factory.makeAccessArtifactGrant(
33+ concrete_artifact=blueprint1)
34+ self.assertEqual(
35+ [blueprint1],
36+ list_result(blueprint1.owner, user=grant.grantee))
37+
38+ def test_proprietary_listed_for_policy_grant(self):
39+ # Proprietary blueprints are listed for users with a policy grant.
40+ blueprint1 = self.makeSpec(
41+ information_type=InformationType.PROPRIETARY)
42+ policy_source = getUtility(IAccessPolicySource)
43+ (policy,) = policy_source.find(
44+ [(blueprint1.product, InformationType.PROPRIETARY)])
45+ grant = self.factory.makeAccessPolicyGrant(policy)
46+ self.assertEqual(
47+ [blueprint1],
48+ list_result(blueprint1.owner, user=grant.grantee))