Authenticating in the @WebMvcTest
Learn authentication by simulating a user login.
We'll cover the following...
Simulating user login
Since our UserController
has all its methods secured, we need a way to simulate a user logging in so that we can do some actual validation on the controller’s logic.
The Spring Security test has some helper annotations like @WithMockUser
and @WithUserDetails
to help us. In our production security configuration, we use ...