This depends on the authorization methods used to protect those endpoints.
For example if you use JWT you could generate your token in the TestInitialize and set the Authorization header on the client.
TestInitialize
Authorization
I'm planning on doing another post going into more detail.
Good point. But if you're ought to create and API for SPA, you'd probably consider not only 'header' implementation. For those reasons I personally prefer to send JWT in HttpOnly cookie. Could you please cover this case as well?
Just published the second post covering Cookie and JWT authentication!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This depends on the authorization methods used to protect those endpoints.
For example if you use JWT you could generate your token in the
TestInitialize
and set theAuthorization
header on the client.I'm planning on doing another post going into more detail.
Good point.
But if you're ought to create and API for SPA, you'd probably consider not only 'header' implementation.
For those reasons I personally prefer to send JWT in HttpOnly cookie. Could you please cover this case as well?
Just published the second post covering Cookie and JWT authentication!
ASP.NET Core Integration Testing: Protected endpoints
Kai Oswald ・ Oct 7 ・ 4 min read