From cd0dd91ab93653631904f2ea0e574ccde6d60339 Mon Sep 17 00:00:00 2001 From: Chia Date: Wed, 5 Aug 2026 14:48:00 +1200 Subject: add passkey, totp. --- internal/controlplane/outbox_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/controlplane/outbox_test.go (limited to 'internal/controlplane/outbox_test.go') diff --git a/internal/controlplane/outbox_test.go b/internal/controlplane/outbox_test.go new file mode 100644 index 0000000..d9a0f2d --- /dev/null +++ b/internal/controlplane/outbox_test.go @@ -0,0 +1,33 @@ +package controlplane + +import ( + "net/url" + "strings" + "testing" + "time" +) + +func TestAccountActionURLKeepsAdminPathAndEncodesToken(t *testing.T) { + link, err := accountActionURL("https://console.example.test/admin/", actionVerifyEmail, "act-aigw-a+b/c") + if err != nil { + t.Fatal(err) + } + parsed, err := url.Parse(link) + if err != nil { + t.Fatal(err) + } + if parsed.Path != "/admin/" || parsed.Query().Get("action") != "verify-email" || parsed.Query().Get("token") != "act-aigw-a+b/c" { + t.Fatalf("unexpected action URL %q", link) + } +} + +func TestActionMailUsesSingularDuration(t *testing.T) { + _, dayBody := actionMail("Test", actionVerifyEmail, "https://example.test", 24*time.Hour) + _, hourBody := actionMail("Test", actionPasswordReset, "https://example.test", time.Hour) + if !strings.Contains(dayBody, "1 day") || strings.Contains(dayBody, "1 days") { + t.Fatalf("unexpected day label %q", dayBody) + } + if !strings.Contains(hourBody, "1 hour") || strings.Contains(hourBody, "1 hours") { + t.Fatalf("unexpected hour label %q", hourBody) + } +} -- cgit v1.2.3