MCPcopy
hub / github.com/labstack/echo / TestCSRFWithSameSiteDefaultMode

Function TestCSRFWithSameSiteDefaultMode

middleware/csrf_test.go:422–439  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

420}
421
422func TestCSRFWithSameSiteDefaultMode(t *testing.T) {
423 e := echo.New()
424 req := httptest.NewRequest(http.MethodGet, "/", nil)
425 rec := httptest.NewRecorder()
426 c := e.NewContext(req, rec)
427
428 csrf := CSRFWithConfig(CSRFConfig{
429 CookieSameSite: http.SameSiteDefaultMode,
430 })
431
432 h := csrf(func(c *echo.Context) error {
433 return c.String(http.StatusOK, "test")
434 })
435
436 r := h(c)
437 assert.NoError(t, r)
438 assert.NotRegexp(t, "SameSite=", rec.Header()["Set-Cookie"])
439}
440
441func TestCSRFWithSameSiteModeNone(t *testing.T) {
442 e := echo.New()

Callers

nothing calls this directly

Calls 4

StringMethod · 0.95
CSRFWithConfigFunction · 0.85
NewContextMethod · 0.80
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…