Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add modify obstructive user agent code for electron to strip el… #22958

Merged
merged 14 commits into from Jul 30, 2022

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Jul 27, 2022

User facing changelog

Modifies the Electron user agent to strip Cypress and Electron references when the experimentalModifyObstructiveThirdPartyCode flag is enabled.

Additional details

The goal here is to update the user agent to appear more chrome like. This should work around currently obstructive authentication mechanisms, currently Google with Electron and avoid 403s. The fix hear was tested on Windows 10 with Electron 18, Linux Mint 22 with Electron 18, and MacOS Monterey with Electron 18. The user agent looks to be edited appropriately and is no longer 403ed by Google

Steps to test

run test-unit inside the server package to run the electron unit tests. run the user_agent_override cypress test inside the driver with the experimentalModifyObstructiveThirdPartyCode flag set to true

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

@AtofStryker AtofStryker added the topic: cy.origin Problems or enhancements related to cy.origin command label Jul 27, 2022
@AtofStryker AtofStryker self-assigned this Jul 27, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 27, 2022

Thanks for taking the time to open a PR!

@@ -0,0 +1,50 @@
// @see https://github.com/cypress-io/cypress/issues/22953
// We modify the user agent to strip cypress and electron out of the user agent string to appear more chrome-like
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to strip out cypress? I thought it wasn't causing any issues and only electron was? Or are we just stripping out all non-standard parts of the referrer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just stripping out non standard parts of the user agent. Seems weird to keep it in there but currently there aren't ill adverse side effects with keeping it as far as we know

@cypress
Copy link

cypress bot commented Jul 28, 2022



Test summary

4885 0 79 0Flakiness 0


Run details

Project cypress
Status Passed
Commit 7084d4c
Started Jul 30, 2022 2:29 AM
Ended Jul 30, 2022 2:45 AM
Duration 15:13 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@AtofStryker AtofStryker marked this pull request as ready for review July 28, 2022 17:24
@AtofStryker AtofStryker requested a review from a team as a code owner July 28, 2022 17:24
@AtofStryker AtofStryker requested review from chrisbreiding, emilyrohrbough, mjhenkes and mschile and removed request for a team July 28, 2022 17:24

beforeEach(function () {
userAgent = ''
electron._getUserAgent.callsFake(() => userAgent)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing a callsFake over returns since userAgent is assigned dynamically in the test.

packages/server/lib/browsers/electron.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cy.origin Problems or enhancements related to cy.origin command
Projects
None yet
5 participants