← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:gdpr-add-ssh-key-info into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:gdpr-add-ssh-key-info into launchpad:master.

Commit message:
Add ssh keys info to GDPR endpoint

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/406079
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:gdpr-add-ssh-key-info into launchpad:master.
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index f9d911e..c669daf 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -4123,6 +4123,10 @@ class PersonSet:
         questions_url = self._checkForAnswers(account)
         if questions_url:
             return_data["answers"] = questions_url
+        # ssh keys
+        if not account.sshkeys.is_empty():
+            return_data["sshkeys"] = canonical_url(
+                account, view_name="+sshkeys")
         # This is only an 'account' in terms of the end user view,
         # it does not refer to an `IAccount`.
         if len(return_data.keys()) > 1:
diff --git a/lib/lp/registry/tests/test_personset.py b/lib/lp/registry/tests/test_personset.py
index 9c7d308..cee7182 100644
--- a/lib/lp/registry/tests/test_personset.py
+++ b/lib/lp/registry/tests/test_personset.py
@@ -1356,6 +1356,17 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
                 canonical_url(
                     person, rootsite="answers"))}))
 
+    def test_account_data_sshkeys(self):
+        person = self.factory.makePerson(email="test@xxxxxxxxxxx")
+        with admin_logged_in():
+            self.factory.makeSSHKey(person)
+            result = self.person_set.getUserData(u"test@xxxxxxxxxxx")
+        self.assertDictEqual({
+            "status": "account with data",
+            "person": canonical_url(person),
+            "sshkeys": canonical_url(person, view_name="+sshkeys")
+            }, result)
+
     def test_getUserOverview(self):
         ppa = self.factory.makeArchive(owner=self.user)