Skip to content

Commit

Permalink
Merge pull request #369 from vania-pooh/master
Browse files Browse the repository at this point in the history
Bump Golang to 1.19.3
  • Loading branch information
vania-pooh authored Nov 24, 2022
2 parents e83d8e5 + 980de9f commit c041f40
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: ~1.19.3

- uses: actions/cache@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: ~1.19.3

- uses: actions/cache@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: ~1.19.3

- uses: actions/cache@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

export GO111MODULE="on"
go test -tags 'watch' -v -race -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/aerokube/ggr

go install golang.org/x/vuln/cmd/govulncheck@latest
"$(go env GOPATH)"/bin/govulncheck -tags production ./...
7 changes: 3 additions & 4 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -167,7 +166,7 @@ func TestFindWithPlatformPrefix(t *testing.T) {
}

func TestReadNotExistingConfig(t *testing.T) {
tmp, err := ioutil.TempFile("", "config")
tmp, err := os.CreateTemp("", "config")
if err != nil {
t.Fatal(err)
}
Expand All @@ -183,7 +182,7 @@ func TestReadNotExistingConfig(t *testing.T) {
}

func TestParseInvalidConfig(t *testing.T) {
tmp, err := ioutil.TempFile("", "config")
tmp, err := os.CreateTemp("", "config")
defer os.Remove(tmp.Name())
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -212,7 +211,7 @@ func TestParseConfigWithoutNamespace(t *testing.T) {
}

func testParseConfig(t *testing.T, config string) {
tmp, err := ioutil.TempFile("", "config")
tmp, err := os.CreateTemp("", "config")
defer os.Remove(tmp.Name())
if err != nil {
t.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/aerokube/ggr

go 1.18
go 1.19

require (
github.com/aandryashin/matchers v0.0.0-20160729131923-5eb67beb188b
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e
github.com/aandryashin/reloader v0.0.0-20161127125235-da4f1b43ce40
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/net v0.2.0
)

require (
github.com/fsnotify/fsnotify v1.5.4 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/sys v0.2.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/aandryashin/matchers v0.0.0-20160729131923-5eb67beb188b h1:2hJ49uel4j48uteFY3ybBiSB35Ml86IZkSXAb+rj0lQ=
github.com/aandryashin/matchers v0.0.0-20160729131923-5eb67beb188b/go.mod h1:cbmYNkm9xeQlNoWEPtOUcvNok2gSD7ErMnYkRW+eHi8=
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e h1:ogUKYFNcdYUIBSLibE4+EjbTJazoHr5JsWWx21Lpn8c=
github.com/aandryashin/matchers v0.0.0-20161126170413-435295ea180e/go.mod h1:cbmYNkm9xeQlNoWEPtOUcvNok2gSD7ErMnYkRW+eHi8=
github.com/aandryashin/reloader v0.0.0-20161127125235-da4f1b43ce40 h1:zSKVi4h3Kv0HvNGjWPOsOEJIxtvd3PRMlVA/fcCB45g=
github.com/aandryashin/reloader v0.0.0-20161127125235-da4f1b43ce40/go.mod h1:gvg2/m9OQ4ZwK4Qk/mnfgokCb4qDN4BGyle+QGw4VOc=
github.com/abbot/go-http-auth v0.4.1-0.20220112235402-e1cee1c72f2f h1:R2ZVGCZzU95oXFJxncosHS9LsX8N4/MYUdGGWOb2cFk=
Expand All @@ -10,11 +12,15 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5U
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ func init() {
go func() {
for {
<-sig
loadQuotaFiles(quotaDir)
err := loadQuotaFiles(quotaDir)
if err != nil {
log.Printf("[-] [-] [INIT] [-] [-] [-] [-] [-] [-] [%v]\n", err)
}
}
}()
}
Expand Down
10 changes: 5 additions & 5 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"os"
"reflect"
"strings"
"sync"
Expand Down Expand Up @@ -421,15 +421,15 @@ func proxy(w http.ResponseWriter, r *http.Request) {
confLock.RUnlock()
if ok {
if r.Body != nil {
if body, err := ioutil.ReadAll(r.Body); err == nil {
if body, err := io.ReadAll(r.Body); err == nil {
r.Body.Close()
var msg map[string]interface{}
if err := json.Unmarshal(body, &msg); err == nil {
delete(msg, "sessionId")
body, _ = json.Marshal(msg)
r.ContentLength = int64(len(body))
}
r.Body = ioutil.NopCloser(bytes.NewReader(body))
r.Body = io.NopCloser(bytes.NewReader(body))
}
}
if h.Scheme != "" {
Expand Down Expand Up @@ -570,7 +570,7 @@ func withCloseNotifier(handler http.HandlerFunc) http.HandlerFunc {
}

func readConfig(fn string, browsers *Browsers) error {
file, err := ioutil.ReadFile(fn)
file, err := os.ReadFile(fn)
if err != nil {
return fmt.Errorf("error reading configuration file %s: %v", fn, err)
}
Expand Down Expand Up @@ -625,7 +625,7 @@ func requireBasicAuth(authenticator *auth.BasicAuth, handler func(http.ResponseW
})
}

//WithSuitableAuthentication handles basic authentication and guest quota processing
// WithSuitableAuthentication handles basic authentication and guest quota processing
func WithSuitableAuthentication(authenticator *auth.BasicAuth, handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if rootToken != "" {
Expand Down
15 changes: 7 additions & 8 deletions proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -100,7 +99,7 @@ func TestPing(t *testing.T) {
AssertThat(t, rsp.Body, Is{Not{nil}})

var data map[string]interface{}
bt, readErr := ioutil.ReadAll(rsp.Body)
bt, readErr := io.ReadAll(rsp.Body)
AssertThat(t, readErr, Is{nil})
jsonErr := json.Unmarshal(bt, &data)
AssertThat(t, jsonErr, Is{nil})
Expand All @@ -125,7 +124,7 @@ func TestStatus(t *testing.T) {
AssertThat(t, rsp.Body, Is{Not{nil}})

var data map[string]interface{}
bt, readErr := ioutil.ReadAll(rsp.Body)
bt, readErr := io.ReadAll(rsp.Body)
AssertThat(t, readErr, Is{nil})
jsonErr := json.Unmarshal(bt, &data)
AssertThat(t, jsonErr, Is{nil})
Expand Down Expand Up @@ -785,7 +784,7 @@ func TestStartSessionWithOverriddenBasicAuth(t *testing.T) {
func TestStartSessionWithPrefixVersion(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/wd/hub/session", postOnly(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
r.Body.Close()
var sess map[string]map[string]string
err := json.Unmarshal(body, &sess)
Expand Down Expand Up @@ -839,7 +838,7 @@ func TestCreateSessionW3CBrowserNotSet2(t *testing.T) {
func TestStartSessionWithDefaultVersion(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/wd/hub/session", postOnly(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
r.Body.Close()
w.Write([]byte(`{"sessionId":"123"}`))
var sess map[string]map[string]string
Expand Down Expand Up @@ -878,7 +877,7 @@ func TestStartSessionWithDefaultVersion(t *testing.T) {
func TestStartSessionWithDefaultVersionW3C(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/wd/hub/session", postOnly(func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
r.Body.Close()
var sess map[string]map[string]map[string]interface{}
err := json.Unmarshal(body, &sess)
Expand Down Expand Up @@ -1416,7 +1415,7 @@ func TestProxyJsonRequest(t *testing.T) {
func TestProxyPlainRequest(t *testing.T) {
mux := http.NewServeMux()
mux.HandleFunc("/wd/hub/session/", func(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
body, _ := io.ReadAll(r.Body)
r.Body.Close()
AssertThat(t, string(body), EqualTo{"request"})
})
Expand Down Expand Up @@ -1685,7 +1684,7 @@ func TestFileExists(t *testing.T) {
tmpDir := os.TempDir()
AssertThat(t, fileExists(tmpDir), Is{false})
AssertThat(t, fileExists(filepath.Join(tmpDir, "missing-file")), Is{false})
f, err := ioutil.TempFile(tmpDir, "testfile")
f, err := os.CreateTemp(tmpDir, "testfile")
AssertThat(t, err, Is{nil})
AssertThat(t, fileExists(f.Name()), Is{true})
}
Expand Down

0 comments on commit c041f40

Please sign in to comment.