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

AbstractJsonPartialMatcher: Regex Value is Uppercased when IgnoreCase is set to true #1117

Closed epDugas closed 3 weeks ago

epDugas commented 3 weeks ago

Describe the bug

AbstractJsonPartialMatcher When IgnoreCase is true, and Regex is true, the value used as a regex is upper-cased. This changes a given regex and causes a non-match. Example: "^\d+$" is changed to "^\D+$"

Expected behavior:

Expect the given regex to be used.

Test to reproduce

Other related info

Test to Demonstrate:

[Fact]
public void JsonPartialWildcardMatcher_IsMatch_WithIgnoreCaseTrueAndRegexTrue_JObject()
{
    // Assign 
    var matcher = new JsonPartialWildcardMatcher(new { id = 1, Number = "^\\d+$" }, true, true);

    // Act 
    var jObject = new JObject
    {
        { "Id", new JValue(1) },
        { "Number", new JValue(1) }
    };
    double match = matcher.IsMatch(jObject).Score;

    // Assert 
    Assert.Equal(1.0, match);
}
StefH commented 3 weeks ago

@epDugas Thanks for this finding.

A fix will be released shortly.

StefH commented 3 weeks ago

https://github.com/WireMock-Net/WireMock.Net/commit/86f8877039d89674f4191f40b2d85320398167d1