Skip to content

Commit

Permalink
ensure Token implements the new AttributesAccessor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Aug 13, 2024
1 parent ecc370c commit a287834
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions basculejwt/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (t token) Capabilities() (caps []string) {
return
}

func (t token) Get(key string) (any, bool) {
return t.jwt.Get(key)
}

// tokenParser is the canonical parser for bascule that deals with JWTs.
// This parser does not use the source.
type tokenParser struct {
Expand Down
5 changes: 5 additions & 0 deletions basculejwt/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func (suite *TokenTestSuite) TestTokenParser() {
suite.Equal(suite.capabilities, caps)
suite.True(ok)

suite.Require().Implements((*bascule.AttributesAccessor)(nil), token)
v, ok := bascule.GetAttribute[string](token.(bascule.AttributesAccessor), "version")
suite.True(ok)
suite.Equal(suite.version, v)

suite.Require().Implements((*Claims)(nil), token)
claims := token.(Claims)
suite.Equal(suite.audience, claims.Audience())
Expand Down

0 comments on commit a287834

Please sign in to comment.