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

fix: Ensure basic auth headers are set on extra target requests #28387

Merged
merged 4 commits into from Nov 27, 2023

Conversation

chrisbreiding
Copy link
Contributor

Additional details

Fixes a regression caused by #28188, which cut down the request middleware a bit too much. The authorization header for basic auth set through cy.visit() was not being carried through for extra tabs.

PR Tasks

packages/driver/cypress/e2e/cypress/downloads.cy.ts Outdated Show resolved Hide resolved
})

// NOTE: webkit opens a new window and doesn't download the file
it('downloads basic auth protected file that opens in a new tab', { browser: '!webkit' }, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this assert that a new window was opened successfully rather than skipping it in webkit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having a new window open isn't the desired behavior, so I would hesitate to codify that behavior. It's supposed to download the file, but it seems that doesn't work in webkit for some reason. Might be something we fix in the future, but I'd say it's out of scope for this bug fix.

@@ -52,6 +52,7 @@ const ExtractCypressMetadataHeaders: RequestMiddleware = function () {
delete this.req.headers['x-cypress-is-from-extra-target']

this.onlyRunMiddleware([
'MaybeSetBasicAuthHeaders',
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 really want to attach basic auth to all requests in the new target? The download use-case seems like the exception not the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we would only attach if the origins match, correct? So, that's probably fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, they have to cy.visit() the origin with the credentials first

@chrisbreiding chrisbreiding merged commit 650d5cb into develop Nov 27, 2023
82 of 84 checks passed
@chrisbreiding chrisbreiding deleted the issue-28350-new-tab-auth branch November 27, 2023 21:28
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 5, 2023

Released in 13.6.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.6.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress 13.5.1 - Header not transmited to new tabs open in chromium navigator
3 participants