bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
54 stars 9 forks source link

cy.ntlmReset() is not working #210

Closed sebgamby closed 1 year ago

sebgamby commented 1 year ago

Hello,

My apologies for opening a second issue so soon. I am trying to use the function cy.ntlmlReset() in order to switch identities in the same feature (I am using cypress-cucumber-preprocessor). But I get a "socket hang up" error. The full Cypress error message is available in error.txt. I have also run the test with ntlm-proxy in DEBUG mode, I have recorded the output in ntlm-proxy-debug-output.txt. I have no issue when calling the method cy.ntml(...) and the behavior of the application under test shows that the authentication is successful. My tests use two different identities with different user roles and are working fine as long as I use a single identity by feature.

I am running the the test on Windows 10 with the following packages:

sebgamby commented 1 year ago

As extra information: The environment variables HTTP_PROXY and NO_PROXY are not set in the Powershell prompt where ntlm-proxy run My computer can access the company's active directory without having to go through a proxy

bjowes commented 1 year ago

cy.ntlmReset() will tear down all connections, somehow this does not play nicely with your test setup. As a workaround, could you try simply calling cy.ntlm() with the new credentials? This will overwrite the existing config if the same host is specified. It should also close any open connections to that host.

bjowes commented 1 year ago

Ok, I see the issue. The fact that you are setting cy.ntlm with the wildcard '*' makes all hosts considered as NTLM hosts. When the reset request comes in, this is also treated that way, which causes its socket to be terminated in the processing. I will fix this so that the ntlm proxy API port is never treated as a NTLM host.

bjowes commented 1 year ago

Try version 4.0.4