cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.87k stars 3.18k forks source link

Websocket doesn't use SESSION cookie set by a cy.request #29398

Open Lexa-tech opened 6 months ago

Lexa-tech commented 6 months ago

Current behavior

Hello, I would like to open a WebSocket connection in a test file with the Native Javascript WebSocket API, but the authentication is failing. The WebSocket has to use a session cookie to authenticate to the server. The cookie is set by a previous cy.request to the login API, but it is not reused and added to the headers when I'm opening the Websocket connection. The domain of the Websocket is the same that the domain of the cookie. Is it a normal behaviour or a bug ?

Desired behavior

I expect that opening a Websocket connection could use the cookie, and have the same behaviour than in the Browser.

Test code to reproduce

cy.request to login to myserver.com cookie is set for the myserver.com domain (I can see it in the debug tools) new Websocket('wss://myserver.com') failed to authenticate because the cookie is not sent in the Headers.

Cypress Version

13.6.0

Node version

18.9.0

Operating System

Windows

Debug Logs

No response

Other

No response

cypress-app-bot commented 3 days ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.