-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package JWK: if missing kid in jwks, then refresh JWKS (#411)
* if missing kid in jwks, then refresh JWKS * updated comments and removed unused const * made const lower case / private * moved webgatewaykid const to test file * simplified decoder to split out jwks lifecycle management to seperate class * chore(deps): update module gopkg.in/datadog/dd-trace-go.v1 to v1.63.1 (#413) (#414) Co-authored-by: cultureamp-renovate[bot] <89962466+cultureamp-renovate[bot]@users.noreply.github.com> Co-authored-by: Self-hosted Renovate Bot <135776+cultureamp-renovate[bot]@users.noreply.github.com> * Package LOG: Updates from Go meeting (#412) * removed error on Debug() Info() etc. * removed unused func GetEnvBool * now can create logger with start up properties and use extensions * removed FromContext wip * removed nolint errcheck on ld client * added Child to Logger interface * example using Child to inherit parent values * added context helpers - unit tests still to come * started tests for context helpers * cleaned up tests and examples and made default fields appears inside properties * put default/global properties in a 'default_properties' sub-doc so they don't overwrite normal properties * updated README with logging examples * Upgraded Go to 1.22.3 to close CVE-2024-24787 and CVE-2024-24788 (#416) * updated to go 1.22.3 to close CVE-2024-24787 and CVE-2024-24788 * small update to the README to force snyk to pass the build * Trigger Build * minor updates to linters (#415) * minor updates to linters * enabled all new linters by default and exclude only those we don't (yet) support * added internal revive linter fixes - no breaking changes * turned on ireturn linter * reemoved ex exclude rule in favour of //nolint * fixed some magic number lint errors * fixed conflict and golint ireturns * fixed all magic number lint warnings * made const lower case / private * simplified decoder to split out jwks lifecycle management to seperate class * jwks can rotate by default in 30 seconds * minor updates to linters (#415) * minor updates to linters * enabled all new linters by default and exclude only those we don't (yet) support * added internal revive linter fixes - no breaking changes * turned on ireturn linter * reemoved ex exclude rule in favour of //nolint * fixed some magic number lint errors * fixed conflict and golint ireturns * fixed all magic number lint warnings * fixed linter warnings * added jwks tests and cleaned up class * try and fix ireturn linter warnings * fixed refresh logic * fixed test and coverage pipeline steps * ignore example and gen files from coverage stats * ignore kafaktest dir in coverage stats * fixed kafka typo --------- Co-authored-by: cultureamp-renovate[bot] <89962466+cultureamp-renovate[bot]@users.noreply.github.com> Co-authored-by: Self-hosted Renovate Bot <135776+cultureamp-renovate[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5c9c9ee
commit 193a498
Showing
9 changed files
with
310 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package jwt | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestJwkSet(t *testing.T) { | ||
b, err := os.ReadFile(filepath.Clean(testAuthJwks)) | ||
require.Nil(t, err) | ||
|
||
count := 0 | ||
dispatcher := func() string { | ||
count++ | ||
return string(b) | ||
} | ||
|
||
expiresIn := 200 * time.Millisecond | ||
rotatesIn := 100 * time.Millisecond | ||
|
||
// 1. test constructor | ||
jwk := newJWKSet(dispatcher, expiresIn, rotatesIn) | ||
assert.NotNil(t, jwk) | ||
|
||
// 2. test get works ok | ||
set, err := jwk.Get() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, set) | ||
assert.Equal(t, 1, count) | ||
|
||
// 3. check refresh returns the current set | ||
set, err = jwk.Refresh() | ||
assert.NotNil(t, err) | ||
assert.ErrorContains(t, err, "failed to refresh jwks as just recently updated") | ||
assert.NotNil(t, set) | ||
assert.Equal(t, 1, count) | ||
|
||
// Now wait so that the refresh window is reached | ||
time.Sleep(100 * time.Millisecond) | ||
|
||
// 4. check refresh returns new set | ||
set, err = jwk.Refresh() | ||
assert.Nil(t, err) | ||
assert.NotNil(t, set) | ||
assert.Equal(t, 2, count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.