Save mappings to files #560

Closed
opened 2025-12-29 15:26:59 +01:00 by adam · 5 comments
Owner

Originally created by @MindaugasLaganeckas on GitHub (Dec 8, 2023).

Originally assigned to: @StefH on GitHub.

Describe the bug

Missing mapping files in case the request URL is the same AND the HTTP request method is the same, BUT the request data is different.
This bug breaks our record mapping files and replay tests using local mapping files flow.

Expected behavior:

Even though I use the same request URL and the same HTTP request method, but as long as I change the request data, I expect to get a mapping file for every such request.

Test to reproduce

Start wiremock server in the examples/Wiremock.Net.Console.Proxy.NetCoreApp

Execute
curl -d "param1=value1&param2=value2" -X POST http://localhost:9091/post
curl -d "param10=value10&param20=value20" -X POST http://localhost:9091/post

Expected behavior: find 2 different mapping files in the __admin/mappings folder one for each request.
Actual behavior: 1 mapping file in the __admin/mappings folder containing the latest request/response data.

Other info.
I am willing to work on the issue since it is a blocker for our test execution.
Would you have any suggestions of how to fix it?

My inputs:
A naïve approach would be to add GUID to the name of the mapping file before saving it.
I am not sure whether a more sophisticated approach is needed.

Originally created by @MindaugasLaganeckas on GitHub (Dec 8, 2023). Originally assigned to: @StefH on GitHub. ### Describe the bug Missing mapping files in case the request URL is the same AND the HTTP request method is the same, BUT the request data is different. This bug breaks our record mapping files and replay tests using local mapping files flow. ### Expected behavior: Even though I use the same request URL and the same HTTP request method, but as long as I change the request data, I expect to get a mapping file for every such request. ### Test to reproduce Start wiremock server in the examples/Wiremock.Net.Console.Proxy.NetCoreApp Execute curl -d "param1=value1&param2=value2" -X POST http://localhost:9091/post curl -d "param10=value10&param20=value20" -X POST http://localhost:9091/post Expected behavior: find 2 different mapping files in the __admin/mappings folder one for each request. Actual behavior: 1 mapping file in the __admin/mappings folder containing the latest request/response data. Other info. I am willing to work on the issue since it is a blocker for our test execution. Would you have any suggestions of how to fix it? My inputs: A naïve approach would be to add GUID to the name of the mapping file before saving it. I am not sure whether a more sophisticated approach is needed.
adam added the question label 2025-12-29 15:26:59 +01:00
adam closed this issue 2025-12-29 15:26:59 +01:00
Author
Owner

@StefH commented on GitHub (Dec 8, 2023):

You are correct, the mapping file is named Proxy Mapping for POST _post.json which is the same in both cases.

A possible solution for this is to add the hashcode from the mapping also in the filename. In that case you'll get 2 files.

@StefH commented on GitHub (Dec 8, 2023): You are correct, the mapping file is named `Proxy Mapping for POST _post.json` which is the same in both cases. A possible solution for this is to add the hashcode from the mapping also in the filename. In that case you'll get 2 files.
Author
Owner

@StefH commented on GitHub (Dec 8, 2023):

Or just append a random Guid in this scenario as you suggest, but this should be configurable in the ProxyAndRecordSettings

@StefH commented on GitHub (Dec 8, 2023): Or just append a random Guid in this scenario as you suggest, but this should be configurable in the ProxyAndRecordSettings
Author
Owner

@StefH commented on GitHub (Dec 8, 2023):

Ah...

It's already supported with AppendGuidToSavedMappingFile boolean.

@StefH commented on GitHub (Dec 8, 2023): Ah... It's already supported with `AppendGuidToSavedMappingFile` boolean.
Author
Owner

@MindaugasLaganeckas commented on GitHub (Dec 9, 2023):

Wow! Thank you so much for a quick reply! I will try it out on Monday and will return to you. 🎄

@MindaugasLaganeckas commented on GitHub (Dec 9, 2023): Wow! Thank you so much for a quick reply! I will try it out on Monday and will return to you. 🎄
Author
Owner

@MindaugasLaganeckas commented on GitHub (Dec 11, 2023):

Thank you! The flag works as expected.

@MindaugasLaganeckas commented on GitHub (Dec 11, 2023): Thank you! The flag works as expected.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#560