-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebTestClient authentication fails with form-data credentials #10841
Comments
Hi @membersound. Thanks for the sample over in spring boot issue. I was able to pull in the project and see your errors. I am able to convert the simple project you provided to a Spring WebFlux project by removing the All that to say, I'm uncertain whether your scenario would be expected to work currently as I believe the |
Hi @membersound. Just to let you know, I've spoken with the team around this issue. A couple of takeaways:
|
@sjohnr currently it is possible to use e.g. val webTestClient = MockMvcWebTestClient.bindToApplicationContext(webApplicationContext)
.apply(SecurityMockMvcConfigurers.springSecurity())
.defaultRequest(MockMvcRequestBuilders.get("/").with(SecurityMockMvcRequestPostProcessors.csrf()))
.configureClient()
.build() If an exception is thrown proactively during |
Thanks @mengelbrecht, that's definitely worth exploring. I'm less familiar with the test infrastructure, so thanks for pointing that out! |
spring-boot-2.6.3
I'm migrating my
MockMvc
tests toWebTestClient
, for having all my tests using the same underlying API.The following example project shows that authenticating on the
/login
page works withMockMvc
, but does not withWebTestClient
.In real world, I'm testing a ldap security configuration, but the issue is reproducible even with in-memory authentication.
This is a result result of spring-projects/spring-boot#29825
(see the issue also for a full sample project attached)
I assume this is a bug, as authentication with
MockMvc
works flawless, andWebTestClient
does not.Tests:
Source:
The text was updated successfully, but these errors were encountered: