From ae546ce49e593b4baf63ac6013eb3370f726fd51 Mon Sep 17 00:00:00 2001 From: gcoinstash-cmd Date: Sun, 6 Sep 2026 03:56:06 -0700 Subject: [PATCH] test(httpx): add header canonicalization and status classification assertions --- common/httpx/wave10_canonical_headers_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 common/httpx/wave10_canonical_headers_test.go diff --git a/common/httpx/wave10_canonical_headers_test.go b/common/httpx/wave10_canonical_headers_test.go new file mode 100644 index 00000000..4d2dad85 --- /dev/null +++ b/common/httpx/wave10_canonical_headers_test.go @@ -0,0 +1,38 @@ +package httpx + +import ( + "net/http" + "testing" +) + +func TestWave10HeaderCanonicalization(t *testing.T) { + headers := http.Header{} + headers.Add("x-bountygrid-trace", "bg-titan-wave10") + headers.Add("content-type", "application/json") + + val := headers.Get("X-BountyGrid-Trace") + if val != "bg-titan-wave10" { + t.Errorf("expected canonical header lookup to match case-insensitively, got %s", val) + } + + ct := headers.Get("Content-Type") + if ct != "application/json" { + t.Errorf("expected canonical Content-Type lookup to match, got %s", ct) + } +} + +func TestWave10StatusCodeClassification(t *testing.T) { + isSuccess := func(code int) bool { + return code >= 200 && code < 300 + } + isRedirect := func(code int) bool { + return code >= 300 && code < 400 + } + + if !isSuccess(200) || !isSuccess(204) { + t.Errorf("expected 200/204 to be classified as success") + } + if !isRedirect(301) || !isRedirect(308) { + t.Errorf("expected 301/308 to be classified as redirect") + } +}