Merge lp:~cjwatson/launchpad/close-account-login-token into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 19020
Proposed branch: lp:~cjwatson/launchpad/close-account-login-token
Merge into: lp:launchpad
Diff against target: 49 lines (+24/-0)
2 files modified
lib/lp/registry/scripts/closeaccount.py (+4/-0)
lib/lp/registry/scripts/tests/test_closeaccount.py (+20/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-login-token
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+371081@code.launchpad.net

Commit message

Handle login tokens in close-account.

Description of the change

These otherwise block account closures when people have done something recently that required a login token to be generated, and I can't see a good reason to keep them.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) wrote :

*nods*

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/scripts/closeaccount.py'
2--- lib/lp/registry/scripts/closeaccount.py 2019-07-23 12:36:32 +0000
3+++ lib/lp/registry/scripts/closeaccount.py 2019-08-08 11:38:32 +0000
4@@ -256,6 +256,10 @@
5 # concerned with being removed from our systems.
6 ('EmailAddress', 'person'),
7
8+ # Login tokens are no longer interesting if the user can no longer
9+ # log in.
10+ ('LoginToken', 'requester'),
11+
12 # Trash their codes of conduct and GPG keys
13 ('SignedCodeOfConduct', 'owner'),
14 ('GpgKey', 'owner'),
15
16=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
17--- lib/lp/registry/scripts/tests/test_closeaccount.py 2019-07-23 12:36:32 +0000
18+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2019-08-08 11:38:32 +0000
19@@ -47,6 +47,8 @@
20 DevNullLogger,
21 )
22 from lp.services.scripts.base import LaunchpadScriptFailure
23+from lp.services.verification.interfaces.authtoken import LoginTokenType
24+from lp.services.verification.interfaces.logintoken import ILoginTokenSet
25 from lp.soyuz.enums import (
26 ArchiveSubscriberStatus,
27 PackagePublishingStatus,
28@@ -520,3 +522,21 @@
29 self.assertRemoved(account_id, person_id)
30 self.assertEqual(person, code_imports[0].registrant)
31 self.assertEqual(person, code_imports[1].registrant)
32+
33+ def test_handles_login_token(self):
34+ person = self.factory.makePerson()
35+ email = '%s@another-domain.test' % person.name
36+ login_token_set = getUtility(ILoginTokenSet)
37+ token = login_token_set.new(
38+ person, person.preferredemail.email, email,
39+ LoginTokenType.VALIDATEEMAIL)
40+ plaintext_token = token.token
41+ self.assertEqual(token, login_token_set[plaintext_token])
42+ person_id = person.id
43+ account_id = person.account.id
44+ script = self.makeScript([six.ensure_str(person.name)])
45+ with dbuser('launchpad'):
46+ self.runScript(script)
47+ self.assertRemoved(account_id, person_id)
48+ self.assertRaises(
49+ KeyError, login_token_set.__getitem__, plaintext_token)