Rob Winch 39c43159f4 Convert to Asciidoctor Tabs
Closes gh-13403
2023-06-18 21:30:41 -05:00

47 lines
839 B
Plaintext

[[test-logout]]
= 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` xref:servlet/test/mockmvc/request-post-processors.adoc[`RequestPostProcessor`] will submit a POST to "/logout" with a valid CSRF token:
[tabs]
======
Java::
+
[source,java,role="primary"]
----
mvc
.perform(logout())
----
Kotlin::
+
[source,kotlin,role="secondary"]
----
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:
[tabs]
======
Java::
+
[source,java,role="primary"]
----
mvc
.perform(logout("/signout"))
----
Kotlin::
+
[source,kotlin,role="secondary"]
----
mvc
.perform(logout("/signout"))
----
======