Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) - #1503
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1503 +/- ##
==========================================
- Coverage 30.76% 30.48% -0.29%
==========================================
Files 163 163
Lines 42251 42626 +375
==========================================
- Hits 12999 12995 -4
- Misses 28889 29270 +381
+ Partials 363 361 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@Bafyn This fix is a rather big retfactor... Can you also take a look? |
There was a problem hiding this comment.
Pull request overview
This PR fixes and refactors form-url-encoded body matching by moving form/query parameter values from single strings to WireMockList<string> (to support multi-value keys) and by reworking matcher scoring logic accordingly.
Changes:
- Refactor form-url-encoded parsing and models to represent multiple values per key via
WireMockList<string>. - Rework
FormUrlEncodedMatcherand parameter matching score calculations to better handle multi-value matching scenarios. - Update/extend unit tests to cover single vs multiple values and AND/OR operator behaviors.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/WireMock.Net.Tests/WireMockServerTests.WithBody.cs | Adds a typed FormUrlEncoded body func test using WireMockList<string> values. |
| test/WireMock.Net.Tests/Util/QueryStringParserTests.cs | Updates parser tests for WireMockList<string>-based outputs. |
| test/WireMock.Net.Tests/RequestMatchers/RequestMessageParamMatcherTests.cs | Updates param matcher tests for new scoring behavior and newer collection literals. |
| test/WireMock.Net.Tests/RequestBuilders/RequestBuilderWithBodyTests.cs | Updates request builder test to use WireMockList<string> form-url-encoded bodies. |
| test/WireMock.Net.Tests/Matchers/FormUrlEncodedMatcherTests.cs | Major expansion of matcher tests across single/multiple values and AND/OR logic. |
| test/WireMock.Net.Tests/Abstractions/WireMockListTests.cs | Adds equality/operator + Equals/GetHashCode tests for WireMockList<string>. |
| src/WireMock.Net.Shared/Util/QueryStringParser.cs | Changes TryParse to collect multiple values per key into WireMockList<string>. |
| src/WireMock.Net.Shared/RequestBuilders/IBodyRequestBuilder.cs | Breaks API type for form-url-encoded body func to use WireMockList<string>. |
| src/WireMock.Net.Shared/Models/BodyData.cs | Updates BodyAsFormUrlEncoded to IDictionary<string, WireMockList<string>>. |
| src/WireMock.Net.Shared/Matchers/MatchScores.cs | Broadens score helpers to IEnumerable<T> and adds list-vs-matchers scoring helper. |
| src/WireMock.Net.Shared/Extensions/AnyOfExtensions.cs | Minor using cleanup. |
| src/WireMock.Net.Minimal/RequestBuilders/Request.WithBody.cs | Updates WithBody overload signature for form-url-encoded func. |
| src/WireMock.Net.Minimal/Matchers/Request/RequestMessageParamMatcher.cs | Switches param scoring to the new MatchScores.ToScore(list, matchers) logic. |
| src/WireMock.Net.Minimal/Matchers/Request/RequestMessageBodyMatcher.cs | Updates form-url-encoded func signature to use WireMockList<string>. |
| src/WireMock.Net.Minimal/Matchers/FormUrlEncodedMatcher.cs | Reworks internal representation and matching/scoring for multi-value inputs. |
| src/WireMock.Net.Abstractions/Types/WireMockList.cs | Adds operators and value-based equality/hash code implementation. |
| src/WireMock.Net.Abstractions/Models/IBodyData.cs | Updates BodyAsFormUrlEncoded type to WireMockList<string> values. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Bafyn
left a comment
There was a problem hiding this comment.
some comments from copilot also make sense like unused vars, etc.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Updated [DotNext](https://github.com/dotnet/dotNext) from 6.7.1 to 6.8.0. <details> <summary>Release notes</summary> _Sourced from [DotNext's releases](https://github.com/dotnet/dotNext/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotNext/commits). </details> Updated [Eventuous.SignalR.Client](https://github.com/eventuous/Eventuous) from 0.16.5-alpha.0.22 to 0.16.5-alpha.0.33. <details> <summary>Release notes</summary> _Sourced from [Eventuous.SignalR.Client's releases](https://github.com/eventuous/Eventuous/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/eventuous/Eventuous/commits). </details> Updated [Markdig](https://github.com/xoofx/markdig) from 1.3.2 to 1.4.0. <details> <summary>Release notes</summary> _Sourced from [Markdig's releases](https://github.com/xoofx/markdig/releases)._ ## 1.4.0 # Changes ## ✨ New Features - Add strict GFM pipe table parsing mode (14cd25c7) ## 🐛 Bug Fixes - Fix heading auto-link hijacking nested link labels (#668) (PR #949) by @dualfroz - Fix: keep trailing content out of an unmatched emphasis closer (#743) (PR #950) by @dualfroz - Fix indent on first list item (#482) (PR #953) by @boxofyellow - Add Normalization Support for PipeTables (GFM) (PR #954) by @boxofyellow - Fix partially empty pipe table separator regression (PR #955) by @vicancy - Reject emoji-parsing if the slice ends with `**` (PR #947) by @bstordrup - Fix strict GFM tables against native cmark-gfm (86866b91) ## 🚀 Enhancements - Update 3rd party extensions (PR #945) by @Kryptos-FR ## 🏭 Tests - Fix tests warnings (96b024c2) ## 📦 Dependencies - Bump deps (c6b186b4) ## 🧰 Misc - Use NuGet Trusted Publishing via dotnet-releaser (56e9c238) **Full Changelog**: [1.3.2...1.4.0](xoofx/markdig@1.3.2...1.4.0) <sub>Published with [dotnet-releaser](https://github.com/xoofx/dotnet-releaser/)</sub> Commits viewable in [compare view](xoofx/markdig@1.3.2...1.4.0). </details> Updated [Microsoft.Testing.Extensions.GitHubActionsReport](https://github.com/microsoft/testfx) from 2.4.0 to 2.4.1. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Testing.Extensions.GitHubActionsReport's releases](https://github.com/microsoft/testfx/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/microsoft/testfx/commits). </details> Updated [Svg.Controls.Skia.Avalonia](https://github.com/wieslawsoltes/Svg.Skia) from 12.0.0.15 to 12.0.0.17. <details> <summary>Release notes</summary> _Sourced from [Svg.Controls.Skia.Avalonia's releases](https://github.com/wieslawsoltes/Svg.Skia/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/wieslawsoltes/Svg.Skia/commits). </details> Updated [Velopack](https://github.com/velopack/velopack) from 1.2.0 to 1.2.158. <details> <summary>Release notes</summary> _Sourced from [Velopack's releases](https://github.com/velopack/velopack/releases)._ ## 1.2.158 ## What's Changed * Fix NodeJSElectron sample for TypeScript 6.0 compatibility by @caesay in velopack/velopack#931 * Localize setup disk-space error and use byte units by @chinaszzt-erio in velopack/velopack#932 * Ignore pyo3 RUSTSEC-2026-0176/0177 advisories in cargo deny by @caesay in velopack/velopack#942 * Move argument validation to command layer, add JSON support, refactor deployment commands by @caesay in velopack/velopack#934 * Fix supply-chain CI: bump vite to 8.0.16 to resolve npm audit failure by @caesay in velopack/velopack#952 * Allow S3 region to be specified at the same time as endpoint by @caesay in velopack/velopack#957 * Ship 64-bit Windows bootstrapper binaries from vpk pack by @roysyahputra in velopack/velopack#944 * Renovate/dotnet packages deny cleanup by @caesay in velopack/velopack#968 * Add NodeJS pre-built sources & add HttpOptions class by @caesay in velopack/velopack#969 * Fix MSI quiet-install default location and bracket escaping in packTitle by @caesay in velopack/velopack#970 * Use atomic rename on macos by @caesay in velopack/velopack#972 * Add timing logs to diagnose slow update apply on EDR machines (#947) by @caesay in velopack/velopack#974 * Fix supply-chain CI: address new RUSTSEC advisories by @caesay in velopack/velopack#984 * Add new deployment and sources tests by @caesay in velopack/velopack#973 * Fix portable/MSI launcher renamed after update (packTitle vs mainExe) by @caesay in velopack/velopack#985 * Windows installer channel-override tag readers (Setup.exe + MSI) by @caesay in velopack/velopack#987 * Make Velopack Flow a first-class update source across all client libraries by @caesay in velopack/velopack#999 * Fix swapped MSI banner/dialog images, rename to --msiTopBanner and --msiDialogBackground by @caesay in velopack/velopack#1009 * Remove bsdiff fallback; zstd is the only delta patch format by @caesay in velopack/velopack#1010 * Show progress dialog during Windows uninstall by @caesay in velopack/velopack#1011 * Windows signing: pass /d (content description) for Azure Trusted Signing by @SamHartleyFixes in velopack/velopack#1047 * Write EstimatedSize as a REG_DWORD so Windows shows the app size by @timkonieczny in velopack/velopack#1051 * fix(vpk): safely handle non-JSON error responses in FlowApiExtensions by @Keboo in velopack/velopack#1055 * Lock file maintenance by @caesay in velopack/velopack#1063 * Update all dependencies to latest by @caesay in velopack/velopack#1064 ## New Contributors * @chinaszzt-erio made their first contribution in velopack/velopack#932 * @roysyahputra made their first contribution in velopack/velopack#944 * @SamHartleyFixes made their first contribution in velopack/velopack#1047 * @timkonieczny made their first contribution in velopack/velopack#1051 ## Dependency Updates <details> <summary>Expand to see all changed dependencies</summary> * Pin dependencies by @renovate[bot] in velopack/velopack#925 * Pin dependencies by @renovate[bot] in velopack/velopack#926 * Lock file maintenance by @renovate[bot] in velopack/velopack#930 * Update npm packages by @renovate[bot] in velopack/velopack#927 * Update sample dotnet packages by @renovate[bot] in velopack/velopack#940 * Update npm packages by @renovate[bot] in velopack/velopack#937 * Update sample js packages by @renovate[bot] in velopack/velopack#951 * Update dotnet test packages to 18.6.0 by @renovate[bot] in velopack/velopack#938 * Update dotnet packages by @renovate[bot] in velopack/velopack#949 * Update sample dotnet packages to 1.2.0 by @renovate[bot] in velopack/velopack#950 * Lock file maintenance by @renovate[bot] in velopack/velopack#943 * Update dependency WixToolset.Dtf.WindowsInstaller to v7 by @renovate[bot] in velopack/velopack#939 ... (truncated) ## 1.2.110-ge826545 ## What's Changed * Fix NodeJSElectron sample for TypeScript 6.0 compatibility by @caesay in velopack/velopack#931 * Localize setup disk-space error and use byte units by @chinaszzt-erio in velopack/velopack#932 * Ignore pyo3 RUSTSEC-2026-0176/0177 advisories in cargo deny by @caesay in velopack/velopack#942 * Move argument validation to command layer, add JSON support, refactor deployment commands by @caesay in velopack/velopack#934 * Fix supply-chain CI: bump vite to 8.0.16 to resolve npm audit failure by @caesay in velopack/velopack#952 * Allow S3 region to be specified at the same time as endpoint by @caesay in velopack/velopack#957 * Ship 64-bit Windows bootstrapper binaries from vpk pack by @roysyahputra in velopack/velopack#944 * Renovate/dotnet packages deny cleanup by @caesay in velopack/velopack#968 * Add NodeJS pre-built sources & add HttpOptions class by @caesay in velopack/velopack#969 * Fix MSI quiet-install default location and bracket escaping in packTitle by @caesay in velopack/velopack#970 * Use atomic rename on macos by @caesay in velopack/velopack#972 * Add timing logs to diagnose slow update apply on EDR machines (#947) by @caesay in velopack/velopack#974 * Fix supply-chain CI: address new RUSTSEC advisories by @caesay in velopack/velopack#984 * Add new deployment and sources tests by @caesay in velopack/velopack#973 * Fix portable/MSI launcher renamed after update (packTitle vs mainExe) by @caesay in velopack/velopack#985 * Windows installer channel-override tag readers (Setup.exe + MSI) by @caesay in velopack/velopack#987 * Make Velopack Flow a first-class update source across all client libraries by @caesay in velopack/velopack#999 ## New Contributors * @chinaszzt-erio made their first contribution in velopack/velopack#932 * @roysyahputra made their first contribution in velopack/velopack#944 ## Dependency Updates <details> <summary>Expand to see all changed dependencies</summary> * Pin dependencies by @renovate[bot] in velopack/velopack#925 * Pin dependencies by @renovate[bot] in velopack/velopack#926 * Lock file maintenance by @renovate[bot] in velopack/velopack#930 * Update npm packages by @renovate[bot] in velopack/velopack#927 * Update sample dotnet packages by @renovate[bot] in velopack/velopack#940 * Update npm packages by @renovate[bot] in velopack/velopack#937 * Update sample js packages by @renovate[bot] in velopack/velopack#951 * Update dotnet test packages to 18.6.0 by @renovate[bot] in velopack/velopack#938 * Update dotnet packages by @renovate[bot] in velopack/velopack#949 * Update sample dotnet packages to 1.2.0 by @renovate[bot] in velopack/velopack#950 * Lock file maintenance by @renovate[bot] in velopack/velopack#943 * Update dependency WixToolset.Dtf.WindowsInstaller to v7 by @renovate[bot] in velopack/velopack#939 * Update sample js packages by @renovate[bot] in velopack/velopack#961 * Update dependency System.IO.Packaging to 10.0.9 by @renovate[bot] in velopack/velopack#959 * Update dependency @types/node to v25.9.4 - autoclosed by @renovate[bot] in velopack/velopack#958 * Update codecov/codecov-action action to v7 by @renovate[bot] in velopack/velopack#963 * Lock file maintenance by @renovate[bot] in velopack/velopack#965 * Update rust crates to 0.29 by @renovate[bot] in velopack/velopack#962 * Update dotnet packages by @renovate[bot] in velopack/velopack#960 * Update actions/checkout action to v7 by @renovate[bot] in velopack/velopack#980 * Update dotnet packages by @renovate[bot] in velopack/velopack#976 * Update dependency electron to v43 by @renovate[bot] in velopack/velopack#977 ... (truncated) Commits viewable in [compare view](velopack/velopack@1.2.0...1.2.158). </details> Updated [WireMock.Net](https://github.com/wiremock/WireMock.Net) from 2.15.0 to 2.18.0. <details> <summary>Release notes</summary> _Sourced from [WireMock.Net's releases](https://github.com/wiremock/WireMock.Net/releases)._ ## 2.18.0 ## What's Changed * WireMock.Net.OpenApiParser: fix depencency on RamlToOpenApiConverter.SourceOnly by @StefH in wiremock/WireMock.Net#1510 **Full Changelog**: wiremock/WireMock.Net@2.17.0...2.18.0 ## 2.17.0 ## What's Changed * Revert to RamlToOpenApiConverter.SourceOnly by @StefH in wiremock/WireMock.Net#1509 **Full Changelog**: wiremock/WireMock.Net@2.16.0...2.17.0 ## 2.16.0 ## What's Changed * Fix #1501: Generate WhenStateIs/WillSetStateTo correctly in ToCSharpCode by @Bafyn in wiremock/WireMock.Net#1502 * Fix FormUrlEncodedMatcher (+ refactor values / matchers logic) by @StefH in wiremock/WireMock.Net#1503 * Update SharpYaml package to version 2.5.1 by @johnthcall in wiremock/WireMock.Net#1504 * Upgrade dependency RamlToOpenApiConverter to version 0.40.0 by @StefH in wiremock/WireMock.Net#1505 **Full Changelog**: wiremock/WireMock.Net@2.15.0...2.16.0 Commits viewable in [compare view](wiremock/WireMock.Net@2.15.0...2.18.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
No description provided.