(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func TestDecompress_WithinLimit(t *testing.T) { |
| 254 | e := echo.New() |
| 255 | body := strings.Repeat("test data ", 100) // Small payload ~1KB |
| 256 | gz, _ := gzipString(body) |
| 257 | |
| 258 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(gz)) |
| 259 | req.Header.Set(echo.HeaderContentEncoding, GZIPEncoding) |
| 260 | rec := httptest.NewRecorder() |
| 261 | c := e.NewContext(req, rec) |
| 262 | |
| 263 | h, err := DecompressConfig{MaxDecompressedSize: 100 * MB}.ToMiddleware() |
| 264 | assert.NoError(t, err) |
| 265 | |
| 266 | err = h(func(c *echo.Context) error { |
| 267 | b, _ := io.ReadAll(c.Request().Body) |
| 268 | return c.String(http.StatusOK, string(b)) |
| 269 | })(c) |
| 270 | |
| 271 | assert.NoError(t, err) |
| 272 | assert.Equal(t, body, rec.Body.String()) |
| 273 | } |
| 274 | |
| 275 | func TestDecompress_ExceedsLimit(t *testing.T) { |
| 276 | e := echo.New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…