mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Content-Type multipart/form-data is not serialized in proxy and recording mode #171
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pmiossec on GitHub (Apr 1, 2019).
Originally assigned to: @StefH on GitHub.
In the last version of
WireMock.Net.StandAlone( Version="1.0.8"), when doing a Content-Type multipart/form-data POST request, the mapping generated doesn't contain the Matcher for the body (so that don't made it a valid mapping).Note: I forward to another Wiremock instance and see the content of the body, so the content seems to be forwarded.
I get the generated mapping (Notice the empty "Body" key) :
I have the same behavior when doing the request through Postman or C# code...
If you want to test, you could reproduce with this code.
@StefH commented on GitHub (Apr 1, 2019):
If possible, can you provide the full body (captured using fiddler for example)?
@pmiossec commented on GitHub (Apr 1, 2019):
Body content obtained with fiddler:
@StefH commented on GitHub (Apr 1, 2019):
I checked, and this is actually
by design.Only full text or json body is saved on the mapping.
I left out Bytes / Multipart because I'm not sure which matcher to use.
@pmiossec commented on GitHub (Apr 1, 2019):
I don't know what to do with this answer 😢
It seems to me that the content in sent in text so it should be possible to do some checks.
But what worries me much is that the body is empty and we could think that nothing was sent...
I don't know if we could not have a "No check" matcher so that we could have the value received serialized in the mapping file but ignored in the matching process. That way the developer could really see what have been sent.
Thanks for the answer.
@StefH commented on GitHub (Apr 1, 2019):
Sorry for my short answer. What I just meant to say is that up until your question, I did not really think it would be usefull / possible to save the body in case of Bytes or Multipart.
I think using the
ExactObjectMatchercould be an option in this case. I'll take a look at the code.@StefH commented on GitHub (Apr 1, 2019):
Using the ExactObjectMatcher would return the body in the mapping as:
Example:
Would this be ok?
@StefH commented on GitHub (Apr 2, 2019):
Linked to PR - https://github.com/WireMock-Net/WireMock.Net/pull/264
@StefH commented on GitHub (Apr 2, 2019):
I can also build some logic to check if the data is a valid ASCII string, in that case I can change the detection from MultiPart logic and the code will automatically used the current string matchers...
In this case, the mapping would look like:
@pmiossec commented on GitHub (Apr 2, 2019):
I'm really impress and appreciate this very quick PR 👍
But that didn't let me the time to answer your question 😢
I don't think it will be very useful due to the multiparts boundaries that are by default auto generated and, so, varies and consequently, the ExactObjectMatcher will match nothing :(
Something like that will indeed be much more valuable and will let the developer check for part of the string (without the boundaries, for example).
@StefH commented on GitHub (Apr 2, 2019):
Would the mapping in my proposal work for you?
@pmiossec commented on GitHub (Apr 2, 2019):
I'm not very used to mapping file but will I be able to modified it to look like below and that will still work?
If yes, 👍
Perhaps there is also a something looking like
ContainsMatcherthat return true if the body contains the string passed?@StefH commented on GitHub (Apr 2, 2019):
You can indeed change the generated mapping to use the
WildcardMatcher, this is essentially a contains-matcher if used correctly (in your example this is correct) ==>"*XXX*"@StefH commented on GitHub (Apr 2, 2019):
@pmiossec
If you like, you can use this preview NuGet which includes this code.
https://www.myget.org/feed/wiremock-net/package/nuget/WireMock.Net/1.0.12-ci-11179
@pmiossec commented on GitHub (Apr 2, 2019):
I'll try to do that. Thanks a lot again (especially for your spontaneity!)
On Tue, 2 Apr 2019 at 15:02, Stef Heyenrath notifications@github.com
wrote:
@StefH commented on GitHub (Apr 4, 2019):
@pmiossec Does that NuGet work correct for you?
@pmiossec commented on GitHub (Apr 5, 2019):
@StefH I have tested it and it is working as expected.
Thank you very much!
@StefH commented on GitHub (Apr 5, 2019):
Today a new official NuGet will be released.