Closed jakub-bao closed 4 years ago
Issue to allow sameSite
parameter for cy.setCookie()
is here: https://github.com/cypress-io/cypress/issues/2437
@jennifer-shehane Good. That might be a good first step. However, I think it still won't solve this issue. It might need extra work.
Here is the latest draft spec I can find for SameSite: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-05
It's still not a standard, but I guess it might as well be since the browsers are shipping it as stable :stuck_out_tongue:
The Cypress networking layer doesn't know about SameSite and will discard it from incoming requests that are manually handled (like cy.visit
and cy.request
). I'll work on implementing that along with the work required for #2437.
@flotwig
The Cypress networking layer doesn't know about SameSite and will discard it from incoming requests that are manually handled (like cy.visit and cy.request). I'll work on implementing that along with the work required for #2437.
Great! That sounds awesome! Thank you!
FYI, temporary workaround
: Switch to Electron browser.
Curious that Electron works for you, we're shipping Electron 8.1.1 which includes Chromium 80.0.3987.141, which is > the versions you mentioned using. I wonder why that is.
@flotwig the new SameSite behavior is not bound to a specific version, but rather "being rolled out to Chrome 80 Stable users through gradually increasing rollouts": https://www.chromium.org/updates/same-site
You can explicitely enable/disable the behavior in chrome://flags, though.
@jklingen Awesome! That's amazing.
I was running of Electron. But honestly Chrome is so much better for test running. Due to it's DevTools debugger. Electron has it too but let's be honest :)
For anyone experiencing this issue. You can temporarily disable
the new security features in chrome://flags
here:
The code for this is done in cypress-io/cypress#6778, but has yet to be released. We'll update this issue and reference the changelog when it's released.
Released in 4.3.0
.
This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v4.3.0, please open a new issue.
Facts:
cy.request
should persist cookies received in response headers. It does it just fine except this used case described below.Behaviour before chrome update (expected behaviour):
cy.request
to login to our server before running tests:This was just fine and it would set a cookie for chrome browser.
Then I can run my tests against a local instance of my app at
http://localhost:3003
while the app requests cross-origin resources fromdev.xxxx.org
. The serverdev.xxxx.org
knows I am logged in because with each request my Chrome provides session id cookie.Behavior after chrome update (current behavior)
cy.request
as in the case above. But cypress fails to persist the cookie due to the following Chrome security complains:Long story short: Chrome is complaining it can't store my session id cookie because it's missing
SameSite=None and Secure
attributes.The problem is that the attributes are NOT missing. Look at raw output here:
Conclusions
I believe that cypress swallows the
Same-Site
attribute while persisting cookies fromcy.request
A hint is is also that
cy.setCookie
is completely missingSame-Site
parameter:Temporary solution
Versions
80.0.3987.122
or80.0.3987.132
. It was fine with earlier versions of Chrome including (80.*)