summaryrefslogtreecommitdiff
path: root/internal/controlplane/outbox_test.go
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-05 14:48:00 +1200
committerChia <Chia@93.nz>2026-08-05 14:48:00 +1200
commitcd0dd91ab93653631904f2ea0e574ccde6d60339 (patch)
treec65417b880a3f4a35c504c44edae821bc2122f70 /internal/controlplane/outbox_test.go
parent86b1f42e3c5601ff10621a9779cf0076590797a1 (diff)
add passkey, totp.
Diffstat (limited to 'internal/controlplane/outbox_test.go')
-rw-r--r--internal/controlplane/outbox_test.go33
1 files changed, 33 insertions, 0 deletions
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)
+ }
+}