Skip to content

Commit 52e68d5

Browse files
Update code around blacklistHosts to use blocklist terminology
1 parent c22541d commit 52e68d5

File tree

12 files changed

+37
-37
lines changed

12 files changed

+37
-37
lines changed

packages/driver/src/cy/aliases.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const aliasRe = /^@.+/
77
const aliasDisplayRe = /^([@]+)/
88
const requestXhrRe = /\.request$/
99

10-
const blacklist = ['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect']
10+
const blocklist = ['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect']
1111

1212
const aliasDisplayName = (name) => {
1313
return name.replace(aliasDisplayRe, '')
@@ -39,7 +39,7 @@ const validateAlias = (alias) => {
3939
$errUtils.throwErrByPath('as.empty_string')
4040
}
4141

42-
if (blacklist.includes(alias)) {
42+
if (blocklist.includes(alias)) {
4343
return $errUtils.throwErrByPath('as.reserved_word', { args: { alias } })
4444
}
4545
}

packages/driver/test/cypress/integration/commands/agents_spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ describe('src/cy/commands/agents', () => {
352352
}).to.throw('`cy.as()` cannot be passed an empty string.')
353353
})
354354

355-
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blacklist) => {
356-
it(`throws on a blacklisted word: ${blacklist}`, () => {
355+
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blocklist) => {
356+
it(`throws on a blocklisted word: ${blocklist}`, () => {
357357
expect(() => {
358-
cy.stub().as(blacklist)
359-
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blacklist}\`. This word is reserved.`)
358+
cy.stub().as(blocklist)
359+
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blocklist}\`. This word is reserved.`)
360360
})
361361
})
362362
})
@@ -433,11 +433,11 @@ describe('src/cy/commands/agents', () => {
433433
}).to.throw('`cy.as()` cannot be passed an empty string.')
434434
})
435435

436-
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blacklist) => {
437-
it(`throws on a blacklisted word: ${blacklist}`, () => {
436+
_.each(['test', 'runnable', 'timeout', 'slow', 'skip', 'inspect'], (blocklist) => {
437+
it(`throws on a blocklisted word: ${blocklist}`, () => {
438438
expect(() => {
439-
cy.stub().as(blacklist)
440-
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blacklist}\`. This word is reserved.`)
439+
cy.stub().as(blocklist)
440+
}).to.throw(`\`cy.as()\` cannot be aliased as: \`${blocklist}\`. This word is reserved.`)
441441
})
442442
})
443443
})

packages/driver/test/cypress/integration/commands/aliasing_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,16 @@ describe('src/cy/commands/aliasing', () => {
232232
cy.get('@my@Alias')
233233
})
234234

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

241241
done()
242242
})
243243

244-
cy.get('div:first').as(blacklist)
244+
cy.get('div:first').as(blocklist)
245245
})
246246
})
247247
})

packages/network/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You can see a list of the modules exported from this package in [./lib/index.ts]
88

99
* `agent` is a HTTP/HTTPS [agent][1] with support for HTTP/HTTPS proxies and keepalive whenever possible
1010
* `allowDestroy` can be used to wrap a `net.Server` to add a `.destroy()` method
11-
* `blacklist` is a utility for matching glob blacklists
11+
* `blocklist` is a utility for matching glob blocklists
1212
* `concatStream` is a wrapper around [`concat-stream@1.6.2`][2] that makes it always yield a `Buffer`
1313
* `connect` contains utilities for making network connections, including `createRetryingSocket`
1414
* `cors` contains utilities for Cross-Origin Resource Sharing
File renamed without changes.

packages/network/lib/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import agent from './agent'
2-
import * as blacklist from './blacklist'
2+
import * as blocklist from './blocklist'
33
import * as connect from './connect'
44
import * as cors from './cors'
55
import * as uri from './uri'
66

77
export {
88
agent,
9-
blacklist,
9+
blocklist,
1010
connect,
1111
cors,
1212
uri,

packages/network/test/unit/blacklist_spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { blacklist } from '../..'
1+
import { blocklist } from '../..'
22
import { expect } from 'chai'
33

44
const hosts = [
@@ -10,22 +10,22 @@ const hosts = [
1010
]
1111

1212
const matchesStr = function (url, host, val) {
13-
const m = blacklist.matches(url, host)
13+
const m = blocklist.matches(url, host)
1414

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

1818
const matchesArray = function (url, val) {
19-
const m = blacklist.matches(url, hosts)
19+
const m = blocklist.matches(url, hosts)
2020

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

2424
const matchesHost = (url, host) => {
25-
expect(blacklist.matches(url, hosts)).to.eq(host)
25+
expect(blocklist.matches(url, hosts)).to.eq(host)
2626
}
2727

28-
describe('lib/blacklist', () => {
28+
describe('lib/blocklist', () => {
2929
it('handles hosts, ports, wildcards', () => {
3030
matchesArray('https://mail.google.com/foo', true)
3131
matchesArray('https://shop.apple.com/bar', true)

packages/proxy/lib/http/request-middleware.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash'
22
import debugModule from 'debug'
3-
import { blacklist, cors } from '@packages/network'
3+
import { blocklist, cors } from '@packages/network'
44
import { HttpMiddleware } from './'
55

66
export type RequestMiddleware = HttpMiddleware<{
@@ -50,11 +50,11 @@ const EndRequestsToBlacklistedHosts: RequestMiddleware = function () {
5050
const { blocklistHosts } = this.config
5151

5252
if (blocklistHosts) {
53-
const matches = blacklist.matches(this.req.proxiedUrl, blocklistHosts)
53+
const matches = blocklist.matches(this.req.proxiedUrl, blocklistHosts)
5454

5555
if (matches) {
56-
this.res.set('x-cypress-matched-blacklisted-host', matches)
57-
debug('blacklisting request %o', {
56+
this.res.set('x-cypress-matched-blocklisted-host', matches)
57+
debug('blocklisting request %o', {
5858
url: this.req.proxiedUrl,
5959
matches,
6060
})

packages/server/lib/server.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const compression = require('compression')
1515
const debug = require('debug')('cypress:server:server')
1616
const {
1717
agent,
18-
blacklist,
18+
blocklist,
1919
concatStream,
2020
cors,
2121
uri,
@@ -293,16 +293,16 @@ class Server {
293293
// if we are currently matching then we're
294294
// not making a direct connection anyway
295295
// so we only need to check this if we
296-
// have blacklist hosts and are not matching.
296+
// have blocklist hosts and are not matching.
297297
//
298-
// if we have blacklisted hosts lets
298+
// if we have blocklisted hosts lets
299299
// see if this matches - if so then
300300
// we cannot allow it to make a direct
301301
// connection
302302
if (blocklistHosts && !isMatching) {
303-
isMatching = blacklist.matches(urlToCheck, blocklistHosts)
303+
isMatching = blocklist.matches(urlToCheck, blocklistHosts)
304304

305-
debug(`HTTPS request ${urlToCheck} matches blacklist?`, isMatching)
305+
debug(`HTTPS request ${urlToCheck} matches blocklist?`, isMatching)
306306
}
307307

308308
// make a direct connection only if

packages/server/test/e2e/1_blacklist_hosts_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const onServer = function (app) {
1414
})
1515
}
1616

17-
describe('e2e blacklist', () => {
17+
describe('e2e blocklist', () => {
1818
e2e.setup({
1919
servers: [{
2020
port: 3131,
@@ -31,7 +31,7 @@ describe('e2e blacklist', () => {
3131

3232
it('passes', function () {
3333
return e2e.exec(this, {
34-
spec: 'blacklist_hosts_spec.coffee',
34+
spec: 'blocklist_hosts_spec.coffee',
3535
snapshot: true,
3636
})
3737
})

packages/server/test/integration/http_requests_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,7 +3727,7 @@ describe('Routes', () => {
37273727
})
37283728
})
37293729

3730-
context('blacklisted hosts', () => {
3730+
context('blocklisted hosts', () => {
37313731
beforeEach(function () {
37323732
return this.setup({
37333733
config: {
@@ -3744,7 +3744,7 @@ describe('Routes', () => {
37443744

37453745
it('returns 503 and custom headers for all hosts', function () {
37463746
const expectedHeader = (res, val) => {
3747-
expect(res.headers['x-cypress-matched-blacklisted-host']).to.eq(val)
3747+
expect(res.headers['x-cypress-matched-blocklisted-host']).to.eq(val)
37483748
}
37493749

37503750
return Promise.all([

packages/server/test/support/fixtures/projects/e2e/cypress/integration/blacklist_hosts_spec.coffee renamed to packages/server/test/support/fixtures/projects/e2e/cypress/integration/blocklist_hosts_spec.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
describe "blacklist", ->
2-
it "forces blacklisted hosts to return 503", ->
1+
describe "blocklist", ->
2+
it "forces blocklisted hosts to return 503", ->
33
cy
44
.visit("http://localhost:3232")
55

0 commit comments

Comments
 (0)