From 27e8c817d34a9ac70ff840d45938d16d3a225736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?La=C3=ADs=20Tomaz?= <41899092+laiscoolblue@users.noreply.github.com> Date: Mon, 13 Jul 2020 10:46:19 +0200 Subject: [PATCH] Rename configuration option blacklistHosts (#7622) Co-authored-by: Jennifer Shehane Co-authored-by: Brian Mann --- circle.yml | 12 +++++ cli/schema/cypress.schema.json | 4 +- .../desktop-gui/cypress/fixtures/config.json | 4 +- .../cypress/integration/settings_spec.js | 6 +-- .../integration/commands/agents_spec.js | 16 +++---- .../integration/commands/aliasing_spec.js | 8 ++-- packages/driver/src/cy/aliases.js | 4 +- packages/network/README.md | 2 +- .../network/lib/{blacklist.ts => blocked.ts} | 6 +-- packages/network/lib/index.ts | 4 +- .../{blacklist_spec.ts => blocked_spec.ts} | 10 ++--- packages/proxy/lib/http/request-middleware.ts | 16 +++---- .../test/unit/http/request-middleware.spec.ts | 2 +- ...st_hosts_spec.js => 1_block_hosts_spec.js} | 24 ++++------ packages/server/lib/browsers/firefox.ts | 2 +- packages/server/lib/config.js | 11 +++-- packages/server/lib/errors.js | 2 +- packages/server/lib/server.js | 15 ++++--- ...st_hosts_spec.js => 1_block_hosts_spec.js} | 7 +-- .../server/test/integration/cypress_spec.js | 44 +++++++++++-------- .../test/integration/http_requests_spec.js | 6 +-- ...ts_spec.coffee => block_hosts_spec.coffee} | 4 +- packages/server/test/unit/args_spec.js | 14 +++--- packages/server/test/unit/config_spec.js | 34 +++++++------- 24 files changed, 137 insertions(+), 120 deletions(-) rename packages/network/lib/{blacklist.ts => blocked.ts} (71%) rename packages/network/test/unit/{blacklist_spec.ts => blocked_spec.ts} (87%) rename packages/server/__snapshots__/{1_blacklist_hosts_spec.js => 1_block_hosts_spec.js} (83%) rename packages/server/test/e2e/{1_blacklist_hosts_spec.js => 1_block_hosts_spec.js} (82%) rename packages/server/test/support/fixtures/projects/e2e/cypress/integration/{blacklist_hosts_spec.coffee => block_hosts_spec.coffee} (91%) diff --git a/circle.yml b/circle.yml index 5ec3cc5ef3f2..64740734f74e 100644 --- a/circle.yml +++ b/circle.yml @@ -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: @@ -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: diff --git a/cli/schema/cypress.schema.json b/cli/schema/cypress.schema.json index c3d2ffb22876..9ab63fce9cb2 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": { + "blockHosts": { "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#blockHosts" }, "modifyObstructiveCode": { "type": "boolean", diff --git a/packages/desktop-gui/cypress/fixtures/config.json b/packages/desktop-gui/cypress/fixtures/config.json index f55c7483b7df..5da0c8d3e099 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": [ + "blockHosts": [ "www.google-analytics.com", "hotjar.com" ], @@ -376,7 +376,7 @@ "from": "default", "value": true }, - "blacklistHosts": { + "blockHosts": { "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..7f43548f3828 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', 'blockHosts').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 blockHosts', () => { + cy.contains('.line', 'blockHosts').contains('www.google-analytics.com, hotjar.com') }) it('opens help link on click', () => { diff --git a/packages/driver/cypress/integration/commands/agents_spec.js b/packages/driver/cypress/integration/commands/agents_spec.js index 0088dfc6c210..bff2ae3ea08f 100644 --- a/packages/driver/cypress/integration/commands/agents_spec.js +++ b/packages/driver/cypress/integration/commands/agents_spec.js @@ -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.`) }) }) }) @@ -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.`) }) }) }) diff --git a/packages/driver/cypress/integration/commands/aliasing_spec.js b/packages/driver/cypress/integration/commands/aliasing_spec.js index 3a88ff2d70fb..db17200a01cf 100644 --- a/packages/driver/cypress/integration/commands/aliasing_spec.js +++ b/packages/driver/cypress/integration/commands/aliasing_spec.js @@ -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) }) }) }) diff --git a/packages/driver/src/cy/aliases.js b/packages/driver/src/cy/aliases.js index 8bf2dff1c6ab..fe7db54847b8 100644 --- a/packages/driver/src/cy/aliases.js +++ b/packages/driver/src/cy/aliases.js @@ -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, '') @@ -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 } }) } } diff --git a/packages/network/README.md b/packages/network/README.md index df06bbe38812..5263862e391a 100644 --- a/packages/network/README.md +++ b/packages/network/README.md @@ -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 diff --git a/packages/network/lib/blacklist.ts b/packages/network/lib/blocked.ts similarity index 71% rename from packages/network/lib/blacklist.ts rename to packages/network/lib/blocked.ts index 1a6b7021ecba..1e59bbda5b91 100644 --- a/packages/network/lib/blacklist.ts +++ b/packages/network/lib/blocked.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, blockHosts) { // normalize into flat array - blacklistHosts = [].concat(blacklistHosts) + blockHosts = [].concat(blockHosts) urlToCheck = stripProtocolAndDefaultPorts(urlToCheck) @@ -14,5 +14,5 @@ export function matches (urlToCheck, blacklistHosts) { return minimatch(urlToCheck, hostMatcher) } - return _.find(blacklistHosts, matchUrl) + return _.find(blockHosts, matchUrl) } diff --git a/packages/network/lib/index.ts b/packages/network/lib/index.ts index f40984659a19..e9064ae0b3ab 100644 --- a/packages/network/lib/index.ts +++ b/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, diff --git a/packages/network/test/unit/blacklist_spec.ts b/packages/network/test/unit/blocked_spec.ts similarity index 87% rename from packages/network/test/unit/blacklist_spec.ts rename to packages/network/test/unit/blocked_spec.ts index 81e223b4f915..0e327503d490 100644 --- a/packages/network/test/unit/blacklist_spec.ts +++ b/packages/network/test/unit/blocked_spec.ts @@ -1,4 +1,4 @@ -import { blacklist } from '../..' +import { blocked } from '../..' import { expect } from 'chai' const hosts = [ @@ -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) diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index df9819330678..f8ab37cb6c00 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/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<{ @@ -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, }) @@ -149,7 +149,7 @@ export default { LogRequest, RedirectToClientRouteIfUnloaded, RedirectToClientRouteIfNotProxied, - EndRequestsToBlacklistedHosts, + EndRequestsToBlockedHosts, MaybeEndRequestWithBufferedResponse, StripUnsupportedAcceptEncoding, MaybeSetBasicAuthHeaders, diff --git a/packages/proxy/test/unit/http/request-middleware.spec.ts b/packages/proxy/test/unit/http/request-middleware.spec.ts index 5fb61b6839e9..07cd117c8754 100644 --- a/packages/proxy/test/unit/http/request-middleware.spec.ts +++ b/packages/proxy/test/unit/http/request-middleware.spec.ts @@ -8,7 +8,7 @@ describe('http/request-middleware', function () { 'LogRequest', 'RedirectToClientRouteIfUnloaded', 'RedirectToClientRouteIfNotProxied', - 'EndRequestsToBlacklistedHosts', + 'EndRequestsToBlockedHosts', 'MaybeEndRequestWithBufferedResponse', 'StripUnsupportedAcceptEncoding', 'MaybeSetBasicAuthHeaders', diff --git a/packages/server/__snapshots__/1_blacklist_hosts_spec.js b/packages/server/__snapshots__/1_block_hosts_spec.js similarity index 83% rename from packages/server/__snapshots__/1_blacklist_hosts_spec.js rename to packages/server/__snapshots__/1_block_hosts_spec.js index ddc788d39721..e96f050822b3 100644 --- a/packages/server/__snapshots__/1_blacklist_hosts_spec.js +++ b/packages/server/__snapshots__/1_block_hosts_spec.js @@ -1,4 +1,4 @@ -exports['e2e blacklist passes 1'] = ` +exports['e2e blockHosts passes 1'] = ` ==================================================================================================== @@ -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 @@ -33,18 +33,12 @@ 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) @@ -52,7 +46,7 @@ exports['e2e blacklist passes 1'] = ` 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 - - - diff --git a/packages/server/lib/browsers/firefox.ts b/packages/server/lib/browsers/firefox.ts index ff71136ba9de..f533955839e7 100644 --- a/packages/server/lib/browsers/firefox.ts +++ b/packages/server/lib/browsers/firefox.ts @@ -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 diff --git a/packages/server/lib/config.js b/packages/server/lib/config.js index a9dd933fa7dd..7e4f9aad5580 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 +blockHosts chromeWebSecurity modifyObstructiveCode integrationFolder env pluginsFile @@ -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 @@ -125,7 +126,7 @@ const CONFIG_DEFAULTS = { isTextTerminal: false, reporter: 'spec', reporterOptions: null, - blacklistHosts: null, + blockHosts: null, clientRoute: '/__/', xhrRoute: '/xhrs/', socketIoRoute: '/__socket.io', @@ -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, @@ -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: diff --git a/packages/server/lib/errors.js b/packages/server/lib/errors.js index 78153766d5cc..88b6676d6629 100644 --- a/packages/server/lib/errors.js +++ b/packages/server/lib/errors.js @@ -664,7 +664,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) { Learn more at https://on.cypress.io/screenshot-api` case 'RENAMED_CONFIG_OPTION': return stripIndent`\ - A configuration option you have supplied has been renamed. + The ${chalk.yellow(arg1)} configuration option you have supplied has been renamed. Please rename ${chalk.yellow(arg1)} to ${chalk.blue(arg2)}` case 'CANNOT_CONNECT_BASE_URL': diff --git a/packages/server/lib/server.js b/packages/server/lib/server.js index fab463c55a08..e1d0f2cbd03c 100644 --- a/packages/server/lib/server.js +++ b/packages/server/lib/server.js @@ -15,7 +15,7 @@ const compression = require('compression') const debug = require('debug')('cypress:server:server') const { agent, - blacklist, + blocked, concatStream, cors, uri, @@ -238,7 +238,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, blockHosts } = config this._server = http.createServer(app) @@ -291,16 +291,17 @@ class Server { // if we are currently matching then we're // not making a direct connection anyway // so we only need to check this if we - // have blacklist hosts and are not matching. + // have blocked hosts and are not matching. // - // if we have blacklisted hosts lets + // if we have blocked hosts lets // see if this matches - if so then // we cannot allow it to make a direct // connection - if (blacklistHosts && !isMatching) { - isMatching = blacklist.matches(urlToCheck, blacklistHosts) - debug(`HTTPS request ${urlToCheck} matches blacklist?`, isMatching) + if (blockHosts && !isMatching) { + isMatching = blocked.matches(urlToCheck, blockHosts) + + debug(`HTTPS request ${urlToCheck} matches blockHosts?`, isMatching) } // make a direct connection only if diff --git a/packages/server/test/e2e/1_blacklist_hosts_spec.js b/packages/server/test/e2e/1_block_hosts_spec.js similarity index 82% rename from packages/server/test/e2e/1_blacklist_hosts_spec.js rename to packages/server/test/e2e/1_block_hosts_spec.js index ae38f96f5f0d..946f656ff6b1 100644 --- a/packages/server/test/e2e/1_blacklist_hosts_spec.js +++ b/packages/server/test/e2e/1_block_hosts_spec.js @@ -14,7 +14,7 @@ const onServer = function (app) { }) } -describe('e2e blacklist', () => { +describe('e2e blockHosts', () => { e2e.setup({ servers: [{ port: 3131, @@ -25,13 +25,14 @@ describe('e2e blacklist', () => { }], settings: { baseUrl: 'http://localhost:3232', - blacklistHosts: 'localhost:3131', + blockHosts: 'localhost:3131', + video: false, }, }) it('passes', function () { return e2e.exec(this, { - spec: 'blacklist_hosts_spec.coffee', + spec: 'block_hosts_spec.coffee', snapshot: true, }) }) diff --git a/packages/server/test/integration/cypress_spec.js b/packages/server/test/integration/cypress_spec.js index 627fd351ab30..762541c514be 100644 --- a/packages/server/test/integration/cypress_spec.js +++ b/packages/server/test/integration/cypress_spec.js @@ -889,25 +889,31 @@ describe('lib/cypress', () => { }) }) - it('logs error and exits when using an old configuration option: trashAssetsBeforeHeadlessRuns', function () { - return cypress.start([ - `--run-project=${this.todosPath}`, - '--config=trashAssetsBeforeHeadlessRuns=false', - ]) - .then(() => { - this.expectExitWithErr('RENAMED_CONFIG_OPTION', 'trashAssetsBeforeHeadlessRuns') - this.expectExitWithErr('RENAMED_CONFIG_OPTION', 'trashAssetsBeforeRuns') - }) - }) - - it('logs error and exits when using an old configuration option: videoRecording', function () { - return cypress.start([ - `--run-project=${this.todosPath}`, - '--config=videoRecording=false', - ]) - .then(() => { - this.expectExitWithErr('RENAMED_CONFIG_OPTION', 'videoRecording') - this.expectExitWithErr('RENAMED_CONFIG_OPTION', 'video') + const renamedConfigs = [ + { + old: 'trashAssetsBeforeHeadlessRuns', + new: 'trashAssetsBeforeRuns', + }, + { + old: 'videoRecording', + new: 'video', + }, + { + old: 'blacklistHosts', + new: 'blockHosts', + }, + ] + + renamedConfigs.forEach(function (config) { + it(`logs error and exits when using an old configuration option: ${config.old}`, function () { + return cypress.start([ + `--run-project=${this.todosPath}`, + `--config=${config.old}=''`, + ]) + .then(() => { + this.expectExitWithErr('RENAMED_CONFIG_OPTION', config.old) + this.expectExitWithErr('RENAMED_CONFIG_OPTION', config.new) + }) }) }) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 30b44bea47e6..501aaaafe979 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -3727,11 +3727,11 @@ describe('Routes', () => { }) }) - context('blacklisted hosts', () => { + context('blocked hosts', () => { beforeEach(function () { return this.setup({ config: { - blacklistHosts: [ + blockHosts: [ '*.google.com', 'shop.apple.com', 'cypress.io', @@ -3744,7 +3744,7 @@ describe('Routes', () => { it('returns 503 and custom headers for all hosts', function () { const expectedHeader = (res, val) => { - expect(res.headers['x-cypress-matched-blacklisted-host']).to.eq(val) + expect(res.headers['x-cypress-matched-blocked-host']).to.eq(val) } return Promise.all([ diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/blacklist_hosts_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/block_hosts_spec.coffee similarity index 91% rename from packages/server/test/support/fixtures/projects/e2e/cypress/integration/blacklist_hosts_spec.coffee rename to packages/server/test/support/fixtures/projects/e2e/cypress/integration/block_hosts_spec.coffee index 47fecb9a4e39..16ee8ecc9552 100644 --- a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/blacklist_hosts_spec.coffee +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/block_hosts_spec.coffee @@ -1,5 +1,5 @@ -describe "blacklist", -> - it "forces blacklisted hosts to return 503", -> +describe "block hosts", -> + it "forces blocked hosts to return 503", -> cy .visit("http://localhost:3232") diff --git a/packages/server/test/unit/args_spec.js b/packages/server/test/unit/args_spec.js index c7d896434b84..ae9f7801f35f 100644 --- a/packages/server/test/unit/args_spec.js +++ b/packages/server/test/unit/args_spec.js @@ -241,7 +241,7 @@ describe('lib/util/args', () => { const config = { pageLoadTimeout: 10000, waitForAnimations: false, - blacklistHosts: ['one.com', 'www.two.io'], + blockHosts: ['one.com', 'www.two.io'], hosts: { 'foobar.com': '127.0.0.1', }, @@ -254,7 +254,7 @@ describe('lib/util/args', () => { // as mixed usage const hosts = JSON.stringify(config.hosts) - const blacklistHosts = JSON.stringify(config.blacklistHosts) + const blockHosts = JSON.stringify(config.blockHosts) options = this.setup( '--config', @@ -262,7 +262,7 @@ describe('lib/util/args', () => { 'pageLoadTimeout=10000', 'waitForAnimations=false', `hosts=${hosts}`, - `blacklistHosts=${blacklistHosts}`, + `blockHosts=${blockHosts}`, ].join(','), ) @@ -319,7 +319,7 @@ describe('lib/util/args', () => { context('.toObject', () => { beforeEach(function () { this.hosts = { a: 'b', b: 'c' } - this.blacklistHosts = ['a.com', 'b.com'] + this.blockHosts = ['a.com', 'b.com'] this.specs = [ path.join(cwd, 'foo'), path.join(cwd, 'bar'), @@ -336,7 +336,7 @@ describe('lib/util/args', () => { env: this.env, hosts: this.hosts, requestTimeout: 1234, - blacklistHosts: this.blacklistHosts, + blockHosts: this.blockHosts, reporterOptions: { foo: 'bar', }, @@ -350,7 +350,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,blockHosts=${s(this.blockHosts)},hosts=${s(this.hosts)}`, '--reporter-options=foo=bar', '--spec=foo,bar,baz', ) @@ -377,7 +377,7 @@ describe('lib/util/args', () => { it('can transpose back to an array', function () { const mergedConfig = JSON.stringify({ requestTimeout: this.config.requestTimeout, - blacklistHosts: this.blacklistHosts, + blockHosts: this.blockHosts, 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 e41d83f737ab..fcd74ce94ac4 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('blockHosts', () => { it('passes if a string', function () { - this.setup({ blacklistHosts: 'google.com' }) + this.setup({ blockHosts: 'google.com' }) return this.expectValidationPasses() }) it('passes if an array of strings', function () { - this.setup({ blacklistHosts: ['google.com'] }) + this.setup({ blockHosts: ['google.com'] }) return this.expectValidationPasses() }) it('fails if not a string or array', function () { - this.setup({ blacklistHosts: 5 }) + this.setup({ blockHosts: 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({ blockHosts: [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 blockHosts', function () { + return this.includes('blockHosts') }) }) @@ -957,19 +957,19 @@ describe('lib/config', () => { return this.defaults('supportFile', false, { supportFile: false }) }) - it('blacklistHosts=null', function () { - return this.defaults('blacklistHosts', null) + it('blockHosts=null', function () { + return this.defaults('blockHosts', null) }) - it('blacklistHosts=[a,b]', function () { - return this.defaults('blacklistHosts', ['a', 'b'], { - blacklistHosts: ['a', 'b'], + it('blockHosts=[a,b]', function () { + return this.defaults('blockHosts', ['a', 'b'], { + blockHosts: ['a', 'b'], }) }) - it('blacklistHosts=a|b', function () { - return this.defaults('blacklistHosts', ['a', 'b'], { - blacklistHosts: ['a', 'b'], + it('blockHosts=a|b', function () { + return this.defaults('blockHosts', ['a', 'b'], { + blockHosts: ['a', 'b'], }) }) @@ -1108,7 +1108,7 @@ describe('lib/config', () => { projectId: { value: null, from: 'default' }, port: { value: 1234, from: 'cli' }, hosts: { value: null, from: 'default' }, - blacklistHosts: { value: null, from: 'default' }, + blockHosts: { value: null, from: 'default' }, browsers: { value: [], from: 'default' }, userAgent: { value: null, from: 'default' }, reporter: { value: 'json', from: 'cli' }, @@ -1184,7 +1184,7 @@ describe('lib/config', () => { projectId: { value: 'projectId123', from: 'env' }, port: { value: 2020, from: 'config' }, hosts: { value: null, from: 'default' }, - blacklistHosts: { value: null, from: 'default' }, + blockHosts: { value: null, from: 'default' }, browsers: { value: [], from: 'default' }, userAgent: { value: null, from: 'default' }, reporter: { value: 'spec', from: 'default' },