Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice on unit testing with Joken JWKS? #61

Open
Nezteb opened this issue Apr 23, 2024 · 0 comments
Open

Advice on unit testing with Joken JWKS? #61

Nezteb opened this issue Apr 23, 2024 · 0 comments

Comments

@Nezteb
Copy link

Nezteb commented Apr 23, 2024

I have a project using joken_jwks. I've been writing some unit tests for my business logic, but whenever I try to verify_and_validate a token in a unit test, I get various failures because the tokens I'm testing with aren't valid according to the JWKS signers fetched.

I found some useful testing code that I tried copying:

The one thing I didn't copy was the Tesla mock for the JWKS URL, but maybe that's required?

Even then, when I create a token in a unit test it fails verification/validation. Perhaps there is a way to configure joken_jwks in config/test.exs to make this easier? Or something I can add to the module I'm calling use JokenJwks.DefaultStrategyTemplate in? I could mock/stub my use Joken.Config module and its verify_and_exit/1 call, but I'd prefer not to mock/stub.

Any advice would be appreciated; thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant