-
I tried using |
Beta Was this translation helpful? Give feedback.
Answered by
ch4mpy
Dec 1, 2023
Replies: 1 comment
-
It is expected behavior: test annotations are intended to populate the test security context with an For CSRF, in addition to authentication annotation, use one of:
As a reminder:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ch4mpy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is expected behavior: test annotations are intended to populate the test security context with an
Authentication
instance at your hand. It do nothing about CSRF.For CSRF, in addition to authentication annotation, use one of:
mockMvc.perform(post("/").with(SecurityMockMvcRequestPostProcessors.csrf()))
webTestClient.mutateWith(SecurityMockServerConfigurers.csrf())
As a reminder:
@WithOAuth2Login
or@WithOidcLogin
on an OAuth2 client withoauth2Login
, not when using@WithJwt
or@…