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

Function TestCSRFSetSameSiteMode

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

Source from the content-addressed store, hash-verified

384}
385
386func TestCSRFSetSameSiteMode(t *testing.T) {
387 e := echo.New()
388 req := httptest.NewRequest(http.MethodGet, "/", nil)
389 rec := httptest.NewRecorder()
390 c := e.NewContext(req, rec)
391
392 csrf := CSRFWithConfig(CSRFConfig{
393 CookieSameSite: http.SameSiteStrictMode,
394 })
395
396 h := csrf(func(c *echo.Context) error {
397 return c.String(http.StatusOK, "test")
398 })
399
400 r := h(c)
401 assert.NoError(t, r)
402 assert.Regexp(t, "SameSite=Strict", rec.Header()["Set-Cookie"])
403}
404
405func TestCSRFWithoutSameSiteMode(t *testing.T) {
406 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…