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

Function TestCSRF

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

Source from the content-addressed store, hash-verified

368}
369
370func TestCSRF(t *testing.T) {
371 e := echo.New()
372 req := httptest.NewRequest(http.MethodGet, "/", nil)
373 rec := httptest.NewRecorder()
374 c := e.NewContext(req, rec)
375 csrf := CSRF()
376 h := csrf(func(c *echo.Context) error {
377 return c.String(http.StatusOK, "test")
378 })
379
380 // Generate CSRF token
381 h(c)
382 assert.Contains(t, rec.Header().Get(echo.HeaderSetCookie), "_csrf")
383
384}
385
386func TestCSRFSetSameSiteMode(t *testing.T) {
387 e := echo.New()

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
CSRFFunction · 0.85
NewContextMethod · 0.80
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…