Skip to content

Commit

Permalink
Rename all instances of blacklistHosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lais Tomaz committed Jun 8, 2020
1 parent 7597bf9 commit d966bdb
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 45 deletions.
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": {
"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
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
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
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
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
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
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
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
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
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
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

0 comments on commit d966bdb

Please sign in to comment.