使用空手道框架执行API测试时观察到的DNS错误

发布于 2025-01-22 18:54:15 字数 930 浏览 2 评论 0原文

在通过Karat执行API进行呼叫时,请在评论代理时观察DNS错误,但是如果我使用代理,则会返回401错误。

以下是以下代码:

功能文件代码:

    Background:
    *url baseUrl
    *def someData = { user:'"myemailid"','ContentType':'application/json',"Accept": "*/*"} 
    *headers someData

    Scenario: SomeScenario
    Given path '/clients'
    When method GET
    Then status 200

Karate Config :

    function()
    {
    karate.configure('proxy','ip address')
    var config = {
    baseUrl:'some url' 
    }
    return config;
    }

请求发送到服务器: debug com.intuit.karate-请求:

1 > GET url
1 > Accept: */*
1 > Accept-Encoding: gzip,deflate
1 > Content-Type: application/json
1 > Host: scrbmapdk007182:8080
1 > Proxy-Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_141)
1 > user: "myemail"

响应是502,与DNS错误一起

不确定我在哪里出错,因为它通过Postman工作。Requestsend与Postman相同

While performing a get call for an api via karat observing DNS error when the proxies im using is commented but if i use the proxy it returns 401 error.

Below is the Following Code :

Feature File Code :

    Background:
    *url baseUrl
    *def someData = { user:'"myemailid"','ContentType':'application/json',"Accept": "*/*"} 
    *headers someData

    Scenario: SomeScenario
    Given path '/clients'
    When method GET
    Then status 200

Karate Config :

    function()
    {
    karate.configure('proxy','ip address')
    var config = {
    baseUrl:'some url' 
    }
    return config;
    }

Request Send to the server:
DEBUG com.intuit.karate - request:

1 > GET url
1 > Accept: */*
1 > Accept-Encoding: gzip,deflate
1 > Content-Type: application/json
1 > Host: scrbmapdk007182:8080
1 > Proxy-Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_141)
1 > user: "myemail"

Response is 502 with along with DNS error

Not sure where im going wrong because it is working via postman .Request send is same as in postman

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏已如深秋| 2025-01-29 18:54:15

阅读文档: https://github.com/intuit/karate#configure

必须是在http中:https: uri表单,包括端口号(如果适用),包括:

karate.configure('proxy','http://myhost:80');

编辑:对于其他降落在此处的其他地方,除了http代理可能在图片中 - 另一个地方空手道的行为与邮递员的行为有所不同。代码>接受默认情况下的标题。

Read the docs: https://github.com/intuit/karate#configure

Has to be in http: or https: URI form including port number if applicable:

karate.configure('proxy','http://myhost:80');

EDIT: for others landing here, besides the fact that an HTTP proxy may be in the picture - another place where Karate behaves a bit differently than Postman is that Karate does not auto-send an Accept header by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文