diff --git a/Makefile b/Makefile index 623d509..2a94779 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,11 @@ test-local: install-deps fmt lint vet @go test -v ./... test: - @docker run -e GO111MODULE=off -v ${shell pwd}:/go/src/${PKG_NAME} -w /go/src/${PKG_NAME} ${IMAGE} make test-local + @docker run --rm -v ${shell pwd}:/go/src/${PKG_NAME} -w /go/src/${PKG_NAME} ${IMAGE} make test-local install-deps: @echo "+ $@" - @go get -u golang.org/x/lint/golint - @go get -d -t ./... + @go install golang.org/x/lint/golint@latest lint: @echo "+ $@" diff --git a/authorization/api_test.go b/authorization/api_test.go index 5532b2b..dd8e39b 100644 --- a/authorization/api_test.go +++ b/authorization/api_test.go @@ -17,7 +17,6 @@ import ( "time" "github.com/docker/go-plugins-helpers/sdk" - "github.com/stretchr/testify/require" ) type TestPlugin struct { @@ -150,21 +149,29 @@ func TestPeerCertificateMarshalJSON(t *testing.T) { } // generate private key privatekey, err := rsa.GenerateKey(rand.Reader, 2048) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } publickey := &privatekey.PublicKey // create a self-signed certificate. template = parent parent := template raw, err := x509.CreateCertificate(rand.Reader, template, parent, publickey, privatekey) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } cert, err := x509.ParseCertificate(raw) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } certs := []*x509.Certificate{cert} addr := "www.authz.com/auth" req, err := http.NewRequest("GET", addr, nil) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } req.RequestURI = addr req.TLS = &tls.ConnectionState{} @@ -176,15 +183,25 @@ func TestPeerCertificateMarshalJSON(t *testing.T) { t.Run("Marshalling :", func(t *testing.T) { raw, err = pcObj.MarshalJSON() - require.NotNil(t, raw) - require.Nil(t, err) + if raw == nil { + t.Fatalf("Failed to marshal peer certificate") + } + if err != nil { + t.Fatal(err) + } }) t.Run("UnMarshalling :", func(t *testing.T) { err := pcObj.UnmarshalJSON(raw) - require.Nil(t, err) - require.Equal(t, "Earth", pcObj.Subject.Country[0]) - require.Equal(t, true, pcObj.IsCA) + if err != nil { + t.Fatal(err) + } + if expected := "Earth"; pcObj.Subject.Country[0] != expected { + t.Fatalf("Expected %s, got %s\n", expected, pcObj.Subject.Country[0]) + } + if pcObj.IsCA != true { + t.Fatalf("Expected %t, got %t\n", true, pcObj.IsCA) + } }) } diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3c58365 --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/docker/go-plugins-helpers + +go 1.21 + +require ( + github.com/Microsoft/go-winio v0.6.2 + github.com/coreos/go-systemd/v22 v22.5.0 + github.com/docker/docker v23.0.13+incompatible + github.com/docker/go-connections v0.5.0 +) + +require golang.org/x/sys v0.10.0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..75702d5 --- /dev/null +++ b/go.sum @@ -0,0 +1,11 @@ +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/docker/docker v23.0.13+incompatible h1:il+Z3USrag/LJkF5apR6APO5sVpjm82jm/wp5XvO4hQ= +github.com/docker/docker v23.0.13+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/sdk/unix_listener_systemd.go b/sdk/unix_listener_systemd.go index 59c53bf..8117673 100644 --- a/sdk/unix_listener_systemd.go +++ b/sdk/unix_listener_systemd.go @@ -7,7 +7,7 @@ import ( "net" "os" - "github.com/coreos/go-systemd/activation" + "github.com/coreos/go-systemd/v22/activation" ) // isRunningSystemd checks whether the host was booted with systemd as its init