This commit is contained in:
2026-08-13 21:01:49 +02:00
parent 593edf35fe
commit 58578fd010
5 changed files with 69 additions and 9 deletions
+8
View File
@@ -62,6 +62,14 @@ func TestCSRFAllowsSafeMethodsWithoutHeader(t *testing.T) {
if !found {
t.Fatal("expected non-HttpOnly CSRF cookie on first GET")
}
hdr := rec.Header().Get("X-CSRF-Token")
if hdr == "" {
t.Fatal("expected X-CSRF-Token response header on GET (cross-origin SPA seed)")
}
cookie := findCSRFCookie(rec.Result().Cookies())
if cookie == nil || cookie.Value != hdr {
t.Fatalf("X-CSRF-Token header %q must match cookie value", hdr)
}
}
func TestCSRFRejectsPOSTWithoutToken(t *testing.T) {