Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

jwk: Fix memory mamager of JWK deletion #1474

Merged
merged 3 commits into from
Jun 24, 2019
Merged
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added go-acc install command because make test requires.


# Runs full test suite including tests where databases are enabled
.PHONY: test
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion jwk/manager_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions jwk/manager_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down