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

chore: [Multi-origin] Correctly find the spec bridge if chromeWebSecurity set to false. #21117

Merged
merged 3 commits into from
Apr 18, 2022

Conversation

mjhenkes
Copy link
Member

  • Closes

User facing changelog

n/a

Additional details

If chromeWebSecurity is set to false we can't rely on a security error to identify the correct spec bridge.

This PR adds some check to verify we are on the correct origin policy for the spec bridge.

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?
  • Have new configuration options been added to the cypress.schema.json?

@mjhenkes mjhenkes added the topic: cy.origin Problems or enhancements related to cy.origin command label Apr 18, 2022
@mjhenkes mjhenkes self-assigned this Apr 18, 2022
@mjhenkes mjhenkes requested a review from a team as a code owner April 18, 2022 17:49
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 18, 2022

Thanks for taking the time to open a PR!

@mjhenkes mjhenkes removed the request for review from a team April 18, 2022 17:49
@cypress
Copy link

cypress bot commented Apr 18, 2022



Test summary

20731 0 258 4Flakiness 3


Run details

Project cypress
Status Passed
Commit 653988b
Started Apr 18, 2022 8:24 PM
Ended Apr 18, 2022 8:41 PM
Duration 16:18 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/integration/cypress/proxy-logging_spec.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second
2 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second
3 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

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

packages/runner/injection/multi-domain.js Outdated Show resolved Hide resolved
@@ -198,6 +198,15 @@ describe('cy.origin', () => {
.should('equal', 'Welcome TJohnson')
})

it('finds the correct spec bridge even if a previous spec bridge host is a subset of the current host', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Given the PR title, I expect this test or a few tests to explicitly set chromeWebSecurity: false. Given we can't update that mid-test, it seems like a system-test should have been added to validate this??

Copy link
Member Author

Choose a reason for hiding this comment

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

The 'positive' case of the code is tested for each origin. We verify the port, protocol, and that the host ends with the host from the spec bridge. You are correct that the 'negative' is not tested. I made the call that testing this case did not nessitate the cost of adding a system test (System tests seem expensive to me 🤷‍♂️ ). I can add a system test if the group disagrees with that reasoning.

Copy link
Contributor

Choose a reason for hiding this comment

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

I could see the possibility of users maybe having chromeWebSecurity set to false while experimenting with cy.origin if they are trying the command out in their test suite without trying to refactor the rest of their tests, though I don't think this would be a pattern we would want to encourage. IMO, The system test could prove valuable, which we could shed the cost of once we remove chromeWebSecurity.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated an existing system test for chromeWebSecurity to also test this case.

mjhenkes and others added 2 commits April 18, 2022 13:47
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
@mjhenkes mjhenkes requested a review from a team as a code owner April 18, 2022 20:19
@mjhenkes mjhenkes removed the request for review from a team April 18, 2022 20:19
@mjhenkes mjhenkes merged commit f02d750 into feature-multidomain Apr 18, 2022
@mjhenkes mjhenkes deleted the mo-cy-origin-correctly-find-spec-bridge branch April 18, 2022 21:24
Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

was a little late 😆

@@ -198,6 +198,15 @@ describe('cy.origin', () => {
.should('equal', 'Welcome TJohnson')
})

it('finds the correct spec bridge even if a previous spec bridge host is a subset of the current host', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I could see the possibility of users maybe having chromeWebSecurity set to false while experimenting with cy.origin if they are trying the command out in their test suite without trying to refactor the rest of their tests, though I don't think this would be a pattern we would want to encourage. IMO, The system test could prove valuable, which we could shed the cost of once we remove chromeWebSecurity.

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
Development

Successfully merging this pull request may close these issues.

4 participants