Karate framework symbol encoding in url

随声附和 提交于 2020-05-14 05:57:35

问题


I have this:

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

Scenario:
    Given path 'publish'

Problem here is that the url is being resolved as:

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

instead of:

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

Thanks

EDITED:

I will improve the question.

I uploaded a very simple project here: https://github.com/italktothewind/karate-encoding

It has a wiremock listening to /bar/%2F/foo

This feature is working:

Feature: Working example

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

But this feature is not working (I put an @ignore flag in the project so it can be built successfully):

Feature: Non working example

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

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

The difference between the two features is the use of url and path.


回答1:


Works for me:

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

And in the log:

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)

EDIT: when you have un-conventional URL-s the general recommendation in Karate is to use only the url (don't use path): https://stackoverflow.com/a/53638335/143475



来源:https://stackoverflow.com/questions/59975779/karate-framework-symbol-encoding-in-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!