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 1 commit
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
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": {
"blocklistHosts": {
"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#blocklistHosts"
},
"modifyObstructiveCode": {
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/cypress/fixtures/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"cypressHostUrl": "http://localhost:2020",
"cypressEnv": "development",
"env": {},
"blacklistHosts": [
"blocklistHosts": [
"www.google-analytics.com",
"hotjar.com"
],
Expand Down Expand Up @@ -376,7 +376,7 @@
"from": "default",
"value": true
},
"blacklistHosts": {
"blocklistHosts": {
"from": "config",
"value": [
"www.google-analytics.com",
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-gui/cypress/integration/settings_spec.js
Original file line number Diff line number Diff line change
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', 'blocklistHosts').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 blocklistHosts', () => {
cy.contains('.line', 'blocklistHosts').contains('www.google-analytics.com, hotjar.com')
})

it('opens help link on click', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/network/lib/blacklist.ts
Original file line number Diff line number Diff line change
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, blocklistHosts) {
// normalize into flat array
blacklistHosts = [].concat(blacklistHosts)
blocklistHosts = [].concat(blocklistHosts)

urlToCheck = stripProtocolAndDefaultPorts(urlToCheck)

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

return _.find(blacklistHosts, matchUrl)
return _.find(blocklistHosts, matchUrl)
}
6 changes: 3 additions & 3 deletions packages/proxy/lib/http/request-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const RedirectToClientRouteIfNotProxied: RequestMiddleware = function () {
}

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

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

if (matches) {
this.res.set('x-cypress-matched-blacklisted-host', matches)
Expand Down
6 changes: 3 additions & 3 deletions packages/server/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ folders.push('componentFolder')
const configKeys = toWords(`\
animationDistanceThreshold fileServerFolder
baseUrl fixturesFolder
blacklistHosts
blocklistHosts
chromeWebSecurity
modifyObstructiveCode integrationFolder
env pluginsFile
Expand Down Expand Up @@ -119,7 +119,7 @@ const CONFIG_DEFAULTS = {
isTextTerminal: false,
reporter: 'spec',
reporterOptions: null,
blacklistHosts: null,
blocklistHosts: null,
clientRoute: '/__/',
xhrRoute: '/xhrs/',
socketIoRoute: '/__socket.io',
Expand Down Expand Up @@ -175,7 +175,7 @@ const CONFIG_DEFAULTS = {
const validationRules = {
animationDistanceThreshold: v.isNumber,
baseUrl: v.isFullyQualifiedUrl,
blacklistHosts: v.isStringOrArrayOfStrings,
blocklistHosts: v.isStringOrArrayOfStrings,
browsers: v.isValidBrowserList,
chromeWebSecurity: v.isBoolean,
configFile: v.isStringOrFalse,
Expand Down
6 changes: 3 additions & 3 deletions packages/server/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Server {

createServer (app, config, project, request, onWarning) {
return new Promise((resolve, reject) => {
const { port, fileServerFolder, socketIoRoute, baseUrl, blacklistHosts } = config
const { port, fileServerFolder, socketIoRoute, baseUrl, blocklistHosts } = config

this._server = http.createServer(app)

Expand Down Expand Up @@ -299,8 +299,8 @@ class Server {
// see if this matches - if so then
// we cannot allow it to make a direct
// connection
if (blacklistHosts && !isMatching) {
isMatching = blacklist.matches(urlToCheck, blacklistHosts)
if (blocklistHosts && !isMatching) {
isMatching = blacklist.matches(urlToCheck, blocklistHosts)

debug(`HTTPS request ${urlToCheck} matches blacklist?`, isMatching)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/e2e/1_blacklist_hosts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('e2e blacklist', () => {
}],
settings: {
baseUrl: 'http://localhost:3232',
blacklistHosts: 'localhost:3131',
blocklistHosts: 'localhost:3131',
},
})

Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/integration/http_requests_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,7 @@ describe('Routes', () => {
beforeEach(function () {
return this.setup({
config: {
blacklistHosts: [
blocklistHosts: [
'*.google.com',
'shop.apple.com',
'cypress.io',
Expand Down
14 changes: 7 additions & 7 deletions packages/server/test/unit/args_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('lib/util/args', () => {
const config = {
pageLoadTimeout: 10000,
waitForAnimations: false,
blacklistHosts: ['one.com', 'www.two.io'],
blocklistHosts: ['one.com', 'www.two.io'],
hosts: {
'foobar.com': '127.0.0.1',
},
Expand All @@ -211,15 +211,15 @@ describe('lib/util/args', () => {

// as mixed usage
const hosts = JSON.stringify(config.hosts)
const blacklistHosts = JSON.stringify(config.blacklistHosts)
const blocklistHosts = JSON.stringify(config.blocklistHosts)

options = this.setup(
'--config',
[
'pageLoadTimeout=10000',
'waitForAnimations=false',
`hosts=${hosts}`,
`blacklistHosts=${blacklistHosts}`,
`blocklistHosts=${blocklistHosts}`,
].join(','),

)
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('lib/util/args', () => {
context('.toObject', () => {
beforeEach(function () {
this.hosts = { a: 'b', b: 'c' }
this.blacklistHosts = ['a.com', 'b.com']
this.blocklistHosts = ['a.com', 'b.com']
this.specs = [
path.join(cwd, 'foo'),
path.join(cwd, 'bar'),
Expand All @@ -293,7 +293,7 @@ describe('lib/util/args', () => {
env: this.env,
hosts: this.hosts,
requestTimeout: 1234,
blacklistHosts: this.blacklistHosts,
blocklistHosts: this.blocklistHosts,
reporterOptions: {
foo: 'bar',
},
Expand All @@ -307,7 +307,7 @@ describe('lib/util/args', () => {
'--get-key',
'--env=foo=bar,baz=quux,bar=foo=quz',
'--config',
`requestTimeout=1234,blacklistHosts=${s(this.blacklistHosts)},hosts=${s(this.hosts)}`,
`requestTimeout=1234,blocklistHosts=${s(this.blocklistHosts)},hosts=${s(this.hosts)}`,
'--reporter-options=foo=bar',
'--spec=foo,bar,baz',
)
Expand All @@ -334,7 +334,7 @@ describe('lib/util/args', () => {
it('can transpose back to an array', function () {
const mergedConfig = JSON.stringify({
requestTimeout: this.config.requestTimeout,
blacklistHosts: this.blacklistHosts,
blocklistHosts: this.blocklistHosts,
hosts: this.hosts,
env: this.env,
reporterOptions: {
Expand Down
34 changes: 17 additions & 17 deletions packages/server/test/unit/config_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,27 +649,27 @@ describe('lib/config', () => {
})
})

context('blacklistHosts', () => {
context('blocklistHosts', () => {
it('passes if a string', function () {
this.setup({ blacklistHosts: 'google.com' })
this.setup({ blocklistHosts: 'google.com' })

return this.expectValidationPasses()
})

it('passes if an array of strings', function () {
this.setup({ blacklistHosts: ['google.com'] })
this.setup({ blocklistHosts: ['google.com'] })

return this.expectValidationPasses()
})

it('fails if not a string or array', function () {
this.setup({ blacklistHosts: 5 })
this.setup({ blocklistHosts: 5 })

return this.expectValidationFails('be a string or an array of strings')
})

it('fails if not an array of strings', function () {
this.setup({ blacklistHosts: [5] })
this.setup({ blocklistHosts: [5] })
this.expectValidationFails('be a string or an array of strings')

return this.expectValidationFails('the value was: `[5]`')
Expand Down Expand Up @@ -717,8 +717,8 @@ describe('lib/config', () => {
}
})

it('includes blacklistHosts', function () {
return this.includes('blacklistHosts')
it('includes blocklistHosts', function () {
return this.includes('blocklistHosts')
})
})

Expand Down Expand Up @@ -957,19 +957,19 @@ describe('lib/config', () => {
return this.defaults('supportFile', false, { supportFile: false })
})

it('blacklistHosts=null', function () {
return this.defaults('blacklistHosts', null)
it('blocklistHosts=null', function () {
return this.defaults('blocklistHosts', null)
})

it('blacklistHosts=[a,b]', function () {
return this.defaults('blacklistHosts', ['a', 'b'], {
blacklistHosts: ['a', 'b'],
it('blocklistHosts=[a,b]', function () {
return this.defaults('blocklistHosts', ['a', 'b'], {
blocklistHosts: ['a', 'b'],
})
})

it('blacklistHosts=a|b', function () {
return this.defaults('blacklistHosts', ['a', 'b'], {
blacklistHosts: ['a', 'b'],
it('blocklistHosts=a|b', function () {
return this.defaults('blocklistHosts', ['a', 'b'], {
blocklistHosts: ['a', 'b'],
})
})

Expand Down Expand Up @@ -1097,7 +1097,7 @@ describe('lib/config', () => {
projectId: { value: null, from: 'default' },
port: { value: 1234, from: 'cli' },
hosts: { value: null, from: 'default' },
blacklistHosts: { value: null, from: 'default' },
blocklistHosts: { value: null, from: 'default' },
browsers: { value: [], from: 'default' },
userAgent: { value: null, from: 'default' },
reporter: { value: 'json', from: 'cli' },
Expand Down Expand Up @@ -1172,7 +1172,7 @@ describe('lib/config', () => {
projectId: { value: 'projectId123', from: 'env' },
port: { value: 2020, from: 'config' },
hosts: { value: null, from: 'default' },
blacklistHosts: { value: null, from: 'default' },
blocklistHosts: { value: null, from: 'default' },
browsers: { value: [], from: 'default' },
userAgent: { value: null, from: 'default' },
reporter: { value: 'spec', from: 'default' },
Expand Down