servlet-test-mockmvc-logout.md 694 字节
Newer Older
茶陵後's avatar
茶陵後 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
# 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`](request-post-processors.html) will submit a POST to "/logout" with a valid CSRF token:

Java

```
mvc
	.perform(logout())
```

Kotlin

```
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

```
mvc
	.perform(logout("/signout"))
```

Kotlin

```
mvc
	.perform(logout("/signout"))
```

[Mocking OAuth2](oauth2.html)[Security RequestBuilders](request-builders.html)