Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Phelps <[email protected]>
  • Loading branch information
markphelps committed Apr 15, 2024
1 parent ec5dc16 commit b9e8cd1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/server/authn/middleware/grpc/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func TestJWTAuthenticationInterceptor(t *testing.T) {
claims := map[string]interface{}{
"iss": "https://flipt.io/",
"aud": "flipt",
"sub": "sunglasses",
"iat": nowUnix,
"exp": futureUnix,
}
Expand All @@ -85,6 +86,7 @@ func TestJWTAuthenticationInterceptor(t *testing.T) {
expectedJWT: jwt.Expected{
Issuer: "https://flipt.io/",
Audiences: []string{"flipt"},
Subject: "sunglasses",
},
},
{
Expand Down Expand Up @@ -138,6 +140,27 @@ func TestJWTAuthenticationInterceptor(t *testing.T) {
},
expectedErr: ErrUnauthenticated,
},
{
name: "invalid subject",
metadataFunc: func() metadata.MD {
claims := map[string]interface{}{
"iss": "https://flipt.io/",
"iat": nowUnix,
"exp": futureUnix,
"sub": "bar",
}

token := oidc.TestSignJWT(t, priv, string(jwt.RS256), claims, []byte("test-key"))
return metadata.MD{
"Authorization": []string{"JWT " + token},
}
},
expectedJWT: jwt.Expected{
Issuer: "https://flipt.io/",
Subject: "flipt",
},
expectedErr: ErrUnauthenticated,
},
{
name: "invalid audience",
metadataFunc: func() metadata.MD {
Expand Down

0 comments on commit b9e8cd1

Please sign in to comment.