diff --git a/cli/schema/cypress.schema.json b/cli/schema/cypress.schema.json index 4b69ddbcb589..db9a3fd0a368 100644 --- a/cli/schema/cypress.schema.json +++ b/cli/schema/cypress.schema.json @@ -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" @@ -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", diff --git a/packages/desktop-gui/cypress/fixtures/config.json b/packages/desktop-gui/cypress/fixtures/config.json index f55c7483b7df..9219d5060b3d 100644 --- a/packages/desktop-gui/cypress/fixtures/config.json +++ b/packages/desktop-gui/cypress/fixtures/config.json @@ -109,7 +109,7 @@ "cypressHostUrl": "http://localhost:2020", "cypressEnv": "development", "env": {}, - "blacklistHosts": [ + "blocklistHosts": [ "www.google-analytics.com", "hotjar.com" ], @@ -376,7 +376,7 @@ "from": "default", "value": true }, - "blacklistHosts": { + "blocklistHosts": { "from": "config", "value": [ "www.google-analytics.com", diff --git a/packages/desktop-gui/cypress/integration/settings_spec.js b/packages/desktop-gui/cypress/integration/settings_spec.js index 85eaf91711cd..a3c4a54aa681 100644 --- a/packages/desktop-gui/cypress/integration/settings_spec.js +++ b/packages/desktop-gui/cypress/integration/settings_spec.js @@ -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') @@ -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', () => { diff --git a/packages/network/lib/blacklist.ts b/packages/network/lib/blacklist.ts index 1a6b7021ecba..a36bd75edb88 100644 --- a/packages/network/lib/blacklist.ts +++ b/packages/network/lib/blacklist.ts @@ -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) @@ -14,5 +14,5 @@ export function matches (urlToCheck, blacklistHosts) { return minimatch(urlToCheck, hostMatcher) } - return _.find(blacklistHosts, matchUrl) + return _.find(blocklistHosts, matchUrl) } diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index 51dd2136efc1..5181504b8794 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -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) diff --git a/packages/server/lib/config.js b/packages/server/lib/config.js index a1bfbb39a2de..41f85eb3e1da 100644 --- a/packages/server/lib/config.js +++ b/packages/server/lib/config.js @@ -57,7 +57,7 @@ folders.push('componentFolder') const configKeys = toWords(`\ animationDistanceThreshold fileServerFolder baseUrl fixturesFolder -blacklistHosts +blocklistHosts chromeWebSecurity modifyObstructiveCode integrationFolder env pluginsFile @@ -119,7 +119,7 @@ const CONFIG_DEFAULTS = { isTextTerminal: false, reporter: 'spec', reporterOptions: null, - blacklistHosts: null, + blocklistHosts: null, clientRoute: '/__/', xhrRoute: '/xhrs/', socketIoRoute: '/__socket.io', @@ -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, diff --git a/packages/server/lib/server.js b/packages/server/lib/server.js index 02f7ccf206c5..3dade2ef8a4c 100644 --- a/packages/server/lib/server.js +++ b/packages/server/lib/server.js @@ -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) @@ -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) } diff --git a/packages/server/test/e2e/1_blacklist_hosts_spec.js b/packages/server/test/e2e/1_blacklist_hosts_spec.js index ae38f96f5f0d..b7ea65a1e955 100644 --- a/packages/server/test/e2e/1_blacklist_hosts_spec.js +++ b/packages/server/test/e2e/1_blacklist_hosts_spec.js @@ -25,7 +25,7 @@ describe('e2e blacklist', () => { }], settings: { baseUrl: 'http://localhost:3232', - blacklistHosts: 'localhost:3131', + blocklistHosts: 'localhost:3131', }, }) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index de88edfe633c..7434b39cd6c7 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -3731,7 +3731,7 @@ describe('Routes', () => { beforeEach(function () { return this.setup({ config: { - blacklistHosts: [ + blocklistHosts: [ '*.google.com', 'shop.apple.com', 'cypress.io', diff --git a/packages/server/test/unit/args_spec.js b/packages/server/test/unit/args_spec.js index a09082c159bf..2815354de1d0 100644 --- a/packages/server/test/unit/args_spec.js +++ b/packages/server/test/unit/args_spec.js @@ -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', }, @@ -211,7 +211,7 @@ 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', @@ -219,7 +219,7 @@ describe('lib/util/args', () => { 'pageLoadTimeout=10000', 'waitForAnimations=false', `hosts=${hosts}`, - `blacklistHosts=${blacklistHosts}`, + `blocklistHosts=${blocklistHosts}`, ].join(','), ) @@ -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'), @@ -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', }, @@ -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', ) @@ -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: { diff --git a/packages/server/test/unit/config_spec.js b/packages/server/test/unit/config_spec.js index aecaa46090af..ede7ba399a50 100644 --- a/packages/server/test/unit/config_spec.js +++ b/packages/server/test/unit/config_spec.js @@ -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]`') @@ -717,8 +717,8 @@ describe('lib/config', () => { } }) - it('includes blacklistHosts', function () { - return this.includes('blacklistHosts') + it('includes blocklistHosts', function () { + return this.includes('blocklistHosts') }) }) @@ -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'], }) }) @@ -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' }, @@ -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' },