mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 10:27:12 +00:00

Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
40 lines
1009 B
JavaScript
40 lines
1009 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
|
|
const tls = require('tls');
|
|
const fs = require('fs');
|
|
|
|
const ca1 =
|
|
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, 'utf8');
|
|
const ca2 =
|
|
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, 'utf8');
|
|
const cert =
|
|
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, 'utf8');
|
|
const key =
|
|
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, 'utf8');
|
|
|
|
function test(ca, next) {
|
|
const server = tls.createServer({ ca, cert, key }, function(conn) {
|
|
this.close();
|
|
conn.end();
|
|
});
|
|
|
|
server.addContext('agent3', { ca, cert, key });
|
|
|
|
const host = common.localhostIPv4;
|
|
server.listen(0, host, function() {
|
|
tls.connect({ servername: 'agent3', host, port: this.address().port, ca });
|
|
});
|
|
|
|
server.once('close', next);
|
|
}
|
|
|
|
const array = [ca1, ca2];
|
|
const string = ca1 + '\n' + ca2;
|
|
test(array, () => test(string, common.noop));
|