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: improve server side cookie handling via more accurate top simulation #23728

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cce7e5a
chore: modify xhr-fetch-requests to handle onload and prep for use in…
AtofStryker Sep 6, 2022
5465608
feat: add patches for fetch and xmlhttprequest
AtofStryker Sep 6, 2022
96174b3
feat: add X-Cypress-Request header in extension
AtofStryker Sep 6, 2022
667fee8
feat: add X-Cypress-Request header in CDP
AtofStryker Sep 6, 2022
37d322b
feat: add X-Cypress-Request header in electron
AtofStryker Sep 6, 2022
1dc2206
test: add correct cookie_behavior assertions before work on server
AtofStryker Sep 6, 2022
a38ddc6
add types to be used in the server
AtofStryker Sep 6, 2022
f8be17f
wip: refactor cors package to correct origin functions and add same s…
AtofStryker Sep 6, 2022
b4c33fd
feat: add top-simulation package with samesite and simulation calcula…
AtofStryker Sep 7, 2022
10eeaa2
feat: add socket code to server-base (no tests here) to be used in re…
AtofStryker Sep 7, 2022
ff3075e
feat: add shouldAttachAndSetCookies function and tests
AtofStryker Sep 7, 2022
f6d42c9
add the ExtractRequestedWithAndCredentialsIfApplicable middleware
AtofStryker Sep 7, 2022
afd2598
feat: add attach cookie logic to requests based on xhr/fetch requests
AtofStryker Sep 7, 2022
8cddd3b
feat: add attaching cookies to response logic w/ tests
AtofStryker Sep 7, 2022
56f35dc
fix: only attach cookies if coming from the AUTFrame or is same-origi…
AtofStryker Sep 9, 2022
8eca005
chore: rename getOriginPolicy to getSuperDomainOriginPolicy as the me…
AtofStryker Sep 9, 2022
cb8c26d
feat: allow for spec bridge to either match specific origin policy or…
AtofStryker Sep 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/driver/cypress/e2e/commands/location.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('src/cy/commands/location', () => {
context('#location', () => {
it('returns the location object', () => {
cy.location().then((loc) => {
expect(loc).to.have.keys(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomain', 'toString'])
expect(loc).to.have.keys(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomainOriginPolicy', 'superDomain', 'toString'])
})
})

Expand Down Expand Up @@ -529,7 +529,7 @@ describe('src/cy/commands/location', () => {

expect(_.keys(consoleProps)).to.deep.eq(['Command', 'Yielded'])
expect(consoleProps.Command).to.eq('location')
expect(_.keys(consoleProps.Yielded)).to.deep.eq(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomain', 'toString'])
expect(_.keys(consoleProps.Yielded)).to.deep.eq(['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'originPolicy', 'superDomainOriginPolicy', 'superDomain', 'toString'])
})
})
})
Expand Down
56 changes: 53 additions & 3 deletions packages/driver/cypress/e2e/cypress/location.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('src/cypress/location', () => {
it('handles subdomains google', function () {
const str = this.setup('google').getOriginPolicy()

expect(str).to.eq('https://google.com')
expect(str).to.eq('https://www.google.com')
})

it('issue: #255 two domains in the url', function () {
Expand All @@ -243,20 +243,70 @@ describe('src/cypress/location', () => {
it('handles subdomains of private tlds in the public suffix', function () {
const str = this.setup('herokuSub').getOriginPolicy()

expect(str).to.eq('https://example.herokuapp.com')
expect(str).to.eq('https://foo.example.herokuapp.com')
})

it('falls back to dumb check when invalid tld', function () {
const str = this.setup('unknown').getOriginPolicy()

expect(str).to.eq('http://what.is.so.unknown')
})
})

context('#getSuperDomainOriginPolicy', () => {
it('handles ip addresses', function () {
const str = this.setup('local').getSuperDomainOriginPolicy()

expect(str).to.eq('http://127.0.0.1:8080')
})

it('handles 1 part localhost', function () {
const str = this.setup('users').getSuperDomainOriginPolicy()

expect(str).to.eq('http://localhost:2020')
})

it('handles 2 parts stack', function () {
const str = this.setup('stack').getSuperDomainOriginPolicy()

expect(str).to.eq('https://stackoverflow.com')
})

it('handles subdomains google', function () {
const str = this.setup('google').getSuperDomainOriginPolicy()

expect(str).to.eq('https://google.com')
})

it('issue: #255 two domains in the url', function () {
const str = this.setup('email').getSuperDomainOriginPolicy()

expect(str).to.eq('http://localhost:3500')
})

it('handles private tlds in the public suffix', function () {
const str = this.setup('heroku').getSuperDomainOriginPolicy()

expect(str).to.eq('https://example.herokuapp.com')
})

it('handles subdomains of private tlds in the public suffix', function () {
const str = this.setup('herokuSub').getSuperDomainOriginPolicy()

expect(str).to.eq('https://example.herokuapp.com')
})

it('falls back to dumb check when invalid tld', function () {
const str = this.setup('unknown').getSuperDomainOriginPolicy()

expect(str).to.eq('http://so.unknown')
})
})

context('.create', () => {
it('returns an object literal', () => {
const obj = Location.create(urls.cypress, urls.signin)
const keys = ['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'toString', 'originPolicy', 'superDomain']
const keys = ['auth', 'authObj', 'hash', 'href', 'host', 'hostname', 'origin', 'pathname', 'port', 'protocol', 'search', 'toString', 'originPolicy', 'superDomainOriginPolicy', 'superDomain']

expect(obj).to.have.keys(keys)
})
Expand Down
262 changes: 168 additions & 94 deletions packages/driver/cypress/e2e/e2e/origin/cookie_behavior.cy.ts

Large diffs are not rendered by default.

Loading