mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-12 18:29:53 -05:00
0547d65a2a
* remove experimentalSkipDomainInjection, add and deprecate injectDocumentDomain * remove experimentalSkipDomainInjection, add injectDocumentDomain * begin rethreading domain injection * complete document domain transition * move some cookie specs to separate test run * origin and privileged commands with default docdom inject * fix privileged channel when injecting document domain * rm unnecessary .getOrigin abstraction in cors lib * move remote-states in prep for refactor Replace Conditional with Polymorphism * refactor remote states to strategy pattern * cookie commands work as expected w cross origin bridge on different origins * some origin tests updated * run tests with document domain enabled * run tests actually * use correct config, swap conditional * check-ts * inject documetn domain for webkit tests * do not exec injectDocumetnDomain in parallel * fix ServerBase construction in tests to include cfg now * pass cfg to ServerBase * improved integration tests * remove document domain checks for all server integration specs - will add injectDocumentDomain cases * tests for injecting document domain when configured to * square away server integration tests * ensure cookies are set correctly, potentially * errors pkg snapshots * fix config tests * fixing config tests * somewhat improves tests for cors policies in packages/network * fix ts err in server-base * enable injectDocumentDomain for cy in cy tests * fix Policy type ref * refactor cypress-schematic ct spec to be less prone to timeouts * run vite-dev-server tests with injectDocumentDomain * rm document domain assertion from page_loading system test * add system tests that test with injectDocumentDomain and others that test with cy.origin * fix results_spec snapshot * update experimentalSkipDomainInjection system test * different behavior for certain net_stubbing tests based on injectDocumentDomain or not * fix ts * extract origin key logic from remote states, for now * move server-base and response-middleware over to new pattern * WIP - reentry * fix build, remove console.log * check-ts * fix spec frame injection * remove injection for localhost * mostly fix vite-dev-server app integration tests * fix codeframe in certain cases in chrome * drop internal stack frames from stacks intended for determining code frame data * some improvements to vite ct error codeframes * fix proxy unit tests to use document domain injection util class * rm .only * fix all vite ct error specs * rm console.log * slight refactor to util class to make easier to test * fix refactor - missing rename in files.js * several tests do not set testingtype in config, so just check against component instead of checking for e2e * revert changes to getInvocationDetails to see if that breaks tests * re-enable stack stripping in invocation details for chrome * new snapshots with more accurate invocation details * test for same-site cross-origin cookie behavior * ignore window.top ts errors * revert forcing injectDocumentDomain in vite-dev-server cy config * fix normalized whitespace for firefox "loading_failed" error * always trim trailing wsp from stack before appending additional content * force normalization of whitespace to three \n when adding additional stack details * normalize wsp between stack and additional stack to "\n \n" in firefox * remove stack_utils attempt at normalizing wsp * various cleanup: remove commented console logs, add more detailed comments * add on links to error messages * remove experimentalSkipDomainInjection from exported type defs * Update system-tests/test/experimental_skip_domain_injection_spec.ts Co-authored-by: Bill Glesias <bglesias@gmail.com> * Update packages/driver/cypress/e2e/e2e/origin/cookie_misc.cy.ts Co-authored-by: Bill Glesias <bglesias@gmail.com> * no need to coerce a boolean value to a booleanc * export base config from primary cypress config in driver for use in inject-document-domain test subset * lift experimentalSkipDomainInjection breaking option to root * rollback config/options changes * rm invalid comment * use hostname instead of origin to create cookie from automation cookie * clarify stack regex in results_spec * lint * take a stab at the changelog entries for this * Update cli/CHANGELOG.md Co-authored-by: Ryan Manuel <ryanm@cypress.io> * Update cli/CHANGELOG.md Co-authored-by: Ryan Manuel <ryanm@cypress.io> * reenable locally-failing test * changelog * snapshot updatesfor experimental skip domain injection err msg * remove packageManager declaration in package.json --------- Co-authored-by: Bill Glesias <bglesias@gmail.com> Co-authored-by: Jennifer Shehane <jennifer@cypress.io> Co-authored-by: Ryan Manuel <ryanm@cypress.io>
135 lines
2.6 KiB
TypeScript
135 lines
2.6 KiB
TypeScript
import cors from 'cors'
|
|
import parser from 'cookie-parser'
|
|
import session from 'express-session'
|
|
import systemTests from '../lib/system-tests'
|
|
|
|
const onServer = function (app) {
|
|
app.use(parser())
|
|
|
|
app.use((req, res, next) => {
|
|
console.log('** REQUEST HEADERS ARE', req.url, req.headers)
|
|
|
|
return next()
|
|
})
|
|
|
|
const getIndex = () => {
|
|
return `\
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
<ul>
|
|
<li>
|
|
<a href="http://help.foobar.com:2292">switch to http://help.foobar.com</a>
|
|
</li>
|
|
</ul>
|
|
</body>
|
|
</html>\
|
|
`
|
|
}
|
|
|
|
const getText = (text) => {
|
|
return `\
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
<h1>${text}</h1>
|
|
</body>
|
|
</html>\
|
|
`
|
|
}
|
|
|
|
const applySession = session({
|
|
name: 'secret-session',
|
|
secret: 'secret',
|
|
cookie: {
|
|
sameSite: true,
|
|
},
|
|
}) as Function
|
|
|
|
app.get('/htmlCookies', (req, res) => {
|
|
const {
|
|
cookie,
|
|
} = req.headers
|
|
|
|
return res.send(`<html><div id='cookie'>${cookie}</div></html>`)
|
|
})
|
|
|
|
app.get('/cookies*', cors({ origin: true, credentials: true }), (req, res) => {
|
|
return res.json({
|
|
cookie: req.headers['cookie'],
|
|
parsed: req.cookie,
|
|
})
|
|
})
|
|
|
|
app.get('/redirect', (req, res) => {
|
|
return res.redirect('http://www.foobar.com:2292/cookies')
|
|
})
|
|
|
|
app.get('/domainRedirect', (req, res) => {
|
|
return res.redirect('http://www.foobar.com:2292/htmlCookies')
|
|
})
|
|
|
|
return app.get('*', (req, res, next) => {
|
|
res.set('Content-Type', 'text/html')
|
|
|
|
const getHtml = () => {
|
|
let h
|
|
|
|
switch ((h = req.get('host'))) {
|
|
case 'www.foobar.com:2292':
|
|
return getIndex()
|
|
|
|
case 'help.foobar.com:2292':
|
|
return getText('Help')
|
|
|
|
case 'session.foobar.com:2292':
|
|
applySession(req, res, next)
|
|
|
|
return getText('Session')
|
|
|
|
case 'domain.foobar.com:2292':
|
|
res.cookie('nomnom', 'good', {
|
|
domain: '.domain.foobar.com',
|
|
})
|
|
|
|
return getText('Domain')
|
|
|
|
case 'qa.sub.foobar.com:2292': case 'staging.sub.foobar.com:2292':
|
|
return getText('Nested Subdomains')
|
|
|
|
default:
|
|
throw new Error(`Host: '${h}' not recognized`)
|
|
}
|
|
}
|
|
|
|
return res.send(getHtml())
|
|
})
|
|
}
|
|
|
|
describe('e2e subdomain', () => {
|
|
systemTests.setup({
|
|
servers: {
|
|
port: 2292,
|
|
onServer,
|
|
},
|
|
})
|
|
|
|
systemTests.it('passes', {
|
|
browser: 'chrome', // TODO(webkit): fix+unskip
|
|
spec: 'subdomain.cy.js',
|
|
snapshot: true,
|
|
config: {
|
|
hosts: {
|
|
'*.foobar.com': '127.0.0.1',
|
|
},
|
|
e2e: {
|
|
injectDocumentDomain: true,
|
|
},
|
|
},
|
|
})
|
|
})
|