Location>code7788 >text

Eight, Spring Boot integration Spring Security before and after the separation of authentication best implementation of docking test

Popularity:395 ℃/2024-11-09 22:59:55

preamble

This article introduces before and after the separation of the certification of the best implementation of the docking test, the use of postman or other familiar testing tools, with the following content to watch the effect is better !

  • What is the best solution for separating the front and back certification process and why is it designed that way? Please check outSix, Spring Boot integration Spring Security before and after the separation of the authentication process best practices
  • Wow even, understand the principle of the best solution for separating the front and back authentication process, so how to realize this solution? Please checkSeven, Spring Boot integration Spring Security before and after the separation of the best implementation of authentication
  • Nice to know how to code to implement the best solution for separating the front and back authentication process, so how do I test it? Please checkEight, Spring Boot integration Spring Security before and after the separation of authentication best implementation of docking test
  • Blogger, to help people to the end, to send Buddha to the west, mention whether to provide the source code ah? Please do.Click to download

I. Normal flow test

1、Login interface test

  1. Login requests are handled by a custom authentication filter, RestfulUsernamePasswordAuthenticationFilter, so there is no need to provide a controller interface.
  2. Interface information: POST.http://localhost:8080/login
  3. The interface returns a token, which is used for subsequent business requests

2、Business interface testing

  1. Write business interfaces
  2. Interface information: GET.http://localhost:8080/test/hello
  3. Add the token returned by the login interface to the request header of each business request

![1731162635214]

3、Logout interface test

  1. The logout interface is handled by LogoutFilter, so there is no need to provide a controller interface.
  2. Interface Address:http://localhost:8080/logout

II. Non-normal process testing

1、Input the wrong user name and password to log in

2、No request header to access the business interface

3. Invalid request header to access the business interface

4. Failure to carry a valid request header when logging out