I have created a Spring Boot application containing various endpoints. Except for signup and login endpoints I've added a filter for other requests. All other requests should have:
Authorization Bearer <token>
and requests goes through Spring Security filter chain which checks the user exists in the table or not via UserDetailService.
I would like to know how can I write unit tests for any GET/POST API with Spring Security in place ?
One way i have in mind is to generate the actual token by calling signup API and then call other APIs with the Authorization token generated by Signup API.
OR
There might be some way to mock or skip the Authorization Bearer for unit tests
I wanted to know what is this the correct/best approach that's followed across?