-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support @TestSecurity in combination with JWT-Security #11695
Comments
/cc @radcortez |
@janmaterne thanks, I wonder if we can have
and this |
Sounds good. The value of the Maybe that could default to the value which is used by the application. Could be done by checking for the existence of marker classes on the classpath (during build time):
First thought of the name An alternative would be additional values for the security annotation
But I would prefer your direct use as it is more easier to write than this nested annotations. |
@janmaterne thanks, I actually like your last example, as I guess it all has to be better off grouped together, such extra attributes will not always be used; Stuart will have a better appreciation of it though.
|
When using a nested structure maybe another name is better:
|
Hi @sberyozkin , Line 60 in 5fa5376
I am a bit confused about the role of those |
@geoandri Hi, I've missed it, sorry. I think this issue is about making sure that that |
Hi @sberyozkin, thanks for your help. I have submitted a PR. |
Description
If your application uses JWT for security, you could disable the security during tests with
@TestSecurity(authorizationEnabled = false)
.But if your application requires data (like username or roles) from the JWT, the test will crash with a HTTP-500.
Implementation ideas
Generate a JsonWebToken with the data from the
@TestSecurity
annotation and publish it to CDI context for later injection.The
io.quarkus.test.security.QuarkusSecurityTestExtension#beforeEach
does this for the SecurityIdentity, but adding JWT here would add another dependency which is not required everywhere. Maybe directly a json?Maybe a hook could be implemented where the test author could add some custom values for the JWT.
The text was updated successfully, but these errors were encountered: