Merge lp:~cjwatson/launchpad/close-account-unactivated into lp:launchpad

Proposed by Colin Watson on 2018-12-04
Status: Merged
Merged at revision: 18834
Proposed branch: lp:~cjwatson/launchpad/close-account-unactivated
Merge into: lp:launchpad
Diff against target: 68 lines (+17/-8)
3 files modified
lib/lp/registry/scripts/tests/test_closeaccount.py (+10/-0)
lib/lp/services/identity/interfaces/account.py (+2/-2)
lib/lp/services/identity/tests/test_account.py (+5/-6)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-unactivated
Reviewer Review Type Date Requested Status
William Grant code 2018-12-04 Approve on 2018-12-05
Review via email: mp+360084@code.launchpad.net

Commit message

Allow closing unactivated accounts.

Description of the change

Unactivated accounts contain personal data, albeit only a small amount, so it's conceivable that we might be required to close them. (Indeed, we've had a GDPR erasure request that will probably turn out to require this.)

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
2--- lib/lp/registry/scripts/tests/test_closeaccount.py 2018-12-04 13:00:56 +0000
3+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2018-12-04 17:56:17 +0000
4@@ -180,6 +180,16 @@
5 self.assertRemoved(account_ids[1], person_ids[1])
6 self.assertNotRemoved(account_ids[2], person_ids[2])
7
8+ def test_unactivated(self):
9+ person = self.factory.makePerson(
10+ account_status=AccountStatus.NOACCOUNT)
11+ person_id = person.id
12+ account_id = person.account.id
13+ script = self.makeScript([person.guessedemails[0].email])
14+ with dbuser('launchpad'):
15+ self.runScript(script)
16+ self.assertRemoved(account_id, person_id)
17+
18 def test_retains_audit_trail(self):
19 person = self.factory.makePerson()
20 person_id = person.id
21
22=== modified file 'lib/lp/services/identity/interfaces/account.py'
23--- lib/lp/services/identity/interfaces/account.py 2018-11-29 18:25:03 +0000
24+++ lib/lp/services/identity/interfaces/account.py 2018-12-04 17:56:17 +0000
25@@ -1,4 +1,4 @@
26-# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
27+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
28 # GNU Affero General Public License version 3 (see the file LICENSE).
29
30 """Account interfaces."""
31@@ -243,7 +243,7 @@
32 transitions = {
33 AccountStatus.PLACEHOLDER: [
34 AccountStatus.NOACCOUNT, AccountStatus.ACTIVE],
35- AccountStatus.NOACCOUNT: [AccountStatus.ACTIVE],
36+ AccountStatus.NOACCOUNT: [AccountStatus.ACTIVE, AccountStatus.CLOSED],
37 AccountStatus.ACTIVE: [
38 AccountStatus.DEACTIVATED, AccountStatus.SUSPENDED,
39 AccountStatus.CLOSED],
40
41=== modified file 'lib/lp/services/identity/tests/test_account.py'
42--- lib/lp/services/identity/tests/test_account.py 2018-11-29 18:25:03 +0000
43+++ lib/lp/services/identity/tests/test_account.py 2018-12-04 17:56:17 +0000
44@@ -1,4 +1,4 @@
45-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
46+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
47 # GNU Affero General Public License version 3 (see the file LICENSE).
48
49 """Tests for `Account` objects."""
50@@ -50,14 +50,13 @@
51 self.assertEqual(status, account.status)
52
53 def test_status_from_noaccount(self):
54- # The status may change from NOACCOUNT to ACTIVE.
55+ # The status may change from NOACCOUNT to ACTIVE or CLOSED.
56 account = self.factory.makeAccount(status=AccountStatus.NOACCOUNT)
57 login_celebrity('admin')
58 self.assertCannotTransition(
59- account,
60- [AccountStatus.DEACTIVATED, AccountStatus.SUSPENDED,
61- AccountStatus.CLOSED])
62- self.assertCanTransition(account, [AccountStatus.ACTIVE])
63+ account, [AccountStatus.DEACTIVATED, AccountStatus.SUSPENDED])
64+ self.assertCanTransition(
65+ account, [AccountStatus.ACTIVE, AccountStatus.CLOSED])
66
67 def test_status_from_active(self):
68 # The status may change from ACTIVE to DEACTIVATED, SUSPENDED, or