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

Rename configuration option blacklistHosts #7622

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c22541d
Rename all instances of blacklistHosts
laiscoolblue Jun 8, 2020
52e68d5
Update code around blacklistHosts to use blocklist terminology
jennifer-shehane Jun 9, 2020
567ebd5
Recapture snapshot for new blocklist files
jennifer-shehane Jun 9, 2020
ef155d0
Merge branch 'develop' into rename-blacklisthosts
jennifer-shehane Jun 15, 2020
1cf3fb1
Deprecate blacklistHosts instead of breaking - show warning
jennifer-shehane Jun 15, 2020
966f21b
don't set default for deprecated key
jennifer-shehane Jun 15, 2020
9350251
make error less specific so it matches without ansi code
jennifer-shehane Jun 15, 2020
1712c5c
Update blacklistHosts snapshot, set them both to no video (unecessary)
jennifer-shehane Jun 15, 2020
c7c1c6f
Go back to breaking change for blacklistHosts removal.
jennifer-shehane Jun 23, 2020
987cc6f
rename blacklistHosts to more active voice blockHosts
jennifer-shehane Jun 26, 2020
192081c
Merge branch 'v5.0-release' into rename-blacklisthosts
jennifer-shehane Jul 6, 2020
d7af362
skip running external project job because this is an external PR with…
brian-mann Jul 10, 2020
f098cd8
Merge branch 'develop' into rename-blacklisthosts
brian-mann Jul 11, 2020
0a8b935
Merge branch 'v5.0-release' into rename-blacklisthosts
brian-mann Jul 11, 2020
ff75384
add correct branch to ignore
brian-mann Jul 11, 2020
103de09
Merge branch 'v5.0-release' into rename-blacklisthosts
brian-mann Jul 13, 2020
a2badd7
Merge branch 'v5.0-release' into rename-blacklisthosts
brian-mann Jul 13, 2020
5cbf5c0
go github go
brian-mann Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions circle.yml
Expand Up @@ -1590,6 +1590,12 @@ linux-workflow: &linux-workflow
- test-kitchensink:
requires:
- build
filters:
branches:
ignore:
## TODO: remove this upon merging the PR
- rename-blacklisthosts
- pull/7622
- test-kitchensink-against-staging:
context: test-runner:record-tests
filters:
Expand Down Expand Up @@ -1640,6 +1646,12 @@ linux-workflow: &linux-workflow
requires:
- build-binary
- build-npm-package
filters:
branches:
ignore:
## TODO: remove this upon merging the PR
- rename-blacklisthosts
- pull/7622
- test-binary-against-recipe-pull-request:
name: Test TypeScript recipe
filters:
Expand Down
4 changes: 2 additions & 2 deletions cli/schema/cypress.schema.json
Expand Up @@ -175,7 +175,7 @@
"default": null,
"description": "Enables you to override the default user agent the browser sends in all request headers. User agent values are typically used by servers to help identify the operating system, browser, and browser version. See User-Agent MDN Documentation for example user agent values here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent"
},
"blacklistHosts": {
"blockHosts": {
"type": [
"string",
"array"
Expand All @@ -184,7 +184,7 @@
"type": "string"
},
"default": null,
"description": "A String or Array of hosts that you wish to block traffic for. Please read the notes for examples on using this https://on.cypress.io/configuration#blacklistHosts"
"description": "A String or Array of hosts that you wish to block traffic for. Please read the notes for examples on using this https://on.cypress.io/configuration#blockHosts"
},
"modifyObstructiveCode": {
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/cypress/fixtures/config.json
Expand Up @@ -109,7 +109,7 @@
"cypressHostUrl": "http://localhost:2020",
"cypressEnv": "development",
"env": {},
"blacklistHosts": [
"blockHosts": [
"www.google-analytics.com",
"hotjar.com"
],
Expand Down Expand Up @@ -376,7 +376,7 @@
"from": "default",
"value": true
},
"blacklistHosts": {
"blockHosts": {
"from": "config",
"value": [
"www.google-analytics.com",
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-gui/cypress/integration/settings_spec.js
Expand Up @@ -154,7 +154,7 @@ describe('Settings', () => {
cy.get('@config-vars')
.contains('span', 'Electron').parent('span').should('have.class', 'plugin')

cy.contains('span', 'blacklistHosts').parents('div').first().find('span').first().click()
cy.contains('span', 'blockHosts').parents('div').first().find('span').first().click()
cy.get('@config-vars')
.contains('span', 'www.google-analytics.com').parent('span').should('have.class', 'config')

Expand Down Expand Up @@ -207,8 +207,8 @@ describe('Settings', () => {
cy.get('.line').contains('*.foobar.com, *.bazqux.com')
})

it('displays "array" values for blacklistHosts', () => {
cy.contains('.line', 'blacklistHosts').contains('www.google-analytics.com, hotjar.com')
it('displays "array" values for blockHosts', () => {
cy.contains('.line', 'blockHosts').contains('www.google-analytics.com, hotjar.com')
})

it('opens help link on click', () => {
Expand Down
16 changes: 8 additions & 8 deletions packages/driver/cypress/integration/commands/agents_spec.js
Expand Up @@ -352,11 +352,11 @@ describe('src/cy/commands/agents', () => {
}).to.throw('`cy.as()` cannot be passed an empty string.')
})

_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blacklist) => {
it(`throws on a blacklisted word: ${blacklist}`, () => {
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (reserved) => {
it(`throws on a reserved word: ${reserved}`, () => {
expect(() => {
cy.stub().as(blacklist)
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blacklist}\`. This word is reserved.`)
cy.stub().as(reserved)
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${reserved}\`. This word is reserved.`)
})
})
})
Expand Down Expand Up @@ -433,11 +433,11 @@ describe('src/cy/commands/agents', () => {
}).to.throw('`cy.as()` cannot be passed an empty string.')
})

_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blacklist) => {
it(`throws on a blacklisted word: ${blacklist}`, () => {
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (reserved) => {
it(`throws on a reserved word: ${reserved}`, () => {
expect(() => {
cy.stub().as(blacklist)
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blacklist}\`. This word is reserved.`)
cy.stub().as(reserved)
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${reserved}\`. This word is reserved.`)
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions packages/driver/cypress/integration/commands/aliasing_spec.js
Expand Up @@ -232,16 +232,16 @@ describe('src/cy/commands/aliasing', () => {
cy.get('@my@Alias')
})

_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blacklist) => {
it(`throws on a blacklisted word: ${blacklist}`, (done) => {
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (reserved) => {
it(`throws on a reserved word: ${reserved}`, (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq(`\`cy.as()\` cannot be aliased as: \`${blacklist}\`. This word is reserved.`)
expect(err.message).to.eq(`\`cy.as()\` cannot be aliased as: \`${reserved}\`. This word is reserved.`)
expect(err.docsUrl).to.eq('https://on.cypress.io/as')

done()
})

cy.get('div:first').as(blacklist)
cy.get('div:first').as(reserved)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/aliases.js
Expand Up @@ -6,7 +6,7 @@ const aliasRe = /^@.+/
const aliasDisplayRe = /^([@]+)/
const requestXhrRe = /\.request$/

const blacklist = ['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect']
const reserved = ['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect']

const aliasDisplayName = (name) => {
return name.replace(aliasDisplayRe, '')
Expand Down Expand Up @@ -38,7 +38,7 @@ const validateAlias = (alias) => {
$errUtils.throwErrByPath('as.empty_string')
}

if (blacklist.includes(alias)) {
if (reserved.includes(alias)) {
return $errUtils.throwErrByPath('as.reserved_word', { args: { alias } })
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/network/README.md
Expand Up @@ -8,7 +8,7 @@ You can see a list of the modules exported from this package in [./lib/index.ts]

* `agent` is a HTTP/HTTPS [agent][1] with support for HTTP/HTTPS proxies and keepalive whenever possible
* `allowDestroy` can be used to wrap a `net.Server` to add a `.destroy()` method
* `blacklist` is a utility for matching glob blacklists
* `blocked` is a utility for matching blocked globs
* `concatStream` is a wrapper around [`concat-stream@1.6.2`][2] that makes it always yield a `Buffer`
* `connect` contains utilities for making network connections, including `createRetryingSocket`
* `cors` contains utilities for Cross-Origin Resource Sharing
Expand Down
Expand Up @@ -2,9 +2,9 @@ import _ from 'lodash'
import minimatch from 'minimatch'
import { stripProtocolAndDefaultPorts } from './uri'

export function matches (urlToCheck, blacklistHosts) {
export function matches (urlToCheck, blockHosts) {
// normalize into flat array
blacklistHosts = [].concat(blacklistHosts)
blockHosts = [].concat(blockHosts)

urlToCheck = stripProtocolAndDefaultPorts(urlToCheck)

Expand All @@ -14,5 +14,5 @@ export function matches (urlToCheck, blacklistHosts) {
return minimatch(urlToCheck, hostMatcher)
}

return _.find(blacklistHosts, matchUrl)
return _.find(blockHosts, matchUrl)
}
4 changes: 2 additions & 2 deletions packages/network/lib/index.ts
@@ -1,12 +1,12 @@
import agent from './agent'
import * as blacklist from './blacklist'
import * as blocked from './blocked'
import * as connect from './connect'
import * as cors from './cors'
import * as uri from './uri'

export {
agent,
blacklist,
blocked,
connect,
cors,
uri,
Expand Down
@@ -1,4 +1,4 @@
import { blacklist } from '../..'
import { blocked } from '../..'
import { expect } from 'chai'

const hosts = [
Expand All @@ -10,22 +10,22 @@ const hosts = [
]

const matchesStr = function (url, host, val) {
const m = blacklist.matches(url, host)
const m = blocked.matches(url, host)

expect(!!m).to.eq(val, `url: '${url}' did not pass`)
}

const matchesArray = function (url, val) {
const m = blacklist.matches(url, hosts)
const m = blocked.matches(url, hosts)

expect(!!m).to.eq(val, `url: '${url}' did not pass`)
}

const matchesHost = (url, host) => {
expect(blacklist.matches(url, hosts)).to.eq(host)
expect(blocked.matches(url, hosts)).to.eq(host)
}

describe('lib/blacklist', () => {
describe('lib/blocked', () => {
it('handles hosts, ports, wildcards', () => {
matchesArray('https://mail.google.com/foo', true)
matchesArray('https://shop.apple.com/bar', true)
Expand Down
16 changes: 8 additions & 8 deletions packages/proxy/lib/http/request-middleware.ts
@@ -1,6 +1,6 @@
import _ from 'lodash'
import debugModule from 'debug'
import { blacklist, cors } from '@packages/network'
import { blocked, cors } from '@packages/network'
import { HttpMiddleware } from './'

export type RequestMiddleware = HttpMiddleware<{
Expand Down Expand Up @@ -46,15 +46,15 @@ const RedirectToClientRouteIfNotProxied: RequestMiddleware = function () {
this.next()
}

const EndRequestsToBlacklistedHosts: RequestMiddleware = function () {
const { blacklistHosts } = this.config
const EndRequestsToBlockedHosts: RequestMiddleware = function () {
const { blockHosts } = this.config

if (blacklistHosts) {
const matches = blacklist.matches(this.req.proxiedUrl, blacklistHosts)
if (blockHosts) {
const matches = blocked.matches(this.req.proxiedUrl, blockHosts)

if (matches) {
this.res.set('x-cypress-matched-blacklisted-host', matches)
debug('blacklisting request %o', {
this.res.set('x-cypress-matched-blocked-host', matches)
debug('blocking request %o', {
url: this.req.proxiedUrl,
matches,
})
Expand Down Expand Up @@ -149,7 +149,7 @@ export default {
LogRequest,
RedirectToClientRouteIfUnloaded,
RedirectToClientRouteIfNotProxied,
EndRequestsToBlacklistedHosts,
EndRequestsToBlockedHosts,
MaybeEndRequestWithBufferedResponse,
StripUnsupportedAcceptEncoding,
MaybeSetBasicAuthHeaders,
Expand Down
2 changes: 1 addition & 1 deletion packages/proxy/test/unit/http/request-middleware.spec.ts
Expand Up @@ -8,7 +8,7 @@ describe('http/request-middleware', function () {
'LogRequest',
'RedirectToClientRouteIfUnloaded',
'RedirectToClientRouteIfNotProxied',
'EndRequestsToBlacklistedHosts',
'EndRequestsToBlockedHosts',
'MaybeEndRequestWithBufferedResponse',
'StripUnsupportedAcceptEncoding',
'MaybeSetBasicAuthHeaders',
Expand Down
@@ -1,4 +1,4 @@
exports['e2e blacklist passes 1'] = `
exports['e2e blockHosts passes 1'] = `

====================================================================================================

Expand All @@ -7,18 +7,18 @@ exports['e2e blacklist passes 1'] = `
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (blacklist_hosts_spec.coffee) │
│ Searched: cypress/integration/blacklist_hosts_spec.coffee │
│ Specs: 1 found (block_hosts_spec.coffee)
│ Searched: cypress/integration/block_hosts_spec.coffee
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: blacklist_hosts_spec.coffee (1 of 1)
Running: block_hosts_spec.coffee (1 of 1)


blacklist
✓ forces blacklisted hosts to return 503
block hosts
✓ forces blocked hosts to return 503


1 passing
Expand All @@ -33,26 +33,20 @@ exports['e2e blacklist passes 1'] = `
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true
│ Video: false
│ Duration: X seconds │
│ Spec Ran: blacklist_hosts_spec.coffee │
│ Spec Ran: block_hosts_spec.coffee
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/blacklist_hosts_spec.coffee.mp4 (X second)


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ blacklist_hosts_spec.coffee XX:XX 1 1 - - - │
│ ✔ block_hosts_spec.coffee XX:XX 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 1 1 - - -

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/firefox.ts
Expand Up @@ -190,7 +190,7 @@ const defaultPreferences = {
// Do not wait for the notification button security delay
'security.notification_enable_delay': 0,

// Ensure blocklist updates do not hit the network
// Ensure blocked updates do not hit the network
'services.settings.server': '',

// Do not automatically fill sign-in forms with known usernames and
Expand Down
11 changes: 7 additions & 4 deletions packages/server/lib/config.js
Expand Up @@ -57,7 +57,7 @@ folders.push('componentFolder')
const configKeys = toWords(`\
animationDistanceThreshold fileServerFolder
baseUrl fixturesFolder
blacklistHosts
blockHosts
chromeWebSecurity
modifyObstructiveCode integrationFolder
env pluginsFile
Expand Down Expand Up @@ -89,8 +89,9 @@ firefoxGcInterval\
// experimentalComponentTesting
configKeys.push('componentFolder')

// Deprecated and retired public configuration properties
// Breaking public configuration properties, will error
const breakingConfigKeys = toWords(`\
blacklistHosts
videoRecording
screenshotOnHeadlessFailure
trashAssetsBeforeHeadlessRuns
Expand Down Expand Up @@ -125,7 +126,7 @@ const CONFIG_DEFAULTS = {
isTextTerminal: false,
reporter: 'spec',
reporterOptions: null,
blacklistHosts: null,
blockHosts: null,
clientRoute: '/__/',
xhrRoute: '/xhrs/',
socketIoRoute: '/__socket.io',
Expand Down Expand Up @@ -182,7 +183,7 @@ const CONFIG_DEFAULTS = {
const validationRules = {
animationDistanceThreshold: v.isNumber,
baseUrl: v.isFullyQualifiedUrl,
blacklistHosts: v.isStringOrArrayOfStrings,
blockHosts: v.isStringOrArrayOfStrings,
browsers: v.isValidBrowserList,
chromeWebSecurity: v.isBoolean,
configFile: v.isStringOrFalse,
Expand Down Expand Up @@ -249,6 +250,8 @@ const validateNoBreakingConfig = (cfg) => {
return errors.throw('RENAMED_CONFIG_OPTION', key, 'trashAssetsBeforeRuns')
case 'videoRecording':
return errors.throw('RENAMED_CONFIG_OPTION', key, 'video')
case 'blacklistHosts':
return errors.throw('RENAMED_CONFIG_OPTION', key, 'blockHosts')
case 'experimentalGetCookiesSameSite':
return errors.warning('EXPERIMENTAL_SAMESITE_REMOVED')
default:
Expand Down