package main import ( "context" "os" "strings" "testing" ) func TestSetPasswordInviteURL(t *testing.T) { t.Setenv("WEB_ORIGIN", "https://app.example.com/") got := setPasswordInviteURL("tok+1") wantPrefix := "https://app.example.com/accept-invite#token=" 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") } }