(t *testing.T)
| 299 | } |
| 300 | |
| 301 | func TestDecompress_AtExactLimit(t *testing.T) { |
| 302 | e := echo.New() |
| 303 | exactBody := strings.Repeat("B", 1024) // Exactly 1KB |
| 304 | gz, _ := gzipString(exactBody) |
| 305 | |
| 306 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 307 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 308 | rec := httptest.NewRecorder() |
| 309 | c := e.NewContext(req, rec) |
| 310 | |
| 311 | h, err := DecompressConfig{MaxDecompressedSize: 1024}.ToMiddleware() |
| 312 | assert.NoError(t, err) |
| 313 | |
| 314 | err = h(func(c *echo.Context) error { |
| 315 | b, _ := io.ReadAll(c.Request().Body) |
| 316 | return c.String(http.StatusOK, string(b)) |
| 317 | })(c) |
| 318 | |
| 319 | assert.NoError(t, err) |
| 320 | assert.Equal(t, exactBody, rec.Body.String()) |
| 321 | } |
| 322 | |
| 323 | func TestDecompress_ZipBomb(t *testing.T) { |
| 324 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…