question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can I preserve Mapping title and matchers for proxy response?

See original GitHub issue

Hello.

I use a third party SOAP service that I’ve been told I run tests against too often. I was hoping to use WireMock to proxy and record these requests. Then I’d like to use the recorded mappings as stubs going forward. To proxy and record the initial set, I use something like this:

    server
        .Given(Request.Create().WithPath("/*")
        .WithBody(new RegexMatcher("<RequestType>Auth</RequestType")))
        .WithTitle(rule.Name)
        .RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings
        {
           Url = proxyTarget,
           AllowAutoRedirect = true,
           SaveMapping = true,
           SaveMappingToFile = true,
        }));

Because it is a SOAP service, all the requests use the same URL. The request primarily differ on the body contents. Currently when I run these requests, it seems like a new mapping is creating, using the path and method to create a new title. Since the path and method are the same for each request, each request overwrites the one before it. It also seems that the regex matchers that were specified in the original mapping are being discarded in favor of matching the url, path, headers, and an exact match on the body of the request.

If that understanding is correct, is there a way to work around this behavior to preserve the original mapping? If there isn’t a work around, I’d like to submit a PR. In it, I’d try to add an option to ProxyAndRecordSettings and use that to decide how to build the resulting mapping. Would that help?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
steven-nelson-olocommented, Sep 30, 2022

Thanks @StefH I appreciate all of your help!

0reactions
StefHcommented, Oct 11, 2022

Done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Charles Proxy Rewrite vs MapLocal
MapLocal files can't include regex matches from the rewrite tool so the data always has to be static unless you amend the file...
Read more >
How to manipulate HTTP response using Proxyman Map ...
This mini blog demonstrate how to use Proxyman Map Local Tool to quickly manipulate the response body.
Read more >
Make nginx to pass hostname of the upstream when ...
This answer implies that $host variable gets set to the value of the server name from the upstream block server directive but that...
Read more >
Setting up a Reverse Proxy
Click the Create Mapping link. The Create Mapping page is displayed. ... Save and apply your changes. To see the mappings you just...
Read more >
HTTP proxy server custom properties
On the settings page, type the custom property to configure in the Name field, and type the value of the custom property in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found