Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-allen committed Oct 18, 2024
1 parent d5b34dd commit 736f60c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/handler/subject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"net/http"
"testing"

"github.com/Allen-Career-Institute/flagr/pkg/config/jwtmiddleware"

"github.com/Allen-Career-Institute/flagr/pkg/config"
"github.com/golang-jwt/jwt/v5"
"github.com/stretchr/testify/assert"
Expand All @@ -23,11 +25,11 @@ func TestGetSubjectFromJWT(t *testing.T) {
assert.Equal(t, getSubjectFromRequest(r.WithContext(ctx)), "")

//nolint:staticcheck // jwt-middleware is using the string type of context key
ctx = context.WithValue(ctx, config.Config.JWTAuthUserProperty, &jwt.Token{})
ctx = context.WithValue(ctx, jwtmiddleware.ContextKey(config.Config.JWTAuthUserProperty), nil) //nolint:staticcheck // jwt-middleware is using the string type of context keyconfig.Config.JWTAuthUserProperty, &jwt.Token{})
assert.Equal(t, getSubjectFromRequest(r.WithContext(ctx)), "")

//nolint:staticcheck // jwt-middleware is using the string type of context key
ctx = context.WithValue(ctx, config.Config.JWTAuthUserProperty, &jwt.Token{
ctx = context.WithValue(ctx, jwtmiddleware.ContextKey(config.Config.JWTAuthUserProperty), &jwt.Token{
Claims: jwt.MapClaims{
"sub": "[email protected]",
},
Expand Down

0 comments on commit 736f60c

Please sign in to comment.