Skip to content

add go.mod #140

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 "+ $@"
Expand Down
37 changes: 27 additions & 10 deletions authorization/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"time"

"github.com/docker/go-plugins-helpers/sdk"
"github.com/stretchr/testify/require"
)

type TestPlugin struct {
Expand Down Expand Up @@ -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{}
Expand All @@ -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)
}
})

}
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
2 changes: 1 addition & 1 deletion sdk/unix_listener_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down