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

Function TestCSRFWithSameSiteModeNone

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

Source from the content-addressed store, hash-verified

439}
440
441func TestCSRFWithSameSiteModeNone(t *testing.T) {
442 e := echo.New()
443 req := httptest.NewRequest(http.MethodGet, "/", nil)
444 rec := httptest.NewRecorder()
445 c := e.NewContext(req, rec)
446
447 csrf, err := CSRFConfig{
448 CookieSameSite: http.SameSiteNoneMode,
449 }.ToMiddleware()
450 assert.NoError(t, err)
451
452 h := csrf(func(c *echo.Context) error {
453 return c.String(http.StatusOK, "test")
454 })
455
456 r := h(c)
457 assert.NoError(t, r)
458 assert.Regexp(t, "SameSite=None", rec.Header()["Set-Cookie"])
459 assert.Regexp(t, "Secure", rec.Header()["Set-Cookie"])
460}
461
462func TestCSRFConfig_skipper(t *testing.T) {
463 var testCases = []struct {

Callers

nothing calls this directly

Calls 4

StringMethod · 0.95
NewContextMethod · 0.80
ToMiddlewareMethod · 0.65
HeaderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…