mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
move linter exceptions
This commit is contained in:
@@ -558,8 +558,8 @@ func TestRewriteLocationFunc(t *testing.T) {
|
|||||||
}
|
}
|
||||||
run := func(p *ReverseProxy, matchedPath string, inReq *http.Request, location string) (*http.Response, error) {
|
run := func(p *ReverseProxy, matchedPath string, inReq *http.Request, location string) (*http.Response, error) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
modifyResp := p.rewriteLocationFunc(target, matchedPath, inReq)
|
modifyResp := p.rewriteLocationFunc(target, matchedPath, inReq) //nolint:bodyclose
|
||||||
resp := &http.Response{Header: http.Header{}} //nolint:bodyclose
|
resp := &http.Response{Header: http.Header{}}
|
||||||
if location != "" {
|
if location != "" {
|
||||||
resp.Header.Set("Location", location)
|
resp.Header.Set("Location", location)
|
||||||
}
|
}
|
||||||
@@ -725,8 +725,8 @@ func TestRewriteLocationFunc(t *testing.T) {
|
|||||||
// Per RFC 3986, these are the same authority.
|
// Per RFC 3986, these are the same authority.
|
||||||
target443, _ := url.Parse("https://heise.de:443")
|
target443, _ := url.Parse("https://heise.de:443")
|
||||||
p := newProxy("https")
|
p := newProxy("https")
|
||||||
modifyResp := p.rewriteLocationFunc(target443, "", newReq("https://public.example.com/"))
|
modifyResp := p.rewriteLocationFunc(target443, "", newReq("https://public.example.com/")) //nolint:bodyclose
|
||||||
resp := &http.Response{Header: http.Header{}} //nolint:bodyclose
|
resp := &http.Response{Header: http.Header{}}
|
||||||
resp.Header.Set("Location", "https://heise.de/path")
|
resp.Header.Set("Location", "https://heise.de/path")
|
||||||
|
|
||||||
err := modifyResp(resp)
|
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) {
|
t.Run("rewrites when target has :80 but redirect omits it for http", func(t *testing.T) {
|
||||||
target80, _ := url.Parse("http://backend.local:80")
|
target80, _ := url.Parse("http://backend.local:80")
|
||||||
p := newProxy("http")
|
p := newProxy("http")
|
||||||
modifyResp := p.rewriteLocationFunc(target80, "", newReq("http://public.example.com/"))
|
modifyResp := p.rewriteLocationFunc(target80, "", newReq("http://public.example.com/")) //nolint:bodyclose
|
||||||
resp := &http.Response{Header: http.Header{}} //nolint:bodyclose
|
resp := &http.Response{Header: http.Header{}}
|
||||||
resp.Header.Set("Location", "http://backend.local/path")
|
resp.Header.Set("Location", "http://backend.local/path")
|
||||||
|
|
||||||
err := modifyResp(resp)
|
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) {
|
t.Run("rewrites when redirect has :443 but target omits it", func(t *testing.T) {
|
||||||
targetNoPort, _ := url.Parse("https://heise.de")
|
targetNoPort, _ := url.Parse("https://heise.de")
|
||||||
p := newProxy("https")
|
p := newProxy("https")
|
||||||
modifyResp := p.rewriteLocationFunc(targetNoPort, "", newReq("https://public.example.com/"))
|
modifyResp := p.rewriteLocationFunc(targetNoPort, "", newReq("https://public.example.com/")) //nolint:bodyclose
|
||||||
resp := &http.Response{Header: http.Header{}} //nolint:bodyclose
|
resp := &http.Response{Header: http.Header{}}
|
||||||
resp.Header.Set("Location", "https://heise.de:443/path")
|
resp.Header.Set("Location", "https://heise.de:443/path")
|
||||||
|
|
||||||
err := modifyResp(resp)
|
err := modifyResp(resp)
|
||||||
@@ -767,8 +767,8 @@ func TestRewriteLocationFunc(t *testing.T) {
|
|||||||
t.Run("does not conflate non-default ports", func(t *testing.T) {
|
t.Run("does not conflate non-default ports", func(t *testing.T) {
|
||||||
target8443, _ := url.Parse("https://backend.internal:8443")
|
target8443, _ := url.Parse("https://backend.internal:8443")
|
||||||
p := newProxy("https")
|
p := newProxy("https")
|
||||||
modifyResp := p.rewriteLocationFunc(target8443, "", newReq("https://public.example.com/"))
|
modifyResp := p.rewriteLocationFunc(target8443, "", newReq("https://public.example.com/")) //nolint:bodyclose
|
||||||
resp := &http.Response{Header: http.Header{}} //nolint:bodyclose
|
resp := &http.Response{Header: http.Header{}}
|
||||||
resp.Header.Set("Location", "https://backend.internal/path")
|
resp.Header.Set("Location", "https://backend.internal/path")
|
||||||
|
|
||||||
err := modifyResp(resp)
|
err := modifyResp(resp)
|
||||||
@@ -781,8 +781,8 @@ func TestRewriteLocationFunc(t *testing.T) {
|
|||||||
// --- Edge cases: encoded paths ---
|
// --- Edge cases: encoded paths ---
|
||||||
|
|
||||||
t.Run("preserves percent-encoded path segments", func(t *testing.T) {
|
t.Run("preserves percent-encoded path segments", func(t *testing.T) {
|
||||||
resp, err := run(newProxy("https"), "", newReq("https://public.example.com/"),
|
resp, err := run(newProxy("https"), "", newReq("https://public.example.com/"), //nolint:bodyclose
|
||||||
"http://backend.internal:8080/path%20with%20spaces/file%2Fname") //nolint:bodyclose
|
"http://backend.internal:8080/path%20with%20spaces/file%2Fname")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
loc := resp.Header.Get("Location")
|
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) {
|
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/"),
|
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") //nolint:bodyclose
|
"http://backend.internal:8080/redirect?url=http%3A%2F%2Fexample.com")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "https://public.example.com/v1/redirect?url=http%3A%2F%2Fexample.com", resp.Header.Get("Location"))
|
assert.Equal(t, "https://public.example.com/v1/redirect?url=http%3A%2F%2Fexample.com", resp.Header.Get("Location"))
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ func TestNetBird_RoundTrip_RequiresAccountIDInContext(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// RoundTrip should fail because no account ID in context.
|
// RoundTrip should fail because no account ID in context.
|
||||||
_, err = nb.RoundTrip(req)
|
_, err = nb.RoundTrip(req) //nolint:bodyclose
|
||||||
require.ErrorIs(t, err, ErrNoAccountID)
|
require.ErrorIs(t, err, ErrNoAccountID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ func TestNetBird_RoundTrip_RequiresExistingClient(t *testing.T) {
|
|||||||
req = req.WithContext(WithAccountID(req.Context(), accountID))
|
req = req.WithContext(WithAccountID(req.Context(), accountID))
|
||||||
|
|
||||||
// RoundTrip should fail because no client for this account.
|
// 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.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "no peer connection found for account")
|
assert.Contains(t, err.Error(), "no peer connection found for account")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user