Test Protected (Spring Security) Controller Endpoints With MockMvc

Опубликовано: 16 Октябрь 2024
на канале: Philip Riecks
10,471
182

This is the fourth video of the MockMvc mini-series. It covers mocking the authentication and authorization when using MockMvc to test protected endpoints.

Part I:    • Setup MockMvc to Test Your Spring MVC...  
Part II:    • Perform HTTP GET and POST Requests Mo...  
Part III:    • Use MockMvc to Test a Spring MVC Thym...  
Part IV:    • Test Protected (Spring Security) Cont...  

Content:

0:00 Applying protection with Spring Security
1:30 Use @WithMockUser
4:10 Apply a SecurityMockMvcRequestPostProcessor to MockMvc
5:07 Adding a valid CSRF token to the HTTP POST request

Source code: https://github.com/rieckpil/blog-tuto...

More testing related content is available on my blog: https://rieckpil.de/

» Want to become an expert for testing Spring Boot applications? Join the Testing Spring Boot Applications Masterclass: https://rieckpil.de/testing-spring-bo...

» Revamp your Testing Knowledge with this 14 Days Free Email Course on Testing Java Applications: https://rieckpil.de/getting-started-w...