1

Wiremock 如何将 URL 路径模式与编码的 URL 完全匹配?我是否需要使用已编码的 URL 保存映射?这是我尝试了几个小时但无法正常工作的方法。

在wiremock中映射

"request": {
    "urlPathPattern": "/Systems XYZ (ABC)/2016.10/aaa/bbb/api/ccc/customers/.*",
    "method": "GET",

我已经尝试过使用编码 URL 的不同变体,例如 /Systems%20XYZ%20(ABC)/2016.10/aaa/bbb/api/ccc/customers/.* 甚至 URL 编码映射中的 ( 和 ) 但我的请求没有'似乎不匹配

我尝试针对wiremock /Systems%20XYZ%20(ABC)/2016.10/aaa/bbb/api/ccc/customers/12345 调用服务的URI

/Systems XYZ (ABC)/2016.10/aaa/bbb/api/ccc/customers/.* 不过,我认为 Postman/browser 会自动对空格进行编码。

我在这里有什么遗漏吗?尝试了许多组合,但似乎没有奏效。

4

1 回答 1

0

使用WireMock.Net时,您应该能够使用此示例:

{
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "RegexMatcher",
          "Pattern": "^/Systems XYZ (ABC)/2016.10/aaa/bbb/api/ccc/customers/.*$"
        }
      ]
    }
  },
  "Response": {
    "BodyAsJson": { "result": "test" },
    "Headers": {
      "Content-Type": "application/json"
    }
  }
}
于 2017-02-13T18:44:42.880 回答