feat: change email, export my data, delete account (with data anonymization)
This commit is contained in:
1 parent
bb191c389a
commit
10a66cd979
123 files changed
+10789
-76
No files matched your search
@@ -61,6 +61,62 @@ func TestTransactionalEmailTemplates(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("render() produces the verify-new-email email's subject and link", func(t *testing.T) {
|
||||
repo := mailer.NewMailRepository(config.SmtpSettings{})
|
||||
|
||||
subject, body, err := repo.Render("verify-new-email", useCases.MailVerifyNewEmailData{
|
||||
Host: "https://cms.example.com",
|
||||
Username: "marta",
|
||||
VerificationCode: "abc",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
if subject != "Confirm your new RenewCMS email address" {
|
||||
t.Errorf("unexpected subject %q", subject)
|
||||
}
|
||||
if !strings.Contains(body, "https://cms.example.com/account/email/confirm?c=abc") || strings.Contains(body, "{{") {
|
||||
t.Errorf("expected the confirmation link and no unreplaced action, got %q", body)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("render() produces the email-change-notice email's subject, new address and profile link", func(t *testing.T) {
|
||||
repo := mailer.NewMailRepository(config.SmtpSettings{})
|
||||
|
||||
subject, body, err := repo.Render("email-change-notice", useCases.MailEmailChangeNoticeData{
|
||||
Host: "https://cms.example.com",
|
||||
Username: "marta",
|
||||
NewEmail: "new@renew.example",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
if subject != "Your RenewCMS email address change was requested" {
|
||||
t.Errorf("unexpected subject %q", subject)
|
||||
}
|
||||
if !strings.Contains(body, "new@renew.example") || !strings.Contains(body, "https://cms.example.com/profile") || strings.Contains(body, "{{") {
|
||||
t.Errorf("expected the new address, the profile link and no unreplaced action, got %q", body)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("render() produces the account-deleted email without personal data", func(t *testing.T) {
|
||||
repo := mailer.NewMailRepository(config.SmtpSettings{})
|
||||
|
||||
subject, body, err := repo.Render("account-deleted", useCases.MailAccountDeletedData{Host: "https://cms.example.com"})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
if subject != "Your RenewCMS account has been deleted" {
|
||||
t.Errorf("unexpected subject %q", subject)
|
||||
}
|
||||
if !strings.Contains(body, "https://cms.example.com") || strings.Contains(body, "{{") || strings.Contains(body, "@renew") || strings.Contains(body, "<button") || strings.Contains(body, "<a ") {
|
||||
t.Errorf("expected the host only, no button, no address and no unreplaced action, got %q", body)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("render() falls back to the old default subject for an unrecognized template name", func(t *testing.T) {
|
||||
repo := mailer.NewMailRepository(config.SmtpSettings{})
|
||||
|
||||
|
||||
Reference in new issue
Block a user