← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:verifyObject-person-as-registry into launchpad:master.

Commit message:
Run verifyObject on IPerson as a registry expert

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/453460

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:verifyObject-person-as-registry into launchpad:master.
diff --git a/lib/lp/registry/doc/person.rst b/lib/lp/registry/doc/person.rst
index eb3075a..867a46b 100644
--- a/lib/lp/registry/doc/person.rst
+++ b/lib/lp/registry/doc/person.rst
@@ -11,7 +11,7 @@ not Launchpad users.
     >>> from lp.services.identity.interfaces.emailaddress import (
     ...     IEmailAddressSet,
     ... )
-    >>> from lp.testing import verifyObject
+    >>> from lp.testing import celebrity_logged_in, verifyObject
     >>> from lp.registry.interfaces.person import (
     ...     IHasStanding,
     ...     IPerson,
@@ -22,21 +22,27 @@ not Launchpad users.
     ...     IHasTranslationImports,
     ... )
 
-Any Person object (either a person or a team) implements IPerson...
+Any Person object (either a person or a team) implements IPerson.  We have
+to check this as a registry expert, because evaluating
+``Person.exported_id`` requires high privileges.
 
     >>> personset = getUtility(IPersonSet)
     >>> foobar = personset.getByName("name16")
     >>> foobar.is_team
     False
 
-    >>> verifyObject(IPerson, foobar)
+    >>> with celebrity_logged_in("registry_experts"):
+    ...     verifyObject(IPerson, foobar)
+    ...
     True
 
     >>> ubuntu_team = personset.getByName("ubuntu-team")
     >>> ubuntu_team.is_team
     True
 
-    >>> verifyObject(IPerson, ubuntu_team)
+    >>> with celebrity_logged_in("registry_experts"):
+    ...     verifyObject(IPerson, ubuntu_team)
+    ...
     True
 
 
@@ -416,7 +422,9 @@ property of IPerson or check if the object provides the ITeam interface.
     >>> ITeam.providedBy(landscape_devs)
     True
 
-    >>> verifyObject(ITeam, landscape_devs)
+    >>> with celebrity_logged_in("registry_experts"):
+    ...     verifyObject(ITeam, landscape_devs)
+    ...
     True
 
 Also note that a team will never have a Launchpad account, so its
@@ -503,7 +511,9 @@ entries into teams.
     >>> ITeam.providedBy(not_a_person)
     True
 
-    >>> verifyObject(ITeam, not_a_person)
+    >>> with celebrity_logged_in("registry_experts"):
+    ...     verifyObject(ITeam, not_a_person)
+    ...
     True
 
 The team owner is also added as an administrator of its team.
diff --git a/lib/lp/soyuz/doc/package-diff.rst b/lib/lp/soyuz/doc/package-diff.rst
index ac90cfe..c081d91 100644
--- a/lib/lp/soyuz/doc/package-diff.rst
+++ b/lib/lp/soyuz/doc/package-diff.rst
@@ -36,7 +36,7 @@ Requesting a diff from pmount_0.1-1 to pmount_0.1-2.
 
 Let's inspect the PackageDiff record created.
 
-    >>> from lp.testing import verifyObject
+    >>> from lp.testing import celebrity_logged_in, verifyObject
     >>> from lp.soyuz.interfaces.packagediff import IPackageDiff
 
     >>> verifyObject(IPackageDiff, package_diff)
@@ -45,10 +45,13 @@ Let's inspect the PackageDiff record created.
 Its main attributes are:
 
  * 'requester', which maps to a `IPerson`, the user who made the diff
-   request.
+   request.  (We have to check this as a registry expert, because evaluating
+   ``Person.exported_id`` requires high privileges.)
 
     >>> from lp.registry.interfaces.person import IPerson
-    >>> verifyObject(IPerson, package_diff.requester)
+    >>> with celebrity_logged_in("registry_experts"):
+    ...     verifyObject(IPerson, package_diff.requester)
+    ...
     True
 
     >>> print(package_diff.requester.displayname)