2026-08-09 22:47:43 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSetPasswordInviteURL(t *testing.T) {
|
|
|
|
|
t.Setenv("WEB_ORIGIN", "https://app.example.com/")
|
|
|
|
|
got := setPasswordInviteURL("tok+1")
|
2026-08-17 21:20:45 +02:00
|
|
|
wantPrefix := "https://app.example.com/accept-invite#token="
|
2026-08-09 22:47:43 +02:00
|
|
|
if !strings.HasPrefix(got, wantPrefix) {
|
|
|
|
|
t.Fatalf("got %q", got)
|
|
|
|
|
}
|
|
|
|
|
if !strings.Contains(got, "tok%2B1") && !strings.Contains(got, "tok+1") {
|
|
|
|
|
t.Fatalf("token not in URL: %q", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSetPasswordByEmailParse(t *testing.T) {
|
|
|
|
|
err := setPasswordByEmail(context.TODO(), nil, "bad")
|
|
|
|
|
if err == nil || !strings.Contains(err.Error(), "email:password") {
|
|
|
|
|
t.Fatalf("expected parse error, got %v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWebOriginDefault(t *testing.T) {
|
|
|
|
|
os.Unsetenv("WEB_ORIGIN")
|
|
|
|
|
if webOrigin() != "http://localhost:5174" {
|
|
|
|
|
t.Fatalf("default origin")
|
|
|
|
|
}
|
2026-08-17 21:20:45 +02:00
|
|
|
}
|