DevExpress / testcafe

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

Basic HTTP auth doesn't work with Chrome native automation #8192

Closed anthonyferroHU closed 3 weeks ago

anthonyferroHU commented 1 month ago

What is your Scenario?

Tests that run with .httpAuth can't run on Chrome with native automation

What is the Current behavior?

All of my tests require basic auth to access apps in lower environments. After updating Testcafe to version 3+, these tests get stuck and hang forever because basic auth no longer works. They only run correctly when adding the --disable-native-automation flag.

What is the Expected behavior?

According to the Testcafe docs, it's expected that the NTLM protocol will not work with native automation, but there is no mention of limitations on basic http auth, therefore I expect basic auth to work with native automation.

What is the public URL of the test page? (attach your complete example)

no public URLs, hence the need for basic auth

What is your TestCafe test code?

.httpAuth({ username: authUsername, password: authPwd, });

^ basic auth username & password is set at the fixture level of all tests

Your complete configuration file

{ "src": "*-spec.js", "concurrency": 1, "debugOnFail": false, "skipJsErrors": true, "disableMultipleWindows": true, "screenshots": { "path": "./testscreenshots", "takeOnFails": true, "thumbnails": false } }

Your complete test report

no reports; the test hangs until I manually have to kill it

Screenshots

Screenshot 2024-05-14 at 1 52 24 PM

Steps to Reproduce

Run tests that require basic HTTP auth in Chrome 124 / Testcafe 3.6.0 with native automation enabled. Issue is same with headless and non-headless chrome.

TestCafe version

3.6.0

Node.js version

18.14

Command-line arguments

testcafe chrome -c 1 tests/path/to/test.js --skip-js-errors --skip-uncaught-errors

Browser name(s) and version(s)

Chrome 124.0.0.0

Platform(s) and version(s)

Locally on macOS Ventura 13 and also on Amazon Linux- aws/codebuild/amazonlinux2-x86_64-standard:5.0

Other

No response

github-actions[bot] commented 1 month ago

Thank you for submitting a bug report. We would love to help you investigate the issue. Please share a simple code example that reliably reproduces the bug. For more information, read the following article: How To Create a Minimal Working Example When You Submit an Issue. We look forward to your response.

anthonyferroHU commented 1 month ago

@Bayheck you can't try to run any test on any page that requires basic auth with the testcafe/node/chrome versions I provided?

Bayheck commented 1 month ago

Hello, I tried to emulate your usage scenario and did not encounter any issues with

httpAuth

That is why I am asking for a minimal working example.

github-actions[bot] commented 1 month ago

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

anthonyferroHU commented 1 month ago

@Bayheck I found a some more info when comparing my app's basic auth with this sample page that does work with Testcafe. Sample page: https://authenticationtest.com/HTTPAuth/ (Username= user, Password= pass)

1) The sample page returns a body, the app I'm testing does not

$ curl -s https://authenticationtest.com/HTTPAuth/ | wc -c
2933

$ curl -s https://my.app.io/ | wc -c
0

2) The sample page has an uppercase header to prompt for basic auth, passes in a realm and has a response message; the app I'm testing has a lowercase header, no realm and no response message

$ curl -sI https://authenticationtest.com/HTTPAuth/ | grep uth
HTTP/1.0 401 Unauthorized
WWW-Authenticate: Basic 
realm="u=User,p=Pass"

$ curl -sI https://my.app.io/
HTTP/2 401
server: CloudFront
date: Mon, 20 May 2024 15:16:19 GMT
content-length: 0
www-authenticate: Basic

The actual basic auth headers do work the same though

$ echo -n user:pass | base64
dXNlcjpwYXNz
$ curl -Is -H "Authorization: Basic dXNlcjpwYXNz" https://authenticationtest.com/HTTPAuth/
HTTP/1.1 302 Found

$ echo -n hu-dev:c31b32 | base64
aHUtZGV2OmMzMWIzMg==
$ curl -sI -H "Authorization: Basic aHUtZGV2OmMzMWIzMg==" https://my.app.io/
HTTP/2 200

Hopefully this helps. Again, Testcafe's basic auth setting works perfectly with my app's basic auth when running with native automation disabled.

Bayheck commented 1 month ago

Thank you for the information. Unfortunately, it's difficult to determine the exact cause of the issue without reproducing it. Please share a minimal working example that illustrates the issue.

anthonyferroHU commented 1 month ago

@Bayheck do you mind checking the Testcafe source code around native .httpAuth to see if Testcafe expects (or doesn't expect) either of the things I mentioned while I work on building an example?

Bayheck commented 1 month ago

Thank you for your understanding. I will get back to this issue once we have a working example. 

github-actions[bot] commented 1 month ago

Thank you for submitting a bug report. We would love to help you investigate the issue. Please share a simple code example that reliably reproduces the bug. For more information, read the following article: How To Create a Minimal Working Example When You Submit an Issue. We look forward to your response.

github-actions[bot] commented 3 weeks ago

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.