| index 1863ef365..d44baa63a 100644 |
| --- a/internal/console/ownership_test.go |
| +++ b/internal/console/ownership_test.go |
| @@ -94,3 +94,35 @@ func TestStoreDeleteAccountRechecksObligations(t *testing.T) { |
| t.Fatalf("obligations = %v %v, want both kept", got, err) |
| } |
| } |
| + |
| +// Deleting an account removes its domain contacts, saved and legacy, in the |
| +// same transaction: they are personal data, and nothing reads them once the |
| +// account is gone. Another account's are kept. |
| +func TestStoreDeleteAccountRemovesDomainContacts(t *testing.T) { |
| + ctx := context.Background() |
| + s := openTestStore(t) |
| + now := time.Now() |
| + id, other := testAccountID(), testAccountID() |
| + for i, acct := range []int64{id, other} { |
| + if err := s.CreateAccount(acct, "test-del-contacts-"+string(rune('a'+i)), "Testco", "paul@keymail.dev", now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := s.AddSavedContact(ctx, acct, savedTestContact("jane"), now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := s.SetDomainContact(acct, savedTestContact("legacy"), "contact-1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := s.DeleteAccount(id, now); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, table := range []string{"domain_saved_contacts", "domain_contacts"} { |
| + if n := countWhere(t, s, table, "account_id = ?", id); n != 0 { |
| + t.Errorf("%s: %d row(s) of the deleted account kept", table, n) |
| + } |
| + if n := countWhere(t, s, table, "account_id = ?", other); n != 1 { |
| + t.Errorf("%s: %d row(s) of the other account, want 1", table, n) |
| + } |
| + } |
| +} |