Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/modules/ROOT/pages/servlet/test/method.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ You can change this to happen during the `TestExecutionListener.beforeTestExecut
@WithSecurityContext(setupBefore = TestExecutionEvent.TEST_EXECUTION)
----

[NOTE]
====
`@WithMockUser`, `@WithUserDetails`, and `@WithSecurityContext` populate the xref:servlet/authentication/architecture.adoc#servlet-authentication-securitycontextholder[`SecurityContextHolder`] for the test thread.
This works for method-security tests and for xref:servlet/test/mockmvc/index.adoc[`MockMvc`] (when using `testSecurityContext()`), but does not automatically apply to full HTTP requests made through external clients (for example, REST-assured against a running server), because those requests are handled on a different thread.
Comment thread
jzheaux marked this conversation as resolved.
For end-to-end HTTP tests, xref:servlet/authentication/index.adoc[authenticate] the request itself (for example, with HTTP Basic or a bearer token).
====


[[test-method-meta-annotations]]
== Test Meta Annotations
Expand Down
Loading