diff --git a/compression_test.go b/compression_test.go index b7003d3..85509aa 100644 --- a/compression_test.go +++ b/compression_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/valyala/fasthttp" ) func TestValidateCompressedBody(t *testing.T) { @@ -26,6 +27,10 @@ func TestValidateCompressedBody(t *testing.T) { } valid := loadTestdata(t, "valid.publiccode.yml") compressed := compress(valid) + layered := valid + for range 6 { + layered = compress(layered) + } for _, method := range []string{http.MethodPost, "QUERY"} { for _, tc := range []struct { name, encoding, body string @@ -35,9 +40,13 @@ func TestValidateCompressedBody(t *testing.T) { {"truncated", "gzip", compressed[:len(compressed)-5], 400}, {"oversized", "gzip", compress(strings.Repeat("a", 6_000_000)), 413}, {"unsupported", "unknown", valid, 415}, + {"too many codings", "gzip, gzip, gzip, gzip, gzip, gzip", layered, 415}, {"unimplemented", "compress", valid, 501}, {"valid", "gzip", compressed, 200}, {"stacked", "gzip, gzip", compress(compressed), 200}, + {"x-gzip alias", "x-gzip", compressed, 200}, + {"brotli alias", "brotli", string(fasthttp.AppendBrotliBytes(nil, []byte(valid))), 200}, + {"identity", "gzip, identity", compressed, 200}, } { contentType := "application/problem+json" if tc.status == 200 {