bjowes / cypress-ntlm-auth

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

The cypress-ntlm-auth plugin must be loaded before using this method #116

Closed vinothnageswaran closed 4 years ago

vinothnageswaran commented 4 years ago

Hi ,

I get this error when I run cy.ntlmSso("https://url");

Error The cypress-ntlm-auth plugin must be loaded before using this method

Here are the logs:

cypress:plugin:ntlm-auth Adding localhost to NO_PROXY to disable localhost proxying +0ms cypress:plugin:ntlm-auth Adding 127.0.0.1 to NO_PROXY to disable localhost proxying +2ms cypress:plugin:ntlm-auth Existing proxy instance found, sending shutdown +1ms cypress:plugin:ntlm-auth Quit request failed, trying to delete the ports file: Error: connect ECONNREFUSED 127.0.0.1:52288 +2s cypress:plugin:ntlm-auth Ports file deleted +3ms cypress:plugin:ntlm-auth NTLM auth config API listening on port: 52732 +12ms cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 52733 +195ms cypress:plugin:ntlm-auth wrote C:\Users\nageva9\AppData\Roaming\cypress-ntlm-auth\cypress-ntlm-auth.port +18ms cypress:plugin:ntlm-auth Startup done! +16ms cypress:plugin:ntlm-auth { cypress:plugin:ntlm-auth configApiUrl: 'http://127.0.0.1:52732', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:52733' cypress:plugin:ntlm-auth } +5ms cypress:plugin:ntlm-auth Received alive +16s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:52746 to target https://download.cypress.io:443/ +16s cypress:plugin:ntlm-auth Request to https://download.cypress.io:443/ - pass on +24ms (node:115844) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification. cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:52746 due to socket.close +3s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:52753 to target http://URL:80/ +11s cypress:plugin:ntlm-auth Request to http://URL:80/ - pass on +10ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:52753 due to socket.close +1s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:52756 to target http://proxy-pages.bhpbilliton.net:80/ +9ms cypress:plugin:ntlm-auth Request to http://proxy-pages.80/ - pass on +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:52756 due to socket.close +1s

vinothnageswaran commented 4 years ago

I get the same error with or without running the corporate proxy.

bjowes commented 4 years ago

Quick tip, cy.ntlmSso should be called with hostname(s) only, so drop the https:// part.

tors 14 maj 2020 kl. 17:28 skrev vinothnageswaran <notifications@github.com

:

I get the same error with or without running the corporate proxy.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/116#issuecomment-628710170, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3FWXZ2EHFSPF6HY4STRRQEYPANCNFSM4NAZCFEQ .

-- /Björn W

Skickat från min iPhone

vinothnageswaran commented 4 years ago

Thanks for your response Bjowes The error still occurs

bjowes commented 4 years ago

Could you post new logs?

On Fri, May 15, 2020 at 3:10 AM vinothnageswaran notifications@github.com wrote:

Thanks for your response Bjowes The error still occurs

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/116#issuecomment-628966514, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3DIGU22F73FZ5ZSKLDRRSJA7ANCNFSM4NAZCFEQ .

vinothnageswaran commented 4 years ago

Hi Bjowes, Sorry for the delay.

cypress:plugin:ntlm-auth Existing proxy instance found, sending shutdown +0ms cypress:plugin:ntlm-auth Quit request failed, trying to delete the ports file: Error: connect ECONNREFUSED 127.0.0.1:52116 +2s cypress:plugin:ntlm-auth Ports file deleted +3ms cypress:plugin:ntlm-auth NTLM auth config API listening on port: 63568 +10ms cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 63569 +127ms cypress:plugin:ntlm-auth wrote C:\Users\nageva9\AppData\Roaming\cypress-ntlm-auth\cypress-ntlm-auth.port +7ms cypress:plugin:ntlm-auth Startup done! +0ms cypress:plugin:ntlm-auth { cypress:plugin:ntlm-auth configApiUrl: 'http://127.0.0.1:63568', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:63569' cypress:plugin:ntlm-auth } +0ms cypress:plugin:ntlm-auth Received alive +23s cypress:plugin:ntlm-auth Tunnel to download.cypress.io:443 +18s cypress:plugin:ntlm-auth client closed socket, closing tunnel to download.cypress.io:443 +1s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63598 to target http://iomest:80/ +4s cypress:plugin:ntlm-auth Request to http://iomest:80/ - pass on +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63598 due to socket.close +345ms cypress:plugin:ntlm-auth Tunnel to clientservices.googleapis.com:443 +9s cypress:plugin:ntlm-auth Tunnel to accounts.google.com:443 +12ms cypress:plugin:ntlm-auth Tunnel to clientservices.googleapis.com:443 +231ms cypress:plugin:ntlm-auth Tunnel to accounts.google.com:443 +121ms cypress:plugin:ntlm-auth Tunnel to chromestore.aternity.com:443 +85ms cypress:plugin:ntlm-auth Tunnel to chromestore.aternity.com:443 +185ms cypress:plugin:ntlm-auth Tunnel to update.googleapis.com:443 +2s cypress:plugin:ntlm-auth Tunnel to update.googleapis.com:443 +253ms cypress:plugin:ntlm-auth Tunnel to content-autofill.googleapis.com:443 +1s cypress:plugin:ntlm-auth Tunnel to content-autofill.googleapis.com:443 +253ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63675 to target http://irouomldkjse:80/ +2s cypress:plugin:ntlm-auth Request to http://irouomldkjse:80/ - pass on +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63676 to target http://emnlwtpttvf:80/ +2ms cypress:plugin:ntlm-auth Request to http://emnlwtpttvf:80/ - pass on +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63678 to target http://rakrpmkwfymsg:80/ +2ms cypress:plugin:ntlm-auth Request to http://rakrpmkwfymsg:80/ - pass on +2ms cypress:plugin:ntlm-auth Chrome startup HEAD request detected (host: emnlwtpttvf:80). Ignoring connection error. +3s cypress:plugin:ntlm-auth Chrome startup HEAD request detected (host: irouomldkjse:80). Ignoring connection error. +23ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: accounts.google.com:443 +56ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63675 due to socket.close +60ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63676 due to socket.close +2ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: update.googleapis.com:443 +637ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: clientservices.googleapis.com:443 +36ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: update.googleapis.com:443 +29ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: accounts.google.com:443 +280ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: clientservices.googleapis.com:443 +249ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: content-autofill.googleapis.com:443 +901ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: content-autofill.googleapis.com:443 +8ms cypress:plugin:ntlm-auth Chrome startup HEAD request detected (host: rakrpmkwfymsg:80). Ignoring connection error. +2s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63678 due to socket.close +11ms cypress:plugin:ntlm-auth client closed socket, closing tunnel to chromestore.aternity.com:443 +8s cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: chromestore.aternity.com:443 +9s cypress:plugin:ntlm-auth Tunnel to accounts.google.com:443 +753ms cypress:plugin:ntlm-auth Tunnel to accounts.google.com:443 +255ms cypress:plugin:ntlm-auth Tunnel to content-autofill.googleapis.com:443 +3s cypress:plugin:ntlm-auth Tunnel to content-autofill.googleapis.com:443 +252ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: accounts.google.com:443 +1s cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: accounts.google.com:443 +3s cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: chromestore.aternity.com:443 +135ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: content-autofill.googleapis.com:443 +22ms cypress:plugin:ntlm-auth Got ECONNRESET on PROXY_TO_SERVER_SOCKET, ignoring. Target: content-autofill.googleapis.com:443 +247ms

bjowes commented 4 years ago

I assume that iomest is the site you are trying to test, which requires Windows Authentication? From the logs, it seems that you never call cy.ntlmSso (or cy.ntlm) so the ntlm-proxy does not know of any hosts where Windows Authentication should be applied.

vinothnageswaran commented 4 years ago

Yes, I tried with both cy.ntlm and cy.ntlmSso. The issue is still the same.

vinothnageswaran commented 4 years ago

cy.ntlmSso(["iomest"]); cy.wait(3000); cy.visit("/"); cy.viewport(2000, 1500)

bjowes commented 4 years ago

The this is, the ntlm-proxy logs every configuration change (all calls to cy.ntlm and cy.ntlmSso), and there are no such lines in the log you pasted. So the ntlm-proxy is unaware of the target sites and does not attempt authentication.

Could you send a screenshot from the cypress window, so I can see the command log from cypress?

vinothnageswaran commented 4 years ago

image

vinothnageswaran commented 4 years ago

image

bjowes commented 4 years ago

Thanks. Well this shows that cypress is unaware of the plugin. Please double check that you added the recommended code to cypress/plugins/index.js, see the readme.

vinothnageswaran commented 4 years ago

Awesome. It works like a charm PS: I added the code in the wrong index file.

Thanks bjowes