From 26aa501b1256a32b0f1e876bce674799743834f5 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Wed, 2 Dec 2026 09:23:04 +0000 Subject: [PATCH] test: cover content coding aliases and the coding cap No test sent x-gzip, brotli or identity, so dropping their handling left the suite green while those requests started failing with 415. Six gzip layers make the cap case fail when the cap goes away, which six identity codings do not. --- compression_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 {