简体   繁体   English

在wiremock中匹配URL路径模式

[英]URL Path Pattern matching in wiremock

How does exactly wiremock matches the URL Path Pattern with encoded URLs? 精确线条如何将URL路径模式与编码URL相匹配? Do I need to save mapping with already encoded URL? 我是否需要使用已编码的URL保存映射? Here is what I tried for several hours and can't get it to working. 这是我几个小时的尝试,无法让它工作。

Mapping in wiremock 在wiremock中进行映射

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

I've already tried with different variants with encoded URL eg /Systems%20XYZ%20(ABC)/2016.10/aaa/bbb/api/ccc/customers/.* or even URL encoding the ( and ) in mappings but my request doesn't seems to be matching 我已经尝试过使用带编码URL的不同变体,例如/Systems%20XYZ%20(ABC)2016.10/aaa/bbb/api/ccc/customers/.*,甚至是编码(和)映射的URL,但我的请求没有似乎很匹配

What URI I tried to invoke the service against wiremock /Systems%20XYZ%20(ABC)/2016.10/aaa/bbb/api/ccc/customers/12345 我尝试调用针对wiremock /Systems%20XYZ%20(ABC)2016.10/aaa/bbb/api/ccc/customers/12345的服务的URI

/Systems XYZ (ABC)/2016.10/aaa/bbb/api/ccc/customers/.* Though, I assume Postman/browser will encode the spaces automatically. / Systems XYZ(ABC)/2016.10/aaa/bbb/api/ccc/customers /.*虽然我假设Postman /浏览器会自动编码空格。

Is there anything I'm missing here? 这里有什么我想念的吗? Have tried many combinations but did not seems to work. 尝试了很多组合,但似乎没有奏效。

When using WireMock.Net , you should be able to use this example: 使用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"
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM