【问题标题】:Karate framework symbol encoding in urlurl中的空手道框架符号编码
【发布时间】:2020-02-18 12:57:37
【问题描述】:

我有这个:

Background:
    * url 'http://localhost:15672/api/exchanges/%2F/my_exchange'

Scenario:
    Given path 'publish'

这里的问题是url被解析为:

http://localhost:15672/api/exchanges///my_exchange/publish

代替:

http://localhost:15672/api/exchanges/%2F/my_exchange/publish

谢谢

已编辑:

我会改进这个问题。

我在这里上传了一个非常简单的项目:https://github.com/italktothewind/karate-encoding

它有一个监听/bar/%2F/foo的wiremock

此功能有效:

Feature: Working example

    Scenario:
        Given url 'http://localhost:1081/bar/%2F/foo'
        When method get
        Then status 200

但是这个功能不起作用(我在项目中放了一个@ignore标志,所以它可以成功构建):

Feature: Non working example

Background:
    * url 'http://localhost:1081/bar/%2F'

Scenario:
    Given path 'foo'
    When get
    Then status 200

这两个功能的区别在于url和path的使用。

【问题讨论】:

    标签: karate


    【解决方案1】:

    为我工作:

    * url 'https://httpbin.org/anything/%2F/my_exchange'
    * method get
    

    在日志中:

    1 > GET https://httpbin.org/anything/%2F/my_exchange
    1 > Accept-Encoding: gzip,deflate
    1 > Connection: Keep-Alive
    1 > Host: httpbin.org
    1 > User-Agent: Apache-HttpClient/4.5.11 (Java/1.8.0_231)
    

    编辑:当你有非传统的 URL-s 时,空手道的一般建议是只使用 url(不要使用 path):https://stackoverflow.com/a/53638335/143475

    【讨论】:

    • 我在使用 karate-apache 和 karate-junit4 的 0.9.2 版时遇到问题
    • @italktothewind 遵循这个过程:github.com/intuit/karate/wiki/How-to-Submit-an-Issue
    • 我肯定有问题,当我可以构建一个最小的例子时我会提交一个问题,谢谢!
    • 我进行了更多研究,当您在后台使用 url 并在场景中使用路径(如问题中的示例)而不是直接在场景中使用 url(如此答案)时,就会出现问题/跨度>
    • @italktothewind 我不知道你在说什么
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 2018-03-02
    相关资源
    最近更新 更多