Skip to content

query parameters ignored in post request by HtmlUnitRequestBuilder #33249

@Crydust

Description

@Crydust

Bug in both spring boot 3.4.0-M1 and 3.3.2 (spring-test 6.2.0-M6 and 6.1.11).
When submitting a form in a real browser the query string is included in the parameters.
This allow me to write @PostMapping(params = "form=1") to detect which form was submitted.

It works in production, but not a unittest.
When using HtmlUnit in a test annotated with @SpringBootTest this fails.
HtmlUnitRequestBuilder.params reads this.webRequest.getParameters(), but WebRequest.getParameters ignores query string parameters for post.

I've tested this in spring boot 3.4.0-M1 as I hoped the switch to a newer htmlunit version would have fixed it.
The bug also exists in 3.3.2 and probably all previous versions.

I've put together a minimal testcase here: https://github.com/Crydust/testcasehtmlunit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions