0

I have an ASP.NET Web API project using .NET 6. This project uses openiddict 4 to validate client's bearer tokens using introspection. I also have an event handler that will call another endpoint on the identity server to get extra claims that are needed for the authorization policies.

The current integration tests work only if [Authorize] attributes are commented on the controller methods.

I know that if I would have had the identity provider in the same project I could have made in a fixture some calls to login to actually login the http client used for the test. But in this scenario I'm not sure how to approach the problem.

Obviously I would like the tests to not make actual calls to the identity server but have a method to authenticate and authorize the user to also make sure that the authorization does it's job

How would one go about creating integration test for this scenario?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dmdany07
  • 47
  • 6
  • Sounds more like a e2e test to me. In this case you can probably set up a docker compose network and use a mock authorization server. – Clemens Jun 21 '23 at 21:14
  • This case may help:https://stackoverflow.com/questions/39390339/integration-testing-with-in-memory-identityserver/39409789#39409789 – Ruikai Feng Jun 22 '23 at 05:53

0 Answers0