bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 10 forks source link

Running a cypress/cypress-ntlm-auth test in a Concourse pipeline ends up freezing #260

Closed totomare closed 1 month ago

totomare commented 1 month ago

1) Context • I have a repository of a cypress/cypress-ntlm-auth project which contains a connection test • if i run the e2e test on the command line it runs correctly • for the same project I built a concourse pipeline and I launch with the bash script

 #!/bin/bash
 set -e
 pushd repo-project
 export NODE_TLS_REJECT_UNAUTHORIZED=0
 npm install --legacy-peer-deps
 DEBUG=cypress:plugin:ntlm-auth npx cypress-ntlm open --e2e --browser chrome

2) Settings • testing environment. Ubuntu 20.4 • I use docker cypress-docker-images with Cypress version 13.9.0 installed as well as Chrome brawser • in the package.json file I have

 "devDependencies": {
  ...
  "cypress-ntlm-auth": "^**4.1.7**",
   ...
 }

3) Error message

3.1 When I don't have the setting : export NODE_TLS_REJECT_UNAUTHORIZED=0 there is the error message

cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +6ms cypress-ntlm-auth: Certificate validation failed for "on.cypress.io". ECONNRESET cypress:plugin:ntlm-auth WARN: Certificate validation failed for "on.cypress.io". Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:218:20) { errno: -104, code: 'ECONNRESET', syscall: 'read' } +84ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +27ms

3.2 When I add the setting : export NODE_TLS_REJECT_UNAUTHORIZED=0 There is no more error but the Cypress launch process freezes. Never finishes

Full log file ...... selected worker: 8ce14745-8de9-44a3-9dcc-684bf40ca062 streaming volume for image from aa95f532-9651-411a-8020-ca45376f47f9 streaming volume repo-gabarit from 54b86493-9e0d-4dcb-8b78-5b62769cd88d /tmp/build/605746f4/repo-gabarit /tmp/build/605746f4 (node:13) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification. (Use node --trace-warnings ... to show where the warning was created) ....... added 797 packages, and audited 798 packages in 23s

....... cypress-ntlm-auth: NODE_TLS_REJECT_UNAUTHORIZED is set to 0. This disables all certificate checks and overrides any HTTPS_VALIDATION setting.   cypress:plugin:ntlm-auth Starting ntlm-proxy... +0ms   cypress:plugin:ntlm-auth NTLM auth config API listening on: http://127.0.0.1:46749 +4ms   cypress:plugin:ntlm-auth NTLM auth proxy listening on : http://127.0.0.1:38443 +225ms   cypress:plugin:ntlm-auth Startup done! +1ms   cypress:plugin:ntlm-auth {   cypress:plugin:ntlm-auth   configApiUrl: 'http://127.0.0.1:46749',   cypress:plugin:ntlm-auth   ntlmProxyUrl: 'http://127.0.0.1:38443'   cypress:plugin:ntlm-auth } +0ms   cypress:plugin:ntlm-auth Opening Cypress... +1ms 25h

DevTools listening on ws://127.0.0.1:44383/devtools/browser/39932edb-130c-4619-899b-d9a05a0731a7   cypress:plugin:ntlm-auth Tunnel to redirector.gvt1.com:443 +3s Missing baseUrl in compilerOptions. tsconfig-paths will be skipped   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +232ms   cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59766 to target http://localhost:33731/ +1ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +15ms   cypress:plugin:ntlm-auth Tunnel to r4---sn-t0a7lnee.gvt1.com:443 +55ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +1ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +2ms   cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59794 to target http://localhost:33731/ +0ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +2ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +2ms   cypress:plugin:ntlm-auth Tunnel to localhost:33731 +253ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +7ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +2ms   cypress:plugin:ntlm-auth Tunnel to localhost:33731 +21ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +5ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms   cypress:plugin:ntlm-auth Tunnel to registry.npmjs.org:443 +58ms   cypress:plugin:ntlm-auth Tunnel to download.cypress.io:443 +21ms   cypress:plugin:ntlm-auth client closed tunnel socket to  registry.npmjs.org:443 +111ms   cypress:plugin:ntlm-auth server closed tunnel socket to  registry.npmjs.org:443 +0ms   cypress:plugin:ntlm-auth server closed tunnel socket to  registry.npmjs.org:443 +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +6ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +18ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth client closed tunnel socket to  download.cypress.io:443 +44ms   cypress:plugin:ntlm-auth server closed tunnel socket to  download.cypress.io:443 +0ms   cypress:plugin:ntlm-auth server closed tunnel socket to  download.cypress.io:443 +0ms   cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +5ms   cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +75ms   cypress:plugin:ntlm-auth server closed tunnel socket to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth closing client tunnel to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth client closed tunnel socket to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth client closed tunnel socket to  on.cypress.io:443 +1ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +1ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +51ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +6ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +1ms   cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59846 to target http://localhost:33731/ +0ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +6ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +5ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +19ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +72ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +49ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +127ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +1ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +0ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +10ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +3ms   cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +66ms   cypress:plugin:ntlm-auth server closed tunnel socket to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth closing client tunnel to  on.cypress.io:443 +1ms   cypress:plugin:ntlm-auth client closed tunnel socket to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth client closed tunnel socket to  on.cypress.io:443 +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +1ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +25ms   cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms   cypress:plugin:ntlm-auth getTargetHost - host header  localhost:33731 +3ms   cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59846 due to socket.close +5s   cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59794 due to socket.close +1ms   cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59766 due to socket.close +96ms   cypress:plugin:ntlm-auth client closed tunnel socket to  r4---sn-t0a7lnee.gvt1.com:443 +2m   cypress:plugin:ntlm-auth server closed tunnel socket to  r4---sn-t0a7lnee.gvt1.com:443 +0ms   cypress:plugin:ntlm-auth server closed tunnel socket to  r4---sn-t0a7lnee.gvt1.com:443 +1ms   cypress:plugin:ntlm-auth server closed tunnel socket to  redirector.gvt1.com:443 +2m   cypress:plugin:ntlm-auth client closed tunnel socket to  redirector.gvt1.com:443 +15ms   cypress:plugin:ntlm-auth client closed tunnel socket to  redirector.gvt1.com:443 +0ms   cypress:plugin:ntlm-auth server closed tunnel socket to  redirector.gvt1.com:443 +0ms

bjowes commented 1 month ago

I’m not familiar with Concourse but other CI would generally require that the script uses cypress-ntlm run, not open. With open the cypress app is launched and it won’t close after finishing the tests.

As for the cert validation error, you could ignore it since it is not mandatory. Does similar messages appear for other domains?

/Björn W

Skickat från min iPhone

ons 31 juli 2024 kl. 03:25 skrev totomare @.***>:

1) Context • I have a repository of a cypress/cypress-ntlm-auth project which contains a connection test • if i run the e2e test on the command line it runs correctly • for the same project I built a concourse pipeline and I launch with the bash script

!/bin/bash

set -e pushd repo-project export NODE_TLS_REJECT_UNAUTHORIZED=0 npm install --legacy-peer-deps DEBUG=cypress:plugin:ntlm-auth npx cypress-ntlm open --e2e --browser chrome

2) Settings • testing environment. Ubuntu 20.4 • I use docker cypress-docker-images https://github.com/cypress-io/cypress-docker-images/tree/master with Cypress version 13.9.0 installed as well as Chrome brawser • in the package.json file I have

"devDependencies": { ... "cypress-ntlm-auth": "^4.1.7", ... }

3) Error message

3.1 When I don't have the setting : export NODE_TLS_REJECT_UNAUTHORIZED=0 there is the error message

cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +6ms cypress-ntlm-auth: Certificate validation failed for "on.cypress.io". ECONNRESET cypress:plugin:ntlm-auth WARN: Certificate validation failed for " on.cypress.io". Error: read ECONNRESET at TLSWrap.onStreamRead (node:internal/stream_base_commons:218:20) { errno: -104, code: 'ECONNRESET', syscall: 'read' } +84ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +27ms

3.2 When I add the setting : export NODE_TLS_REJECT_UNAUTHORIZED=0 There is no more error but the Cypress launch process freezes. Never finishes

Full log file ...... selected worker: 8ce14745-8de9-44a3-9dcc-684bf40ca062 streaming volume for image from aa95f532-9651-411a-8020-ca45376f47f9 streaming volume repo-gabarit from 54b86493-9e0d-4dcb-8b78-5b62769cd88d /tmp/build/605746f4/repo-gabarit /tmp/build/605746f4 (node:13) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification. (Use node --trace-warnings ... to show where the warning was created) ....... added 797 packages, and audited 798 packages in 23s

....... cypress-ntlm-auth: NODE_TLS_REJECT_UNAUTHORIZED is set to 0. This disables all certificate checks and overrides any HTTPS_VALIDATION setting. cypress:plugin:ntlm-auth Starting ntlm-proxy... +0ms cypress:plugin:ntlm-auth NTLM auth config API listening on: http://127.0.0.1:46749 +4ms cypress:plugin:ntlm-auth NTLM auth proxy listening on : http://127.0.0.1:38443 +225ms cypress:plugin:ntlm-auth Startup done! +1ms cypress:plugin:ntlm-auth { cypress:plugin:ntlm-auth configApiUrl: 'http://127.0.0.1:46749', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:38443' cypress:plugin:ntlm-auth } +0ms cypress:plugin:ntlm-auth Opening Cypress... +1ms 25h

DevTools listening on ws:// 127.0.0.1:44383/devtools/browser/39932edb-130c-4619-899b-d9a05a0731a7 cypress:plugin:ntlm-auth Tunnel to redirector.gvt1.com:443 +3s Missing baseUrl in compilerOptions. tsconfig-paths will be skipped cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +232ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59766 to target http://localhost:33731/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +15ms cypress:plugin:ntlm-auth Tunnel to r4---sn-t0a7lnee.gvt1.com:443 +55ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +1ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +2ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59794 to target http://localhost:33731/ +0ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +2ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +2ms cypress:plugin:ntlm-auth Tunnel to localhost:33731 +253ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +7ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +2ms cypress:plugin:ntlm-auth Tunnel to localhost:33731 +21ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +5ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms cypress:plugin:ntlm-auth Tunnel to registry.npmjs.org:443 +58ms cypress:plugin:ntlm-auth Tunnel to download.cypress.io:443 +21ms cypress:plugin:ntlm-auth client closed tunnel socket to registry.npmjs.org:443 +111ms cypress:plugin:ntlm-auth server closed tunnel socket to registry.npmjs.org:443 +0ms cypress:plugin:ntlm-auth server closed tunnel socket to registry.npmjs.org:443 +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +6ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +18ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth client closed tunnel socket to download.cypress.io:443 +44ms cypress:plugin:ntlm-auth server closed tunnel socket to download.cypress.io:443 +0ms cypress:plugin:ntlm-auth server closed tunnel socket to download.cypress.io:443 +0ms cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +5ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +75ms cypress:plugin:ntlm-auth server closed tunnel socket to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth closing client tunnel to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth client closed tunnel socket to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth client closed tunnel socket to on.cypress.io:443 +1ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +1ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +51ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +6ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:59846 to target http://localhost:33731/ +0ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +6ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +5ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +19ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +72ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +49ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +127ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +1ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +1ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +0ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +10ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +3ms cypress:plugin:ntlm-auth Tunnel to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: on.cypress.io:443 +66ms cypress:plugin:ntlm-auth server closed tunnel socket to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth closing client tunnel to on.cypress.io:443 +1ms cypress:plugin:ntlm-auth client closed tunnel socket to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth client closed tunnel socket to on.cypress.io:443 +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +1ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +25ms cypress:plugin:ntlm-auth Request to http://localhost:33731/ - pass on +0ms cypress:plugin:ntlm-auth getTargetHost - host header localhost:33731 +3ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59846 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59794 due to socket.close +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:59766 due to socket.close +96ms cypress:plugin:ntlm-auth client closed tunnel socket to r4---sn-t0a7lnee.gvt1.com:443 +2m cypress:plugin:ntlm-auth server closed tunnel socket to r4---sn-t0a7lnee.gvt1.com:443 +0ms cypress:plugin:ntlm-auth server closed tunnel socket to r4---sn-t0a7lnee.gvt1.com:443 +1ms cypress:plugin:ntlm-auth server closed tunnel socket to redirector.gvt1.com:443 +2m cypress:plugin:ntlm-auth client closed tunnel socket to redirector.gvt1.com:443 +15ms cypress:plugin:ntlm-auth client closed tunnel socket to redirector.gvt1.com:443 +0ms cypress:plugin:ntlm-auth server closed tunnel socket to redirector.gvt1.com:443 +0ms

— Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/260, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3HQVFTFPTW7EJ4GIJTZPA4JLAVCNFSM6AAAAABLXOP722VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTQOJSGI4DONI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

totomare commented 1 month ago

Hello @bjowes

Thanks for the quick response. I made some changes in the Concourse CI configuration part. I also changed the script as you suggested.

npx cypress-ntlm run --e2e --browser chrome

I eliminated export NODE_TLS_REJECT_UNAUTHORIZED=0

Everything is working properly now.

I also want to thank you for fixing the anomaly: Cannot perform handshake. Error: NTLM authentication failed #241. This allowed me to incorporate the plugin into the enterprise solution