ExactMatcher with array pattern not working? #167

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

Originally created by @FSatmar on GitHub (Mar 19, 2019).

Originally assigned to: @StefH on GitHub.

Hi,
So I created this mapping:

{
    "Guid": "57cb97c5-d307-40d9-9a50-a8bf4c0842e5",
    "Priority": 0,
    "Request": {
      "Path": {
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "/test",
            "IgnoreCase": false
          }
        ]
      },
      "Methods": [
        "get"
      ],
      "Params": [
        {
          "Name": "ids",
          "Matchers": [
            {
              "Name": "ExactMatcher",
              "Patterns": [
                "1",
                "2"
              ]
            }
          ]
        }
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyDestination": "SameAsSource",
      "Body": "OK",
      "UseTransformer": false,
      "Headers": {
        "content-type": "application/json; charset=utf-8"
      }
    }
  }

And I'm making this request:

{
    "Guid": "d4e602a8-095c-4ae6-ab15-9aefbb14c22f",
    "Request": {
      "ClientIP": "****",
      "DateTime": "2019-03-19T14:54:05.2688502+00:00",
      "Path": "/test",
      "AbsolutePath": "/test",
      "Url": "http://mss.ait.env.works:54024/test?ids=1,2",
      "AbsoluteUrl": "http://mss.ait.env.works:54024/test?ids=1,2",
      "Query": {
        "ids": [
          "1",
          "2"
        ]
      },
      "Method": "get",
      "Headers": {
        "X-P2P-PeerDist": [
          "Version=1.1"
        ],
        "X-P2P-PeerDistEx": [
          "MinContentInformation=1.0, MaxContentInformation=2.0"
        ],
        "Connection": [
          "Keep-Alive"
        ],
        "Accept": [
          "text/html, application/xhtml+xml, image/jxr, */*"
        ],
        "Accept-Encoding": [
          "gzip, deflate, peerdist"
        ],
        "Accept-Language": [
          "en-US,en;q=0.8,de-DE;q=0.5,de;q=0.3"
        ],
        "Host": [
          "mss.ait.env.works:54024"
        ],
        "User-Agent": [
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
        ]
      }
    },
    "Response": {
      "StatusCode": 404,
      "Headers": {
        "Content-Type": [
          "application/json"
        ]
      },
      "BodyAsJson": {
        "Status": "No matching mapping found"
      },
      "BodyEncoding": {
        "CodePage": 65001,
        "EncodingName": "Unicode (UTF-8)",
        "WebName": "utf-8"
      }
    }
  }

but as you can see it does not work as I'm not getting the expected response. What am I doing wrong?

Originally created by @FSatmar on GitHub (Mar 19, 2019). Originally assigned to: @StefH on GitHub. Hi, So I created this mapping: ``` js { "Guid": "57cb97c5-d307-40d9-9a50-a8bf4c0842e5", "Priority": 0, "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/test", "IgnoreCase": false } ] }, "Methods": [ "get" ], "Params": [ { "Name": "ids", "Matchers": [ { "Name": "ExactMatcher", "Patterns": [ "1", "2" ] } ] } ] }, "Response": { "StatusCode": 200, "BodyDestination": "SameAsSource", "Body": "OK", "UseTransformer": false, "Headers": { "content-type": "application/json; charset=utf-8" } } } ``` And I'm making this request: ``` js { "Guid": "d4e602a8-095c-4ae6-ab15-9aefbb14c22f", "Request": { "ClientIP": "****", "DateTime": "2019-03-19T14:54:05.2688502+00:00", "Path": "/test", "AbsolutePath": "/test", "Url": "http://mss.ait.env.works:54024/test?ids=1,2", "AbsoluteUrl": "http://mss.ait.env.works:54024/test?ids=1,2", "Query": { "ids": [ "1", "2" ] }, "Method": "get", "Headers": { "X-P2P-PeerDist": [ "Version=1.1" ], "X-P2P-PeerDistEx": [ "MinContentInformation=1.0, MaxContentInformation=2.0" ], "Connection": [ "Keep-Alive" ], "Accept": [ "text/html, application/xhtml+xml, image/jxr, */*" ], "Accept-Encoding": [ "gzip, deflate, peerdist" ], "Accept-Language": [ "en-US,en;q=0.8,de-DE;q=0.5,de;q=0.3" ], "Host": [ "mss.ait.env.works:54024" ], "User-Agent": [ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299" ] } }, "Response": { "StatusCode": 404, "Headers": { "Content-Type": [ "application/json" ] }, "BodyAsJson": { "Status": "No matching mapping found" }, "BodyEncoding": { "CodePage": 65001, "EncodingName": "Unicode (UTF-8)", "WebName": "utf-8" } } } ``` but as you can see it does not work as I'm not getting the expected response. What am I doing wrong?
adam added the bug label 2025-12-29 14:24:09 +01:00
adam closed this issue 2025-12-29 14:24:09 +01:00
Author
Owner

@StefH commented on GitHub (Mar 19, 2019):

The best option is to look at the logging from WireMock, there you will see which matchers match correctly. Can you post the logging here?

@StefH commented on GitHub (Mar 19, 2019): The best option is to look at the logging from WireMock, there you will see which matchers match correctly. Can you post the logging here?
Author
Owner

@FSatmar commented on GitHub (Mar 19, 2019):

I'm not sure what you mean? I posted the request log from __admin/requests

@FSatmar commented on GitHub (Mar 19, 2019): I'm not sure what you mean? I posted the request log from __admin/requests
Author
Owner

@StefH commented on GitHub (Mar 19, 2019):

You can do a GET request to :
http://{{wm_hostname}}/__admin/requests

@StefH commented on GitHub (Mar 19, 2019): You can do a GET request to : http://{{wm_hostname}}/__admin/requests
Author
Owner

@StefH commented on GitHub (Mar 19, 2019):

Or look at the console log where WireMock is running

@StefH commented on GitHub (Mar 19, 2019): Or look at the console log where WireMock is running
Author
Owner

@FSatmar commented on GitHub (Mar 20, 2019):

You can do a GET request to :
http://{{wm_hostname}}/__admin/requests

This is where I took the request log from (second snippet)

@FSatmar commented on GitHub (Mar 20, 2019): > > > You can do a GET request to : > http://{{wm_hostname}}/__admin/requests This is where I took the request log from (second snippet)
Author
Owner

@StefH commented on GitHub (Mar 20, 2019):

I understand.
When a request is 100% or partially matching, the/admin/requests shows additional information:

"MappingGuid": "a51b78ac-1300-4125-aa97-d48953deef4d",
        "RequestMatchResult": {
            "TotalScore": 1,
            "TotalNumber": 1,
            "IsPerfectMatch": true,
            "AverageTotalScore": 1,
            "MatchDetails": [
                {
                    "Name": "PathMatcher",
                    "Score": 1
                }
            ]
        }

In your case you don't see this.

I'll check why it does not match...

@StefH commented on GitHub (Mar 20, 2019): I understand. When a request is 100% or partially matching, the`/admin/requests` shows additional information: ``` js "MappingGuid": "a51b78ac-1300-4125-aa97-d48953deef4d", "RequestMatchResult": { "TotalScore": 1, "TotalNumber": 1, "IsPerfectMatch": true, "AverageTotalScore": 1, "MatchDetails": [ { "Name": "PathMatcher", "Score": 1 } ] } ``` In your case you don't see this. I'll check why it does not match...
Author
Owner

@FSatmar commented on GitHub (Mar 20, 2019):

Oh, that part is missing from my logged request...

@FSatmar commented on GitHub (Mar 20, 2019): Oh, that part is missing from my logged request...
Author
Owner

@StefH commented on GitHub (Mar 20, 2019):

If you set partialmapping to true, you will also get this part...

@StefH commented on GitHub (Mar 20, 2019): If you set partialmapping to true, you will also get this part...
Author
Owner

@FSatmar commented on GitHub (Mar 20, 2019):

Just tried it, but with partial mapping on any request I make just returns the latest mapping regardless of path or parameters. However I would need to have different mappings with same path but different parameters.

@FSatmar commented on GitHub (Mar 20, 2019): Just tried it, but with partial mapping on any request I make just returns the latest mapping regardless of path or parameters. However I would need to have different mappings with same path but different parameters.
Author
Owner

@StefH commented on GitHub (Mar 20, 2019):

It's a bug. Thanks for finding.

@StefH commented on GitHub (Mar 20, 2019): It's a bug. Thanks for finding.
Author
Owner

@StefH commented on GitHub (Mar 20, 2019):

Can you try a new MyGet version?
1.0.9-ci-11110

see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@StefH commented on GitHub (Mar 20, 2019): Can you try a new MyGet version? 1.0.9-ci-11110 see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
Author
Owner

@FSatmar commented on GitHub (Mar 21, 2019):

It's working better in this version but there is still one bug: if I have 2 mappings, one has parameters {1,2} and the second {1,2,3}, when I make a request for {1,2,3} I still get the response for {1,2}. Does that make sense?

@FSatmar commented on GitHub (Mar 21, 2019): It's working better in this version but there is still one bug: if I have 2 mappings, one has parameters {1,2} and the second {1,2,3}, when I make a request for {1,2,3} I still get the response for {1,2}. Does that make sense?
Author
Owner

@StefH commented on GitHub (Mar 21, 2019):

can you try WireMock.Net.1.0.9-ci-11120.nupkg ?

@StefH commented on GitHub (Mar 21, 2019): can you try `WireMock.Net.1.0.9-ci-11120.nupkg` ?
Author
Owner

@FSatmar commented on GitHub (Mar 22, 2019):

I'm still getting the latest mapping back. So first I create mapping for {1,2}, then I create mapping for {1,2,3} and when I request response for {1,2} I get the response from {1,2,3} mapping.

@FSatmar commented on GitHub (Mar 22, 2019): I'm still getting the latest mapping back. So first I create mapping for {1,2}, then I create mapping for {1,2,3} and when I request response for {1,2} I get the response from {1,2,3} mapping.
Author
Owner

@StefH commented on GitHub (Mar 23, 2019):

Please try WireMock.Net.1.0.9-ci-11123.nupkg

@StefH commented on GitHub (Mar 23, 2019): Please try WireMock.Net.1.0.9-ci-11123.nupkg
Author
Owner

@FSatmar commented on GitHub (Mar 25, 2019):

Yes, that's it, working like a charm now!

@FSatmar commented on GitHub (Mar 25, 2019): Yes, that's it, working like a charm now!
Author
Owner

@StefH commented on GitHub (Mar 25, 2019):

@FSatmar --> New official NuGet is uploaded.

@StefH commented on GitHub (Mar 25, 2019): @FSatmar --> New official NuGet is uploaded.
Author
Owner

@FSatmar commented on GitHub (Mar 26, 2019):

Cheers!

@FSatmar commented on GitHub (Mar 26, 2019): Cheers!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#167