Closed jpmeijers closed 2 years ago
You should be able init the middleware and then do something like middleware.CheckJWT(MyHandlerFunction)
See this for examples of how we test things:
https://github.com/auth0/go-jwt-middleware/blob/master/middleware_test.go#L154
@jpmeijers I've opened a PR which shows some tests: https://github.com/auth0/go-jwt-middleware/pull/157
Nice. I think it is clear enough and I'll be able to follow it to write my own tests.
I wanted to write tests for my handlers, but had the issue of my handlers requiring the auth0 decoded access token in the context. Some searching further and I managed to do the following to add the user id (subject field) to the context.
Maybe someone can help how one would add the other fields and custom claims. I have not yet been successful in adding custom claims to the context.