// SPDX-License-Identifier: 0BSD package server import ( "io" "net/http" "net/http/httptest" "strconv" "strings" "testing" "time" ) func TestHomeIsDynamicEscapedAndNotCached(t *testing.T) { base := time.Date(2026, time.August, 11, 14, 30, 0, 0, time.UTC) clockCalls := 0 handler := NewWithClock(func() time.Time { result := base.Add(time.Duration(clockCalls) * time.Second) clockCalls++ return result }) first := request(t, handler, http.MethodGet, `/?name=%3Cscript%3Ealert%281%29%3C%2Fscript%3E`) second := request(t, handler, http.MethodGet, "/?name=friend") if first.Code != http.StatusOK || second.Code != http.StatusOK { t.Fatalf("unexpected statuses: first=%d second=%d", first.Code, second.Code) } if first.Header().Get("Cache-Control") != "no-store" { t.Fatalf("Cache-Control = %q", first.Header().Get("Cache-Control")) } if timing := first.Header().Get("Server-Timing"); !strings.HasPrefix(timing, "sando;dur=") || !strings.Contains(timing, "buffered component render") { t.Fatalf("Server-Timing = %q", timing) } if strings.Contains(first.Body.String(), "