Merge ~cjwatson/launchpad:verifyObject-person-as-registry into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 49567e74e07dd568a13379eff6e4524a7f05a054
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:verifyObject-person-as-registry
Merge into: launchpad:master
Diff against target: 95 lines (+22/-9)
2 files modified
lib/lp/registry/doc/person.rst (+16/-6)
lib/lp/soyuz/doc/package-diff.rst (+6/-3)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+453460@code.launchpad.net

Commit message

Run verifyObject on IPerson as a registry expert

Description of the change

Evaluating `Person.exported_id` requires high privileges. Perhaps we should have made it a method so that `verifyObject` wouldn't complain, but that would be slower from the client side and rather artificial. There seems to be some precedent for running `verifyObject` as privileged users to cope with permission issues.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

Makes sense

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/doc/person.rst b/lib/lp/registry/doc/person.rst
2index eb3075a..867a46b 100644
3--- a/lib/lp/registry/doc/person.rst
4+++ b/lib/lp/registry/doc/person.rst
5@@ -11,7 +11,7 @@ not Launchpad users.
6 >>> from lp.services.identity.interfaces.emailaddress import (
7 ... IEmailAddressSet,
8 ... )
9- >>> from lp.testing import verifyObject
10+ >>> from lp.testing import celebrity_logged_in, verifyObject
11 >>> from lp.registry.interfaces.person import (
12 ... IHasStanding,
13 ... IPerson,
14@@ -22,21 +22,27 @@ not Launchpad users.
15 ... IHasTranslationImports,
16 ... )
17
18-Any Person object (either a person or a team) implements IPerson...
19+Any Person object (either a person or a team) implements IPerson. We have
20+to check this as a registry expert, because evaluating
21+``Person.exported_id`` requires high privileges.
22
23 >>> personset = getUtility(IPersonSet)
24 >>> foobar = personset.getByName("name16")
25 >>> foobar.is_team
26 False
27
28- >>> verifyObject(IPerson, foobar)
29+ >>> with celebrity_logged_in("registry_experts"):
30+ ... verifyObject(IPerson, foobar)
31+ ...
32 True
33
34 >>> ubuntu_team = personset.getByName("ubuntu-team")
35 >>> ubuntu_team.is_team
36 True
37
38- >>> verifyObject(IPerson, ubuntu_team)
39+ >>> with celebrity_logged_in("registry_experts"):
40+ ... verifyObject(IPerson, ubuntu_team)
41+ ...
42 True
43
44
45@@ -416,7 +422,9 @@ property of IPerson or check if the object provides the ITeam interface.
46 >>> ITeam.providedBy(landscape_devs)
47 True
48
49- >>> verifyObject(ITeam, landscape_devs)
50+ >>> with celebrity_logged_in("registry_experts"):
51+ ... verifyObject(ITeam, landscape_devs)
52+ ...
53 True
54
55 Also note that a team will never have a Launchpad account, so its
56@@ -503,7 +511,9 @@ entries into teams.
57 >>> ITeam.providedBy(not_a_person)
58 True
59
60- >>> verifyObject(ITeam, not_a_person)
61+ >>> with celebrity_logged_in("registry_experts"):
62+ ... verifyObject(ITeam, not_a_person)
63+ ...
64 True
65
66 The team owner is also added as an administrator of its team.
67diff --git a/lib/lp/soyuz/doc/package-diff.rst b/lib/lp/soyuz/doc/package-diff.rst
68index ac90cfe..c081d91 100644
69--- a/lib/lp/soyuz/doc/package-diff.rst
70+++ b/lib/lp/soyuz/doc/package-diff.rst
71@@ -36,7 +36,7 @@ Requesting a diff from pmount_0.1-1 to pmount_0.1-2.
72
73 Let's inspect the PackageDiff record created.
74
75- >>> from lp.testing import verifyObject
76+ >>> from lp.testing import celebrity_logged_in, verifyObject
77 >>> from lp.soyuz.interfaces.packagediff import IPackageDiff
78
79 >>> verifyObject(IPackageDiff, package_diff)
80@@ -45,10 +45,13 @@ Let's inspect the PackageDiff record created.
81 Its main attributes are:
82
83 * 'requester', which maps to a `IPerson`, the user who made the diff
84- request.
85+ request. (We have to check this as a registry expert, because evaluating
86+ ``Person.exported_id`` requires high privileges.)
87
88 >>> from lp.registry.interfaces.person import IPerson
89- >>> verifyObject(IPerson, package_diff.requester)
90+ >>> with celebrity_logged_in("registry_experts"):
91+ ... verifyObject(IPerson, package_diff.requester)
92+ ...
93 True
94
95 >>> print(package_diff.requester.displayname)

Subscribers

People subscribed via source and target branches

to status/vote changes: