cypress: Cypress + AWS Cognito Hosted UI = /error ?
Current behavior
We are testing a Web Application, and for some reason the AWS Cognito Sign In (using the Cognito Hosted UI) doesn’t work -> Cognito just redirects to /error instead of the given redirect_uri. (see screenshots)
This Sign In flow works flawlessly when directly using the application.
The most suspicious thing here is the Insecure HTTPS caused by cypress using its CypressProxyCA when running tests - I think there might be something wrong there?
We have tried adding the Amazon/CloudFront certificates but that doesn’t work because we need the corresponding Private Keys (which we don’t have of course).
Tried looking at the Cognito logs but there’s nothing useful there either.
Tried playing with other settings/configuration but nothing works.
Is there any solution to this, has anyone used AWS Cognito and Cypress in this way before?
Thanks in advance!
Desired behavior
We expect the Cognito Hosted UI - OAuth2.0 Authorization Code flow to work the same as it does when using the Web Application directly.
Test code to reproduce
.
Cypress Version
9.5.2
Other
No response
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 16 (5 by maintainers)
After more than two weeks of struggling to find a solution, I finally made it.
While inspecting the network requests made by Cypress during test execution, I noticed a warning in a request stating:
“This attempt to set a cookie via a Set-Cookie header was blocked because it had the ‘SameSite=Lax’ attribute but came from a cross-site response which was not the response to a top-level navigation.”
After some Googling, I found this blog post: https://www.tomoliver.net/posts/cypress-samesite-problem
By reproducing the steps provided, everything worked as expected.
Hope it helps!
Yes, I did, but it does not work. My problem is that the cognito POST request returns a 400 status code, the same issue OP is facing.
I’m wondering why this isn’t fixed yet. In my opinion the underlying bug is a major issue that probably holds back many people from using Cypress at all, when you can’t login through third-party providers using cookies.
I now made this workaround which seems to work for me:
same issue here, any solutions?