Mappings with scenario #235

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

Originally created by @gregoks on GitHub (Dec 18, 2019).

Hi,

I have the following mappings defined on my wiremock machine:

[
{
  "Guid": "8ca5daaa-a9c4-4bef-9d6b-62e5b4d16eb5",
  "Priority": 1,
  "Scenario": "RetryScenario",
  "SetStateTo": "FirstRetry",
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "**reports**",
          "IgnoreCase": false
        }
      ]
    },
    "Methods": [
      "Post"
    ]
  },
  "Response": {
    "StatusCode": 200,
    "BodyAsJson": {
      "SuccessIds": [],
      "Message": "Success"
    },
    "Headers": {}
  }
},
{
  "Guid": "ecfa2e67-27c4-4925-98fc-0f8641d2a2d0",
  "Priority": 1,
  "Scenario": "RetryScenario",
  "WhenStateIs": "FirstRetry",
  "SetStateTo": "SecondRetry",
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "**reports**",
          "IgnoreCase": false
        }
      ]
    },
    "Methods": [
      "Post"
    ]
  },
  "Response": {
    "StatusCode": 200,
    "BodyAsJson": {
      "SuccessIds": [
        "",
        "",
        ""
      ],
      "Message": "Success"
    },
    "Headers": {}
  }
},
{
  "Guid": "51223398-e68e-492a-ba05-0f32c2bc0d45",
  "Priority": 2147483647,
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "WildcardMatcher",
          "Pattern": "**reports**",
          "IgnoreCase": true
        }
      ]
    }
  },
  "Response": {
    "ProxyUrl": "https://httpreport.azurewebsites.net",
    "WebProxy": {}
  }
}
]

When I send the following request using POST: http://wiremock.qa.com:10012/reports

for some reason its gets routed to the mapping with guid - 51223398-e68e-492a-ba05-0f32c2bc0d45 (mapping with priority 2147483647) and I expect it to be routed to mapping with guid 8ca5daaa-a9c4-4bef-9d6b-62e5b4d16eb5 because its has Priority 1.
If I remove the scenarios from the mapping then it does get routed to the mapping that I want.

here is the request log:

[
  {
    "Guid": "bf57e45d-7e47-4e3b-a024-c28cb33d9675",
    "Request": {
      "ClientIP": "10.30.20.4",
      "DateTime": "2019-12-18T13:38:52.8971897Z",
      "Path": "/reports",
      "AbsolutePath": "/reports",
      "Url": "http://wiremock.qa.com:10012/reports",
      "AbsoluteUrl": "http://wiremock.qa.com:10012/reports",
      "Query": {},
      "Method": "POST",
      "Headers": {
        "Cache-Control": [
          "no-cache"
        ],
        "Connection": [
          "keep-alive"
        ],
        "Content-Type": [
          "text/plain"
        ],
        "Accept": [
          "*/*"
        ],
        "Accept-Encoding": [
          "gzip, deflate"
        ],
        "Host": [
          "wiremock.qa.com:10012"
        ],
        "User-Agent": [
          "PostmanRuntime/7.19.0"
        ],
        "Content-Length": [
          "18"
        ],
        "Postman-Token": [
          "a831b94f-b110-430c-82a9-e98227061263"
        ],
        "X-Forwarded-For": [
          "192.168.112.30"
        ]
      },
      "Body": "{\"a\":\"sTiXXsZDWt\"}",
      "BodyAsJson": {
        "a": "sTiXXsZDWt"
      },
      "BodyEncoding": {
        "CodePage": 65001,
        "EncodingName": "Unicode (UTF-8)",
        "WebName": "utf-8"
      },
      "DetectedBodyType": "Json",
      "DetectedBodyTypeFromContentType": "String"
    },
    "Response": {
      "StatusCode": 403,
      "Headers": {
        "Content-Type": [
          "text/html"
        ],
        "Content-Length": [
          "2345"
        ],
        "Server": [
          "Microsoft-IIS/10.0"
        ],
        "Date": [
          "Wed, 18 Dec 2019 13:38:52 GMT"
        ]
      },
      "Body": "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n    <title>Web App - Unavailable</title>\r\n    <style type=\"text/css\">\r\n        html {\r\n            height: 100%;\r\n            width: 100%;\r\n        }\r\n\r\n        #feature {\r\n            width: 960px;\r\n            margin: 95px auto 0 auto;\r\n            overflow: auto;\r\n        }\r\n\r\n        #content {\r\n            font-family: \"Segoe UI\";\r\n            font-weight: normal;\r\n            font-size: 22px;\r\n            color: #ffffff;\r\n            float: left;\r\n            width: 460px;\r\n            margin-top: 68px;\r\n            margin-left: 0px;\r\n            vertical-align: middle;\r\n        }\r\n\r\n            #content h1 {\r\n                font-family: \"Segoe UI Light\";\r\n                color: #ffffff;\r\n                font-weight: normal;\r\n                font-size: 60px;\r\n                line-height: 48pt;\r\n                width: 800px;\r\n            }\r\n\r\n        p a, p a:visited, p a:active, p a:hover {\r\n            color: #ffffff;\r\n        }\r\n\r\n        #content a.button {\r\n            background: #0DBCF2;\r\n            border: 1px solid #FFFFFF;\r\n            color: #FFFFFF;\r\n            display: inline-block;\r\n            font-family: Segoe UI;\r\n            font-size: 24px;\r\n            line-height: 46px;\r\n            margin-top: 10px;\r\n            padding: 0 15px 3px;\r\n            text-decoration: none;\r\n        }\r\n\r\n            #content a.button img {\r\n                float: right;\r\n                padding: 10px 0 0 15px;\r\n            }\r\n\r\n            #content a.button:hover {\r\n                background: #1C75BC;\r\n            }\r\n    </style>\r\n</head>\r\n<body bgcolor=\"#00abec\">\r\n    <div id=\"feature\">\r\n            <div id=\"content\">\r\n                <h1 id=\"unavailable\">Error 403 - This web app is stopped.</h1>\r\n                <p id=\"tryAgain\">The web app you have attempted to reach is currently stopped and does not accept any requests. Please try to reload the page or visit it again soon.</p>\r\n                <p id=\"toAdmin\">If you are the web app administrator, please find the common 403 error scenarios and resolution <a href=\"https://go.microsoft.com/fwlink/?linkid=2095007\" target=\"_blank\">here</a>. For further troubleshooting tools and recommendations, please visit <a href=\"https://portal.azure.com/\">Azure Portal</a>.</p>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n",
      "BodyEncoding": {
        "CodePage": 65001,
        "EncodingName": "Unicode (UTF-8)",
        "WebName": "utf-8"
      },
      "DetectedBodyType": 1,
      "DetectedBodyTypeFromContentType": 1
    },
    "MappingGuid": "51223398-e68e-492a-ba05-0f32c2bc0d45",
    "RequestMatchResult": {
      "TotalScore": 1.0,
      "TotalNumber": 1,
      "IsPerfectMatch": true,
      "AverageTotalScore": 1.0,
      "MatchDetails": [
        {
          "Name": "PathMatcher",
          "Score": 1.0
        }
      ]
    }
  }
]

Do you have any idea why it caught the wrong mapping? Have I configured something wrong?

Originally created by @gregoks on GitHub (Dec 18, 2019). Hi, I have the following mappings defined on my wiremock machine: ``` js [ { "Guid": "8ca5daaa-a9c4-4bef-9d6b-62e5b4d16eb5", "Priority": 1, "Scenario": "RetryScenario", "SetStateTo": "FirstRetry", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "**reports**", "IgnoreCase": false } ] }, "Methods": [ "Post" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "SuccessIds": [], "Message": "Success" }, "Headers": {} } }, { "Guid": "ecfa2e67-27c4-4925-98fc-0f8641d2a2d0", "Priority": 1, "Scenario": "RetryScenario", "WhenStateIs": "FirstRetry", "SetStateTo": "SecondRetry", "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "**reports**", "IgnoreCase": false } ] }, "Methods": [ "Post" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "SuccessIds": [ "", "", "" ], "Message": "Success" }, "Headers": {} } }, { "Guid": "51223398-e68e-492a-ba05-0f32c2bc0d45", "Priority": 2147483647, "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "**reports**", "IgnoreCase": true } ] } }, "Response": { "ProxyUrl": "https://httpreport.azurewebsites.net", "WebProxy": {} } } ] ``` When I send the following request using POST: `http://wiremock.qa.com:10012/reports` for some reason its gets routed to the mapping with guid - 51223398-e68e-492a-ba05-0f32c2bc0d45 (mapping with priority 2147483647) and I expect it to be routed to mapping with guid 8ca5daaa-a9c4-4bef-9d6b-62e5b4d16eb5 because its has Priority 1. If I remove the scenarios from the mapping then it does get routed to the mapping that I want. here is the request log: ``` js [ { "Guid": "bf57e45d-7e47-4e3b-a024-c28cb33d9675", "Request": { "ClientIP": "10.30.20.4", "DateTime": "2019-12-18T13:38:52.8971897Z", "Path": "/reports", "AbsolutePath": "/reports", "Url": "http://wiremock.qa.com:10012/reports", "AbsoluteUrl": "http://wiremock.qa.com:10012/reports", "Query": {}, "Method": "POST", "Headers": { "Cache-Control": [ "no-cache" ], "Connection": [ "keep-alive" ], "Content-Type": [ "text/plain" ], "Accept": [ "*/*" ], "Accept-Encoding": [ "gzip, deflate" ], "Host": [ "wiremock.qa.com:10012" ], "User-Agent": [ "PostmanRuntime/7.19.0" ], "Content-Length": [ "18" ], "Postman-Token": [ "a831b94f-b110-430c-82a9-e98227061263" ], "X-Forwarded-For": [ "192.168.112.30" ] }, "Body": "{\"a\":\"sTiXXsZDWt\"}", "BodyAsJson": { "a": "sTiXXsZDWt" }, "BodyEncoding": { "CodePage": 65001, "EncodingName": "Unicode (UTF-8)", "WebName": "utf-8" }, "DetectedBodyType": "Json", "DetectedBodyTypeFromContentType": "String" }, "Response": { "StatusCode": 403, "Headers": { "Content-Type": [ "text/html" ], "Content-Length": [ "2345" ], "Server": [ "Microsoft-IIS/10.0" ], "Date": [ "Wed, 18 Dec 2019 13:38:52 GMT" ] }, "Body": "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <title>Web App - Unavailable</title>\r\n <style type=\"text/css\">\r\n html {\r\n height: 100%;\r\n width: 100%;\r\n }\r\n\r\n #feature {\r\n width: 960px;\r\n margin: 95px auto 0 auto;\r\n overflow: auto;\r\n }\r\n\r\n #content {\r\n font-family: \"Segoe UI\";\r\n font-weight: normal;\r\n font-size: 22px;\r\n color: #ffffff;\r\n float: left;\r\n width: 460px;\r\n margin-top: 68px;\r\n margin-left: 0px;\r\n vertical-align: middle;\r\n }\r\n\r\n #content h1 {\r\n font-family: \"Segoe UI Light\";\r\n color: #ffffff;\r\n font-weight: normal;\r\n font-size: 60px;\r\n line-height: 48pt;\r\n width: 800px;\r\n }\r\n\r\n p a, p a:visited, p a:active, p a:hover {\r\n color: #ffffff;\r\n }\r\n\r\n #content a.button {\r\n background: #0DBCF2;\r\n border: 1px solid #FFFFFF;\r\n color: #FFFFFF;\r\n display: inline-block;\r\n font-family: Segoe UI;\r\n font-size: 24px;\r\n line-height: 46px;\r\n margin-top: 10px;\r\n padding: 0 15px 3px;\r\n text-decoration: none;\r\n }\r\n\r\n #content a.button img {\r\n float: right;\r\n padding: 10px 0 0 15px;\r\n }\r\n\r\n #content a.button:hover {\r\n background: #1C75BC;\r\n }\r\n </style>\r\n</head>\r\n<body bgcolor=\"#00abec\">\r\n <div id=\"feature\">\r\n <div id=\"content\">\r\n <h1 id=\"unavailable\">Error 403 - This web app is stopped.</h1>\r\n <p id=\"tryAgain\">The web app you have attempted to reach is currently stopped and does not accept any requests. Please try to reload the page or visit it again soon.</p>\r\n <p id=\"toAdmin\">If you are the web app administrator, please find the common 403 error scenarios and resolution <a href=\"https://go.microsoft.com/fwlink/?linkid=2095007\" target=\"_blank\">here</a>. For further troubleshooting tools and recommendations, please visit <a href=\"https://portal.azure.com/\">Azure Portal</a>.</p>\r\n </div>\r\n </div>\r\n</body>\r\n</html>\r\n", "BodyEncoding": { "CodePage": 65001, "EncodingName": "Unicode (UTF-8)", "WebName": "utf-8" }, "DetectedBodyType": 1, "DetectedBodyTypeFromContentType": 1 }, "MappingGuid": "51223398-e68e-492a-ba05-0f32c2bc0d45", "RequestMatchResult": { "TotalScore": 1.0, "TotalNumber": 1, "IsPerfectMatch": true, "AverageTotalScore": 1.0, "MatchDetails": [ { "Name": "PathMatcher", "Score": 1.0 } ] } } ] ``` Do you have any idea why it caught the wrong mapping? Have I configured something wrong?
adam added the question label 2025-12-29 08:24:31 +01:00
adam closed this issue 2025-12-29 08:24:31 +01:00
Author
Owner

@StefH commented on GitHub (Dec 24, 2019):

Could it be related to the WildcardMatcher you define? (The IgnoreCase differs?)

Can you just try:

{
          "Name": "WildcardMatcher",
          "Pattern": "reports"
}

For all 3 mappings?
(No need to define a *)

@StefH commented on GitHub (Dec 24, 2019): Could it be related to the `WildcardMatcher` you define? (The IgnoreCase differs?) Can you just try: ``` { "Name": "WildcardMatcher", "Pattern": "reports" } ``` For all 3 mappings? (No need to define a `*`)
Author
Owner

@StefH commented on GitHub (Feb 25, 2020):

@gregoks Can this issue be closed?

@StefH commented on GitHub (Feb 25, 2020): @gregoks Can this issue be closed?
Author
Owner

@StefH commented on GitHub (Apr 26, 2020):

Closing...

@StefH commented on GitHub (Apr 26, 2020): Closing...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#235