DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 670 forks source link

t.request() with proxyless returning 400 #7609

Closed codambro closed 1 year ago

codambro commented 1 year ago

What is your Scenario?

Running API tests and trying to enable proxyless. Finding that the tests fail with 400 error in proxyless, but pass normally.

What is the Current behavior?

API requests fail:

{
  status: 400,
  statusText: undefined,
  headers: {
    server: 'awselb/2.0',
    date: 'Mon, 03 Apr 2023 14:50:36 GMT',
    'content-type': 'text/html',
    'content-length': '122',
    [Symbol(nodejs.http2.sensitiveHeaders)]: []
  },
  body: '<html>\r\n' +
    '<head><title>400 Bad Request</title></head>\r\n' +
    '<body>\r\n' +
    '<center><h1>400 Bad Request</h1></center>\r\n' +
    '</body>\r\n' +
    '</html>\r\n'
}

What is the Expected behavior?

API request succeed

What is your public website URL? (or attach your complete example)

See email

What is your TestCafe test code?

const token = "TOKEN";
const url = "URL";

fixture('Proxyless API test');

test("API Test", async t => {
    const resp = await t.request({
        method: "get",
        url: url,
        headers: {
            'x-risk-token': token,
            'accept': '*/*',
        }
    });
    console.log(resp);
    await t.expect(resp.status).eql(200);
});

Your complete configuration file

{
  "hostname": "localhost",
  "disablePageCaching": true,
  "skipUncaughtErrors": true,
  "skipJsErrors": true,
  "retryTestPages": true,
  "pageLoadTimeout": 60000,
  "pageRequestTimeout": 60000,
  "assertionTimeout": 90000,
  "proxyless": true
}

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Run test with t.request()

TestCafe version

2.5.0-rc.1

Node.js version

No response

Command-line arguments

testcafe chrome --config-file conf.json proxylessTest.ts

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

No response

aleks-pro commented 1 year ago

Hello @codambro ,

Thank you for reporting this issue. I reproduced it on my side. We will research it and update this thread once we have any results.

yuwoonil commented 1 year ago

Hello @aleks-pro this issue fixed in 2.5?

aleks-pro commented 1 year ago

Hello @yuwoonil ,

Not yet, we are working on this.

Artem-Babich commented 1 year ago

Hi,

The cause of this issue is the "method" property value. It is not valid because of the lowercase. This behavior is incorrect, and we will fix it. To resolve the issue now, please specify the method property as follows: method: 'GET'.

github-actions[bot] commented 1 year ago

Release v2.5.1-rc.1 addresses this.

github-actions[bot] commented 1 year ago

Release v2.5.1-rc.1 addresses this.