Closed 4effo closed 4 years ago
Hello, just tried to reproduce the problem that I have and it seems the error probably is related with the JUnit setup that I have. Here example of my setup: https://github.com/4effo/spring-webflux-security-xsuaa-usage
Would be glad to try out any suggestion.
Hi @4effo
indeed, spring-xsuaa
had to overwrite the Spring Security JwtDecoder and reconfigure the used Nimbus Jwt Decoder slightly to prepare it for multi-tenant applications. That's why
in case you want to disable Security for the ControllerTests you may have to exclude the Auto-Configurations from spring-xsuaa
:
https://github.com/SAP/cloud-security-xsuaa-integration/tree/master/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/autoconfiguration
In case you like to test the security setup as part of your ControllerTests, we already have a test setup, as described here, but this can be (hopefully) simplified when using java-security-test (spring-xsuaa-mock is deprecated because of complexity).
Best regards, Nena
Hi @nenaraab
Thanks for your response. I didn't knew that the xsuaa mock is deprecated. I'll try by using the java-security-test and if I'm successful I could let you know. Meanwhile I tested also with JUnit 4 and it seems that my assumption is wrong actually. As mentioned before, I use the @WebFluxTest annotation and probably this is the one which causes the auto configuration of a different JwtDecoderBuilder.
Best regards, Stefan
Hi @4effo
cool, thanks! I will keep this ticket open to track the process.
Best regards, Nena
Hi @nenaraab,
I could use the java-securitiy-test module. I can confirm it's much simpler. Two hints that could help further to someone else (for the xsuaa use case):
I think we can close the issue! Thanks a lot!
Greetings, Stefan
Hi @4effo,
Thanks for your feedback, i have two questions.
Thanks and best regards, Nena
Hello,
Need help in investigation of the following problem in a @WebFluxController test. I use the spring-xsuaa-mock version 2.7.7 with spring boot 2.3.3.Release When I deploy my app the authentication works as expected but I have issue with the unit test (I use JUnit 5).
So I setup the WebFluxTest with the following annotations:
Anyway, the call to the endpoint from the WebTestClient fails with the following stack trace:
Is the wrong JwtDecoder used? Not sure how I could change it in the test. So far I tried something like this but without success:
Appreciate any further help!