Error with parameter that contains a "=" character #182

Closed
opened 2025-12-29 14:24:34 +01:00 by adam · 3 comments
Owner

Originally created by @guerital on GitHub (Jun 19, 2019).

I have created a small sample to report the error I'm facing with:

using System.Net;
using NUnit.Framework;
using WireMock.Matchers;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;

namespace WireMockNUnit
{
    [TestFixture]
    class ReportError
    {
        #region Fixture

        private FluentMockServer _server;

        #endregion

        #region Setup & Teardown

        [SetUp]
        public void SetUp()
        {
            _server = FluentMockServer.Start(new FluentMockServerSettings
            {
                Urls = new[] {"http://localhost:12345/" },
                StartAdminInterface = true
            });
        }

        [TearDown]
        public void TearDown()
        {
            _server.Stop();
        }

        #endregion

        [TestCase("value")]
        [TestCase("va?ue")]
        [TestCase("val=e")]
        public void Test(string value)
        {
            _server
                .Given(Request
                    .Create()
                    .WithPath("/path")
                    .WithParam("key", MatchBehaviour.AcceptOnMatch, true, value)
                    .UsingGet())
                .RespondWith(Response
                    .Create()
                    .WithStatusCode(200)
                    .WithBody("You got it!"));

            var client = new WebClient();
            var content = client.DownloadString($"http://localhost:12345/path?key={value}");

            Assert.AreEqual(content, "You got it!");
        }
    }
}

Running this test that has three test case I have obtained the following result:

  • case "value": No error
  • case "va?ue": No error
  • case "val=e":
System.Net.WebException : The remote server returned an error: (404) Not Found.
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadString(Uri address)
   at WireMockNUnit.ReportError.Test(String value) in C:\Users\italo.guerrieri\Downloads\WireMockPoc\WireMockNUnit\Class1.cs:line 57
Originally created by @guerital on GitHub (Jun 19, 2019). I have created a small sample to report the error I'm facing with: ``` c# using System.Net; using NUnit.Framework; using WireMock.Matchers; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Server; using WireMock.Settings; namespace WireMockNUnit { [TestFixture] class ReportError { #region Fixture private FluentMockServer _server; #endregion #region Setup & Teardown [SetUp] public void SetUp() { _server = FluentMockServer.Start(new FluentMockServerSettings { Urls = new[] {"http://localhost:12345/" }, StartAdminInterface = true }); } [TearDown] public void TearDown() { _server.Stop(); } #endregion [TestCase("value")] [TestCase("va?ue")] [TestCase("val=e")] public void Test(string value) { _server .Given(Request .Create() .WithPath("/path") .WithParam("key", MatchBehaviour.AcceptOnMatch, true, value) .UsingGet()) .RespondWith(Response .Create() .WithStatusCode(200) .WithBody("You got it!")); var client = new WebClient(); var content = client.DownloadString($"http://localhost:12345/path?key={value}"); Assert.AreEqual(content, "You got it!"); } } } ``` Running this test that has three test case I have obtained the following result: * case "value": No error * case "va?ue": No error * case "val=e": ``` System.Net.WebException : The remote server returned an error: (404) Not Found. at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at WireMockNUnit.ReportError.Test(String value) in C:\Users\italo.guerrieri\Downloads\WireMockPoc\WireMockNUnit\Class1.cs:line 57 ```
adam added the questionbug labels 2025-12-29 14:24:34 +01:00
adam closed this issue 2025-12-29 14:24:35 +01:00
Author
Owner

@lobsteropteryx commented on GitHub (Aug 13, 2019):

I've submitted a PR which I believe will fix this problem; in our case, we were trying to send a parameter with a double equals ==, and we found that we could match properly on the same querystring with a single equals = in our test code.

For example, our production code would send ?key=value==something, and our test code would match on ?key=value=something. Don't know if that helps, but thought it might be worth mentioning!

@lobsteropteryx commented on GitHub (Aug 13, 2019): I've submitted a PR which I believe will fix this problem; in our case, we were trying to send a parameter with a double equals `==`, and we found that we could match properly on the same querystring with a single equals `=` in our test code. For example, our production code would send `?key=value==something`, and our test code would match on `?key=value=something`. Don't know if that helps, but thought it might be worth mentioning!
Author
Owner

@StefH commented on GitHub (Aug 14, 2019):

@lobsteropteryx Thank you.

@guerital A new version will be uploaded to NuGet shortly. Please test, and if the issue is still there, please create a new issue.

@StefH commented on GitHub (Aug 14, 2019): @lobsteropteryx Thank you. @guerital A new version will be uploaded to NuGet shortly. Please test, and if the issue is still there, please create a new issue.
Author
Owner

@guerital commented on GitHub (Aug 20, 2019):

@lobsteropteryx @StefH Thanks, the fix has worked

@guerital commented on GitHub (Aug 20, 2019): @lobsteropteryx @StefH Thanks, the fix has worked
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#182