From 5f43449f6762aea04611425a4fe0bd4b971eda6e Mon Sep 17 00:00:00 2001 From: pascal Date: Thu, 12 Feb 2026 10:45:21 +0100 Subject: [PATCH] move linter exceptions --- proxy/internal/proxy/reverseproxy_test.go | 28 +++++++++++------------ proxy/internal/roundtrip/netbird_test.go | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/proxy/internal/proxy/reverseproxy_test.go b/proxy/internal/proxy/reverseproxy_test.go index 3cb7101c4..f7f231db4 100644 --- a/proxy/internal/proxy/reverseproxy_test.go +++ b/proxy/internal/proxy/reverseproxy_test.go @@ -558,8 +558,8 @@ func TestRewriteLocationFunc(t *testing.T) { } run := func(p *ReverseProxy, matchedPath string, inReq *http.Request, location string) (*http.Response, error) { t.Helper() - modifyResp := p.rewriteLocationFunc(target, matchedPath, inReq) - resp := &http.Response{Header: http.Header{}} //nolint:bodyclose + modifyResp := p.rewriteLocationFunc(target, matchedPath, inReq) //nolint:bodyclose + resp := &http.Response{Header: http.Header{}} if location != "" { resp.Header.Set("Location", location) } @@ -725,8 +725,8 @@ func TestRewriteLocationFunc(t *testing.T) { // Per RFC 3986, these are the same authority. target443, _ := url.Parse("https://heise.de:443") p := newProxy("https") - modifyResp := p.rewriteLocationFunc(target443, "", newReq("https://public.example.com/")) - resp := &http.Response{Header: http.Header{}} //nolint:bodyclose + modifyResp := p.rewriteLocationFunc(target443, "", newReq("https://public.example.com/")) //nolint:bodyclose + resp := &http.Response{Header: http.Header{}} resp.Header.Set("Location", "https://heise.de/path") err := modifyResp(resp) @@ -739,8 +739,8 @@ func TestRewriteLocationFunc(t *testing.T) { t.Run("rewrites when target has :80 but redirect omits it for http", func(t *testing.T) { target80, _ := url.Parse("http://backend.local:80") p := newProxy("http") - modifyResp := p.rewriteLocationFunc(target80, "", newReq("http://public.example.com/")) - resp := &http.Response{Header: http.Header{}} //nolint:bodyclose + modifyResp := p.rewriteLocationFunc(target80, "", newReq("http://public.example.com/")) //nolint:bodyclose + resp := &http.Response{Header: http.Header{}} resp.Header.Set("Location", "http://backend.local/path") err := modifyResp(resp) @@ -753,8 +753,8 @@ func TestRewriteLocationFunc(t *testing.T) { t.Run("rewrites when redirect has :443 but target omits it", func(t *testing.T) { targetNoPort, _ := url.Parse("https://heise.de") p := newProxy("https") - modifyResp := p.rewriteLocationFunc(targetNoPort, "", newReq("https://public.example.com/")) - resp := &http.Response{Header: http.Header{}} //nolint:bodyclose + modifyResp := p.rewriteLocationFunc(targetNoPort, "", newReq("https://public.example.com/")) //nolint:bodyclose + resp := &http.Response{Header: http.Header{}} resp.Header.Set("Location", "https://heise.de:443/path") err := modifyResp(resp) @@ -767,8 +767,8 @@ func TestRewriteLocationFunc(t *testing.T) { t.Run("does not conflate non-default ports", func(t *testing.T) { target8443, _ := url.Parse("https://backend.internal:8443") p := newProxy("https") - modifyResp := p.rewriteLocationFunc(target8443, "", newReq("https://public.example.com/")) - resp := &http.Response{Header: http.Header{}} //nolint:bodyclose + modifyResp := p.rewriteLocationFunc(target8443, "", newReq("https://public.example.com/")) //nolint:bodyclose + resp := &http.Response{Header: http.Header{}} resp.Header.Set("Location", "https://backend.internal/path") err := modifyResp(resp) @@ -781,8 +781,8 @@ func TestRewriteLocationFunc(t *testing.T) { // --- Edge cases: encoded paths --- t.Run("preserves percent-encoded path segments", func(t *testing.T) { - resp, err := run(newProxy("https"), "", newReq("https://public.example.com/"), - "http://backend.internal:8080/path%20with%20spaces/file%2Fname") //nolint:bodyclose + resp, err := run(newProxy("https"), "", newReq("https://public.example.com/"), //nolint:bodyclose + "http://backend.internal:8080/path%20with%20spaces/file%2Fname") require.NoError(t, err) loc := resp.Header.Get("Location") @@ -793,8 +793,8 @@ func TestRewriteLocationFunc(t *testing.T) { }) t.Run("preserves encoded query parameters with path prefix", func(t *testing.T) { - resp, err := run(newProxy("https"), "/v1", newReq("https://public.example.com/v1/"), - "http://backend.internal:8080/redirect?url=http%3A%2F%2Fexample.com") //nolint:bodyclose + resp, err := run(newProxy("https"), "/v1", newReq("https://public.example.com/v1/"), //nolint:bodyclose + "http://backend.internal:8080/redirect?url=http%3A%2F%2Fexample.com") require.NoError(t, err) assert.Equal(t, "https://public.example.com/v1/redirect?url=http%3A%2F%2Fexample.com", resp.Header.Get("Location")) diff --git a/proxy/internal/roundtrip/netbird_test.go b/proxy/internal/roundtrip/netbird_test.go index 193f36a9d..fd4c68fe8 100644 --- a/proxy/internal/roundtrip/netbird_test.go +++ b/proxy/internal/roundtrip/netbird_test.go @@ -235,7 +235,7 @@ func TestNetBird_RoundTrip_RequiresAccountIDInContext(t *testing.T) { require.NoError(t, err) // RoundTrip should fail because no account ID in context. - _, err = nb.RoundTrip(req) + _, err = nb.RoundTrip(req) //nolint:bodyclose require.ErrorIs(t, err, ErrNoAccountID) } @@ -249,7 +249,7 @@ func TestNetBird_RoundTrip_RequiresExistingClient(t *testing.T) { req = req.WithContext(WithAccountID(req.Context(), accountID)) // RoundTrip should fail because no client for this account. - _, err = nb.RoundTrip(req) + _, err = nb.RoundTrip(req) //nolint:bodyclose // Error case, no response body assert.Error(t, err) assert.Contains(t, err.Error(), "no peer connection found for account") }