WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.35k stars 197 forks source link

Encoded url path parameter decoded via proxy #1097

Open adsk-duszykf opened 1 month ago

adsk-duszykf commented 1 month ago

Describe the bug

An encoded url parameter looks decoded by WireMock server. My code sends a request like : POST http://localhost:4200/api/file%3Atest.pdf to Wiremock proxy server. The url is then transformed to POST https://webservie.com/api/file:test.pdf. Here the url encoded parameter file%3Atest.pdf is decoded and forwarded as file:test.pdf which generate an error from the webservice

I

Expected behavior:

I expect that encoded url parameter are not decoded

Test to reproduce

  1. Create a mock server with proxy (here is my code)
    
    MockServer = WireMockServer.Start(new WireMockServerSettings
    {
    Urls = [BaseProxyURL],
    FileSystemHandler = new LocalFileSystemHandler(recordingPath),
    });

MockServer .Given(Request.Create().WithPath($"/service/")) .RespondWith(Response.Create() .WithProxy(new ProxyAndRecordSettings { Url = "https://webservice.com/",

        SaveMapping = true,
        SaveMappingToFile = true,
        ExcludedHeaders = ["Authorization"],
        ReplaceSettings = new ProxyUrlReplaceSettings
        {
            OldValue = $"/service",
            NewValue = ""
        }
    })
);

2. Capture the outbound traffic with fiddler
3. Send a request containing an encoded url parameter