mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 19:49:19 +00:00

Object.assign() can be replaced by spread objects PR-URL: https://github.com/nodejs/node/pull/30423 Refs: https://eslint.org/docs/rules/prefer-object-spread Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
const https = require('https');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const options = {
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
cert: fixtures.readKey('agent1-cert.pem'),
|
|
ca: fixtures.readKey('ca1-cert.pem'),
|
|
minVersion: 'TLSv1.1',
|
|
};
|
|
|
|
const server = https.Server(options, (req, res) => {
|
|
res.writeHead(200);
|
|
res.end('hello world\n');
|
|
});
|
|
|
|
function getBaseOptions(port) {
|
|
return {
|
|
path: '/',
|
|
port: port,
|
|
ca: options.ca,
|
|
rejectUnauthorized: true,
|
|
servername: 'agent1',
|
|
};
|
|
}
|
|
|
|
const updatedValues = new Map([
|
|
['dhparam', fixtures.readKey('dh2048.pem')],
|
|
['ecdhCurve', 'secp384r1'],
|
|
['honorCipherOrder', true],
|
|
['secureOptions', crypto.constants.SSL_OP_CIPHER_SERVER_PREFERENCE],
|
|
['secureProtocol', 'TLSv1_1_method'],
|
|
['sessionIdContext', 'sessionIdContext'],
|
|
]);
|
|
|
|
let value;
|
|
function variations(iter, port, cb) {
|
|
return common.mustCall((res) => {
|
|
res.resume();
|
|
https.globalAgent.once('free', common.mustCall(() => {
|
|
// Verify that the most recent connection is in the freeSockets pool.
|
|
const keys = Object.keys(https.globalAgent.freeSockets);
|
|
if (value) {
|
|
assert.ok(
|
|
keys.some((val) => val.startsWith(value.toString() + ':') ||
|
|
val.endsWith(':' + value.toString()) ||
|
|
val.includes(':' + value.toString() + ':')),
|
|
`missing value: ${value.toString()} in ${keys}`
|
|
);
|
|
}
|
|
const next = iter.next();
|
|
|
|
if (next.done) {
|
|
https.globalAgent.destroy();
|
|
server.close();
|
|
} else {
|
|
// Save `value` for check the next time.
|
|
value = next.value.val;
|
|
const [key, val] = next.value;
|
|
https.get({ ...getBaseOptions(port), [key]: val },
|
|
variations(iter, port, cb));
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
https.globalAgent.keepAlive = true;
|
|
https.get(getBaseOptions(port), variations(updatedValues.entries(), port));
|
|
}));
|