mirror of
https://github.com/umputun/reproxy.git
synced 2024-08-16 12:10:31 +03:00
update linter and address all lint warns
This commit is contained in:
parent
8c59be3612
commit
075f66825a
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
- name: install golangci-lint and goveralls
|
||||
run: |
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.40.0
|
||||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $GITHUB_WORKSPACE v1.43.0
|
||||
GO111MODULE=off go get -u github.com/mattn/goveralls
|
||||
|
||||
- name: run linters
|
||||
|
@ -74,4 +74,4 @@ issues:
|
||||
exclude-use-default: false
|
||||
|
||||
service:
|
||||
golangci-lint-version: 1.39.x
|
||||
golangci-lint-version: 1.43.x
|
||||
|
@ -57,7 +57,7 @@ func (cl *consulClient) Get() ([]consulService, error) {
|
||||
}
|
||||
|
||||
func (cl *consulClient) getServiceNames() ([]string, error) {
|
||||
req, err := http.NewRequest(http.MethodGet, cl.address+"/v1/catalog/services", nil)
|
||||
req, err := http.NewRequest(http.MethodGet, cl.address+"/v1/catalog/services", http.NoBody)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error create a http request, %w", err)
|
||||
}
|
||||
@ -98,7 +98,7 @@ func (cl *consulClient) filterServices(src map[string][]string) []string {
|
||||
}
|
||||
|
||||
func (cl *consulClient) getServices(serviceName string) ([]consulService, error) {
|
||||
req, err := http.NewRequest(http.MethodGet, cl.address+"/v1/catalog/service/"+serviceName, nil)
|
||||
req, err := http.NewRequest(http.MethodGet, cl.address+"/v1/catalog/service/"+serviceName, http.NoBody)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error create a http request, %w", err)
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package provider
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -344,7 +344,7 @@ func TestDockerClient(t *testing.T) {
|
||||
require.Equal(t, `/v1.22/containers/json`, r.URL.Path)
|
||||
|
||||
// obtained using curl --unix-socket /var/run/docker.sock http://localhost/v1.41/containers/json
|
||||
resp, err := ioutil.ReadFile("testdata/containers.json")
|
||||
resp, err := os.ReadFile("testdata/containers.json")
|
||||
require.NoError(t, err)
|
||||
w.Write(resp)
|
||||
}))
|
||||
|
@ -31,18 +31,18 @@ func TestFile_Events(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
|
||||
// all those event will be ignored, submitted too fast
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
}()
|
||||
|
||||
ch := f.Events(ctx)
|
||||
@ -77,7 +77,7 @@ func TestFile_Events_BusyListener(t *testing.T) {
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte("something"), 0600))
|
||||
assert.NoError(t, os.WriteFile(tmp.Name(), []byte("something"), 0o600))
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
@ -284,7 +283,7 @@ func run() error {
|
||||
func makeBasicAuth(htpasswdFile string) ([]string, error) {
|
||||
var basicAuthAllowed []string
|
||||
if htpasswdFile != "" {
|
||||
data, err := ioutil.ReadFile(htpasswdFile)
|
||||
data, err := os.ReadFile(htpasswdFile) //nolint:gosec //read file with opts passed path
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read htpasswd file %s: %w", htpasswdFile, err)
|
||||
}
|
||||
@ -424,7 +423,7 @@ func makeErrorReporter() (proxy.Reporter, error) {
|
||||
Nice: opts.ErrorReport.Enabled,
|
||||
}
|
||||
if opts.ErrorReport.Template != "" {
|
||||
data, err := ioutil.ReadFile(opts.ErrorReport.Template)
|
||||
data, err := os.ReadFile(opts.ErrorReport.Template)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load error html template from %s, %w", opts.ErrorReport.Template, err)
|
||||
}
|
||||
@ -435,7 +434,7 @@ func makeErrorReporter() (proxy.Reporter, error) {
|
||||
|
||||
func makeAccessLogWriter() (accessLog io.WriteCloser, err error) {
|
||||
if !opts.Logger.Enabled {
|
||||
return nopWriteCloser{ioutil.Discard}, nil
|
||||
return nopWriteCloser{io.Discard}, nil
|
||||
}
|
||||
|
||||
maxSize, perr := sizeParse(opts.Logger.MaxSize)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -59,7 +59,7 @@ func Test_Main(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "pong", string(body))
|
||||
}
|
||||
@ -69,7 +69,7 @@ func Test_Main(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(body), `"Host": "httpbin.org"`)
|
||||
}
|
||||
@ -79,7 +79,7 @@ func Test_Main(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(body), `echo echo 123`)
|
||||
}
|
||||
@ -89,7 +89,7 @@ func Test_Main(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, http.StatusBadGateway, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "oh my! 502 - Bad Gateway", string(body))
|
||||
}
|
||||
@ -139,7 +139,7 @@ func Test_MainWithSSL(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "pong", string(body))
|
||||
}
|
||||
@ -149,7 +149,7 @@ func Test_MainWithSSL(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(body), `"Host": "httpbin.org"`)
|
||||
}
|
||||
@ -206,7 +206,7 @@ func Test_MainWithPlugin(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
t.Logf("body: %s", string(body))
|
||||
assert.Contains(t, string(body), `"Host": "httpbin.org"`)
|
||||
@ -387,6 +387,7 @@ func Test_makeBasicAuth(t *testing.T) {
|
||||
defer fh.Close()
|
||||
|
||||
n, err := fh.WriteString(pf)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(pf), n)
|
||||
|
||||
res, err := makeBasicAuth(fh.Name())
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@ -62,7 +62,7 @@ func TestServer_controllers(t *testing.T) {
|
||||
|
||||
client := http.Client{}
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/ping", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/ping", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -73,7 +73,7 @@ func TestServer_controllers(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/routes", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/routes", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -94,13 +94,13 @@ func TestServer_controllers(t *testing.T) {
|
||||
assert.Contains(t, fmt.Sprintf("%v", data["srv1"][0]), `ping:http://example.com/ping`, data["srv1"][0])
|
||||
}
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/metrics", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/metrics", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
t.Logf("%s", string(body))
|
||||
|
||||
|
@ -262,7 +262,7 @@ func TestConductor_Middleware(t *testing.T) {
|
||||
assert.Equal(t, 3, len(c.plugins), "3 plugins registered")
|
||||
c.plugins[2].Alive = false // set 3rd to dead
|
||||
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", nil)
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
m := discovery.MatchedRoute{
|
||||
@ -343,7 +343,7 @@ func TestConductor_MiddlewarePluginBadStatus(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
assert.Equal(t, 1, len(c.plugins), "one plugin registered")
|
||||
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", nil)
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
m := discovery.MatchedRoute{
|
||||
@ -410,7 +410,7 @@ func TestConductor_MiddlewarePluginFailed(t *testing.T) {
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
assert.Equal(t, 1, len(c.plugins), "one plugin registered")
|
||||
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", nil)
|
||||
rr, err := http.NewRequest("GET", "http://127.0.0.1", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
w := httptest.NewRecorder()
|
||||
h := c.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -24,7 +24,7 @@ func Test_headersHandler(t *testing.T) {
|
||||
assert.Equal(t, "", r.Header.Get("r2"), "r2 header dropped")
|
||||
assert.Equal(t, "rv3", r.Header.Get("r3"), "r3 kept")
|
||||
}))
|
||||
req, err := http.NewRequest("GET", "http://example.com", nil)
|
||||
req, err := http.NewRequest("GET", "http://example.com", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
req.Header.Set("r1", "rv1")
|
||||
req.Header.Set("r2", "rv2")
|
||||
@ -109,7 +109,7 @@ func Test_limiterSystemHandler(t *testing.T) {
|
||||
for i := 0; i < 100; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
req, err := http.NewRequest("GET", ts.URL, nil)
|
||||
req, err := http.NewRequest("GET", ts.URL, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
@ -134,7 +134,7 @@ func Test_limiterClientHandlerNoMatches(t *testing.T) {
|
||||
for i := 0; i < 100; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
req, err := http.NewRequest("GET", ts.URL, nil)
|
||||
req, err := http.NewRequest("GET", ts.URL, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
@ -215,7 +215,7 @@ func TestHttp_basicAuthHandler(t *testing.T) {
|
||||
|
||||
for i, tt := range tbl {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", ts.URL, nil)
|
||||
req, err := http.NewRequest("GET", ts.URL, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
tt.reqFn(req)
|
||||
resp, err := client.Do(req)
|
||||
@ -235,7 +235,7 @@ func TestHttp_basicAuthHandler(t *testing.T) {
|
||||
ts2 := httptest.NewServer(handler)
|
||||
for i, tt := range tbl {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", ts2.URL, nil)
|
||||
req, err := http.NewRequest("GET", ts2.URL, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
tt.reqFn(req)
|
||||
resp, err := client.Do(req)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -104,7 +104,7 @@ func TestHttp_healthHandler(t *testing.T) {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
client := http.Client{}
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/health", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/health", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -148,13 +148,13 @@ func TestHttp_pingHandler(t *testing.T) {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
client := http.Client{}
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/ping", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/ping", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "pong", string(b))
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -61,7 +60,7 @@ func TestHttp_Do(t *testing.T) {
|
||||
client := http.Client{}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -97,7 +96,7 @@ func TestHttp_Do(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, http.StatusBadGateway, resp.StatusCode)
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(b), "Sorry for the inconvenience")
|
||||
assert.Equal(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||
@ -141,7 +140,7 @@ func TestHttp_DoWithAssets(t *testing.T) {
|
||||
client := http.Client{}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -228,7 +227,7 @@ func TestHttp_DoWithSpaAssets(t *testing.T) {
|
||||
client := http.Client{}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -338,7 +337,7 @@ func TestHttp_DoWithAssetRules(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -411,7 +410,7 @@ func TestHttp_DoWithRedirects(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://localhost:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://localhost:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -422,7 +421,7 @@ func TestHttp_DoWithRedirects(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/api/something", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -553,7 +552,7 @@ func TestHttp_health(t *testing.T) {
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/health", nil)
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/health", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
@ -684,7 +683,7 @@ func TestHttp_isAssetRequest(t *testing.T) {
|
||||
for i, tt := range tbl {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
h := Http{AssetsLocation: tt.assetsLocation, AssetsWebRoot: tt.assetsWebRoot}
|
||||
r, err := http.NewRequest("GET", tt.req, nil)
|
||||
r, err := http.NewRequest("GET", tt.req, http.NoBody)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.res, h.isAssetRequest(r))
|
||||
})
|
||||
@ -770,7 +769,7 @@ func TestHttp_matchHandler(t *testing.T) {
|
||||
assert.Equal(t, tt.res, v.(*url.URL).String())
|
||||
}))
|
||||
|
||||
req, err := http.NewRequest("GET", "http://example.com", nil)
|
||||
req, err := http.NewRequest("GET", "http://example.com", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
wr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(wr, req)
|
||||
|
@ -3,7 +3,7 @@ package proxy
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@ -70,7 +70,7 @@ func TestSSL_ACME_HTTPChallengeRouter(t *testing.T) {
|
||||
assert.Equal(t, "https://localhost:443/blah?param=1", resp.Header.Get("Location"))
|
||||
|
||||
// check acme http challenge
|
||||
req, err := http.NewRequest("GET", lh+"/.well-known/acme-challenge/token123", nil)
|
||||
req, err := http.NewRequest("GET", lh+"/.well-known/acme-challenge/token123", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
req.Host = "localhost" // for passing hostPolicy check
|
||||
resp, err = client.Do(req)
|
||||
@ -85,7 +85,7 @@ func TestSSL_ACME_HTTPChallengeRouter(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
assert.Equal(t, 200, resp.StatusCode)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "token", string(body))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user