From 0ea08928374d2499f92f91462179608116ad0fb7 Mon Sep 17 00:00:00 2001 From: Shota Sawada Date: Mon, 17 Jun 2019 22:15:13 +0900 Subject: [PATCH 1/3] jwk: Fix memory mamager of JWK deletion Signed-off-by: Shota Sawada --- jwk/manager_memory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwk/manager_memory.go b/jwk/manager_memory.go index fe92c9bfc24..043d7098e8e 100644 --- a/jwk/manager_memory.go +++ b/jwk/manager_memory.go @@ -123,7 +123,7 @@ func (m *MemoryManager) DeleteKey(ctx context.Context, set, kid string) error { var results []jose.JSONWebKey for _, key := range keys.Keys { if key.KeyID != kid { - results = append(results) + results = append(results, key) } } m.Keys[set].Keys = results From 485dd304b5db530afcc2ce15347fa7cc54486424 Mon Sep 17 00:00:00 2001 From: Shota Sawada Date: Tue, 18 Jun 2019 13:56:30 +0900 Subject: [PATCH 2/3] vendor: Install go-acc in tools installation Signed-off-by: Shota Sawada --- Makefile | 2 ++ go.mod | 1 + go.sum | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 9af44fb7b0c..7da44285c69 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ tools: npm i go get github.com/go-bindata/go-bindata/go-bindata go install github.com/go-bindata/go-bindata/go-bindata + go get github.com/ory/go-acc + go install github.com/ory/go-acc # Runs full test suite including tests where databases are enabled .PHONY: test diff --git a/go.mod b/go.mod index fcb65a35985..2ad18940b66 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ require ( cloud.google.com/go v0.39.0 // indirect github.com/Microsoft/go-winio v0.4.12 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect github.com/go-openapi/analysis v0.19.0 // indirect github.com/go-openapi/errors v0.18.0 github.com/go-openapi/inflect v0.19.0 // indirect diff --git a/go.sum b/go.sum index 63784ac1780..2e4a1224b53 100644 --- a/go.sum +++ b/go.sum @@ -76,6 +76,8 @@ github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7a github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-bindata/go-bindata v3.1.1+incompatible h1:tR4f0e4VTO7LK6B2YWyAoVEzG9ByG1wrXB4TL9+jiYg= github.com/go-bindata/go-bindata v3.1.1+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= +github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= +github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= From dde537a34fc7db2238a08375e34da0eddc22f010 Mon Sep 17 00:00:00 2001 From: Shota Sawada Date: Tue, 18 Jun 2019 13:59:58 +0900 Subject: [PATCH 3/3] jwk: Add test for JWK deletion to make sure only one key is deleted Signed-off-by: Shota Sawada --- jwk/manager_test_helpers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jwk/manager_test_helpers.go b/jwk/manager_test_helpers.go index c665545d659..5566831b3b5 100644 --- a/jwk/manager_test_helpers.go +++ b/jwk/manager_test_helpers.go @@ -81,11 +81,16 @@ func TestHelperManagerKey(m Manager, keys *jose.JSONWebKeySet, suffix string) fu require.NoError(t, err) assert.EqualValues(t, "new-key-id:"+suffix, First(keys.Keys).KeyID) + beforeDeleteKeysCount := len(keys.Keys) err = m.DeleteKey(context.TODO(), "faz", "public:"+suffix) require.NoError(t, err) _, err = m.GetKey(context.TODO(), "faz", "public:"+suffix) require.Error(t, err) + + keys, err = m.GetKeySet(context.TODO(), "faz") + require.NoError(t, err) + assert.EqualValues(t, beforeDeleteKeysCount-1, len(keys.Keys)) } }