MCPcopy Index your code
hub / github.com/labstack/echo / TestBodyDump_DefaultConfig

Function TestBodyDump_DefaultConfig

middleware/body_dump_test.go:438–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

436}
437
438func TestBodyDump_DefaultConfig(t *testing.T) {
439 e := echo.New()
440 smallData := "test"
441 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(smallData))
442 rec := httptest.NewRecorder()
443 c := e.NewContext(req, rec)
444
445 h := func(c *echo.Context) error {
446 body, _ := io.ReadAll(c.Request().Body)
447 return c.String(http.StatusOK, string(body))
448 }
449
450 requestBodyDumped := ""
451 // Use default config which should have 1MB limits
452 config := BodyDumpConfig{}
453 config.Handler = func(c *echo.Context, reqBody, resBody []byte, err error) {
454 requestBodyDumped = string(reqBody)
455 }
456 mw, err := config.ToMiddleware()
457 assert.NoError(t, err)
458
459 err = mw(h)(c)
460 assert.NoError(t, err)
461 assert.Equal(t, smallData, requestBodyDumped)
462}
463
464func TestBodyDump_LargeRequestDosPrevention(t *testing.T) {
465 e := echo.New()

Callers

nothing calls this directly

Calls 4

RequestMethod · 0.95
StringMethod · 0.95
ToMiddlewareMethod · 0.95
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…