Skip to content

Commit 331b652

Browse files
authored
fix: update node engines to 18+, CI to test 18, 20, update eslint-config and eslint errors (#2)
fix: proxy options
1 parent 56ee808 commit 331b652

File tree

7 files changed

+41
-34
lines changed

7 files changed

+41
-34
lines changed

.github/workflows/daily.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
node: [14]
13+
node-version: [18]
1414
os: [ubuntu-latest]
1515

1616
steps:
@@ -29,6 +29,6 @@ jobs:
2929
env:
3030
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
3131
SLACK_TITLE: 'Node version'
32-
SLACK_MESSAGE: ${{ matrix.node }}
32+
SLACK_MESSAGE: ${{ matrix.node-version }}
3333
SLACK_COLOR: ${{ job.status == 'success' && 'good' || job.status == 'cancelled' && '#808080' || 'danger' }}
3434

.github/workflows/node.js.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
node-version: [12.x, 14.x]
20+
node-version: [18.x, 20.x]
2121
os: [ubuntu-latest, windows-latest]
2222

2323
steps:
@@ -34,7 +34,6 @@ jobs:
3434
- run: npm test
3535
- name: upload coverage
3636
if: success()
37-
run: curl -s https://codecov.io/bash | bash
38-
env:
39-
CODECOV_NAME: ${{ runner.os }} node.js ${{ matrix.node-version }}
40-
shell: bash
37+
uses: codecov/codecov-action@v3.1.1
38+
with:
39+
name: ${{ runner.os }} node.js ${{ matrix.node-version }}

.github/workflows/on-push-publish-to-npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- uses: actions/setup-node@v1
1414
with:
15-
node-version: 14
15+
node-version: 18
1616
- run: npm install
1717
- run: npm test
1818
- uses: JS-DevTools/npm-publish@v1

.github/workflows/version-bump-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
git config user.email github-actions@github.com
2222
- uses: actions/setup-node@v1
2323
with:
24-
node-version: 14
24+
node-version: 18
2525
- run: |
2626
npm install
2727
npm test

package.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
"bugs": {
33
"url": "https://github.com/adobe/aio-lib-test-proxy/issues"
44
},
5-
"bundleDependencies": false,
5+
"bundleDependencies": [],
66
"dependencies": {
7-
"express": "^4.17.1",
87
"@adobe/aio-lib-core-logging": "1.1.0",
9-
"node-fetch": "^2.6.4",
8+
"express": "^4.17.1",
109
"mockttp": "^2.2.3",
10+
"node-fetch": "^2.6.4",
1111
"syswide-cas": "^5.3.0"
1212
},
1313
"deprecated": false,
1414
"description": "Adobe I/O Lib Test Proxies and Api Servers",
1515
"devDependencies": {
16-
"@adobe/eslint-config-aio-lib-config": "^1.2.0",
16+
"@adobe/eslint-config-aio-lib-config": "^2.0.2",
1717
"babel-runtime": "^6.26.0",
1818
"dotenv": "^8.1.0",
1919
"eol": "^0.9.1",
20-
"eslint": "^6.2.2",
21-
"eslint-config-standard": "^14.1.0",
22-
"eslint-plugin-import": "^2.18.0",
23-
"eslint-plugin-jest": "^23.6.0",
24-
"eslint-plugin-jsdoc": "^25.0.0",
25-
"eslint-plugin-node": "^11.0.0",
26-
"eslint-plugin-promise": "^4.2.1",
20+
"eslint": "^8.56.0",
21+
"eslint-config-standard": "^17.1.0",
22+
"eslint-plugin-import": "^2.29.1",
23+
"eslint-plugin-jest": "^27.6.1",
24+
"eslint-plugin-jsdoc": "^42.0.0",
25+
"eslint-plugin-n": "^15.7.0",
26+
"eslint-plugin-node": "^11.1.0",
27+
"eslint-plugin-promise": "^6.1.1",
2728
"eslint-plugin-standard": "^4.0.0",
2829
"fetch-mock": "^9.0.0",
2930
"http-proxy-agent": "^4.0.1",
3031
"https-proxy-agent": "2.2.4",
31-
"jest": "^25.1.0",
32+
"jest": "^29",
3233
"jest-fetch-mock": "^3.0.1",
3334
"jest-html-reporter": "^3.4.1",
3435
"jest-junit": "^10.0.0",
@@ -37,7 +38,8 @@
3738
"jsdoc-to-markdown": "^5.0.0",
3839
"query-string": "^7.0.1",
3940
"stdout-stderr": "^0.1.9",
40-
"tsd-jsdoc": "^2.4.0"
41+
"tsd-jsdoc": "^2.4.0",
42+
"typescript": "^5.3.3"
4143
},
4244
"homepage": "https://github.com/adobe/aio-lib-test-proxy",
4345
"license": "Apache-2.0",
@@ -56,7 +58,7 @@
5658
"version": "1.0.0",
5759
"engineStrict": true,
5860
"engines": {
59-
"node": ">=12.0.0"
61+
"node": ">=18"
6062
},
6163
"files": [
6264
"src"

src/api-server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const express = require('express')
1414
const mockttp = require('mockttp')
1515
const https = require('https')
1616
const http = require('http')
17+
const HOSTNAME = '127.0.0.1'
1718

1819
/**
1920
* Create a simple API server.
@@ -50,9 +51,9 @@ async function createApiServer (options = {}) {
5051
if (useSsl) {
5152
const httpsOptions = await mockttp.generateCACertificate()
5253

53-
server = https.createServer(httpsOptions, app).listen(port, 'localhost')
54+
server = https.createServer(httpsOptions, app).listen(port, HOSTNAME)
5455
} else {
55-
server = http.createServer(app).listen(port, 'localhost')
56+
server = http.createServer(app).listen(port, HOSTNAME)
5657
}
5758

5859
return new Promise(resolve => {
@@ -64,5 +65,6 @@ async function createApiServer (options = {}) {
6465
}
6566

6667
module.exports = {
68+
HOSTNAME,
6769
createApiServer
6870
}

test/proxy.test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
1111

1212
const queryString = require('query-string')
1313
const { createHttpsProxy, createHttpProxy } = require('../src/proxy')
14-
const { createApiServer } = require('../src/api-server')
14+
const { createApiServer, HOSTNAME } = require('../src/api-server')
1515
const fetch = require('node-fetch')
1616
const HttpsProxyAgent = require('https-proxy-agent')
1717
const HttpProxyAgent = require('http-proxy-agent')
@@ -64,7 +64,7 @@ describe('http proxy', () => {
6464
const apiServerAddress = apiServer.address()
6565
const queryObject = { foo: 'bar' }
6666

67-
const testUrl = `${protocol}://localhost:${apiServerAddress.port}/mirror?${queryString.stringify(queryObject)}`
67+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerAddress.port}/mirror?${queryString.stringify(queryObject)}`
6868

6969
const proxyUrl = proxyServer.url
7070
const proxyOpts = urlToHttpOptions(proxyUrl)
@@ -78,7 +78,7 @@ describe('http proxy', () => {
7878

7979
test('failure', async () => {
8080
// connect to non-existent server port
81-
const testUrl = `${protocol}://localhost:${portNotInUse}/mirror/?foo=bar`
81+
const testUrl = `${protocol}://${HOSTNAME}:${portNotInUse}/mirror/?foo=bar`
8282

8383
const proxyUrl = proxyServer.url
8484
const proxyOpts = urlToHttpOptions(proxyUrl)
@@ -114,7 +114,7 @@ describe('http proxy', () => {
114114
const proxyOpts = urlToHttpOptions(proxyUrl)
115115
proxyOpts.auth = `${username}:${password}`
116116

117-
const testUrl = `${protocol}://localhost:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
117+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
118118
const response = await fetch(testUrl, {
119119
agent: new HttpProxyAgent(proxyOpts),
120120
headers
@@ -138,7 +138,7 @@ describe('http proxy', () => {
138138
const proxyOpts = urlToHttpOptions(proxyUrl)
139139
proxyOpts.auth = `${username}:${password}`
140140

141-
const testUrl = `${protocol}://localhost:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
141+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
142142
const response = await fetch(testUrl, {
143143
agent: new HttpProxyAgent(proxyOpts),
144144
headers
@@ -170,13 +170,14 @@ describe('https proxy', () => {
170170
const apiServerAddress = apiServer.address()
171171
const queryObject = { foo: 'bar' }
172172

173-
const testUrl = `${protocol}://localhost:${apiServerAddress.port}/mirror?${queryString.stringify(queryObject)}`
173+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerAddress.port}/mirror?${queryString.stringify(queryObject)}`
174174

175175
const proxyUrl = proxyServer.url
176176
const proxyOpts = urlToHttpOptions(proxyUrl)
177177
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
178178
// this is only used for unit-tests and passed in the constructor
179179
proxyOpts.rejectUnauthorized = false
180+
proxyOpts.ALPNProtocols = ['http/1.1']
180181

181182
const response = await fetch(testUrl, {
182183
agent: new HttpsProxyAgent(proxyOpts)
@@ -188,13 +189,14 @@ describe('https proxy', () => {
188189

189190
test('failure', async () => {
190191
// connect to non-existent server port
191-
const testUrl = `${protocol}://localhost:${portNotInUse}/mirror/?foo=bar`
192+
const testUrl = `${protocol}://${HOSTNAME}:${portNotInUse}/mirror/?foo=bar`
192193

193194
const proxyUrl = proxyServer.url
194195
const proxyOpts = urlToHttpOptions(proxyUrl)
195196
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
196197
// this is only used for unit-tests and passed in the constructor
197198
proxyOpts.rejectUnauthorized = false
199+
proxyOpts.ALPNProtocols = ['http/1.1']
198200

199201
const response = await fetch(testUrl, {
200202
agent: new HttpsProxyAgent(proxyOpts)
@@ -230,8 +232,9 @@ describe('https proxy', () => {
230232
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
231233
// this is only used for unit-tests and passed in the constructor
232234
proxyOpts.rejectUnauthorized = false
235+
proxyOpts.ALPNProtocols = ['http/1.1']
233236

234-
const testUrl = `${protocol}://localhost:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
237+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
235238
const response = await fetch(testUrl, {
236239
agent: new HttpsProxyAgent(proxyOpts),
237240
headers
@@ -256,8 +259,9 @@ describe('https proxy', () => {
256259
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
257260
// this is only used for unit-tests and passed in the constructor
258261
proxyOpts.rejectUnauthorized = false
262+
proxyOpts.ALPNProtocols = ['http/1.1']
259263

260-
const testUrl = `${protocol}://localhost:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
264+
const testUrl = `${protocol}://${HOSTNAME}:${apiServerPort}/mirror?${queryString.stringify(queryObject)}`
261265
const response = await fetch(testUrl, {
262266
agent: new HttpsProxyAgent(proxyOpts),
263267
headers

0 commit comments

Comments
 (0)