This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Security 6.1.11! |
Testing Logout
While fairly trivial using standard Spring MVC Test, you can use Spring Security’s testing support to make testing log out easier.
For example, the following logout
RequestPostProcessor
will submit a POST to "/logout" with a valid CSRF token:
-
Java
-
Kotlin
mvc
.perform(logout())
mvc
.perform(logout())
You can also customize the URL to post to. For example, the snippet below will submit a POST to "/signout" with a valid CSRF token:
-
Java
-
Kotlin
mvc
.perform(logout("/signout"))
mvc
.perform(logout("/signout"))