mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 20:39:30 +00:00

Adds a new `../common/fixtures' module to begin normalizing `test/fixtures` use. Our test code is a bit inconsistent with regards to use of the fixtures directory. Some code uses `path.join()`, some code uses string concats, some other code uses template strings, etc. In mnay cases, significant duplication of code is seen when accessing fixture files, etc. This updates many (but by no means all) of the tests in the test suite to use the new consistent API. There are still many more to update, which would make an excelent Code-n-Learn exercise. PR-URL: https://github.com/nodejs/node/pull/14332 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict';
|
|
require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
// Check cert chain is received by client, and is completed with the ca cert
|
|
// known to the client.
|
|
|
|
const {
|
|
assert, connect, debug, keys
|
|
} = require(fixtures.path('tls-connect'));
|
|
|
|
|
|
// agent6-cert.pem includes cert for agent6 and ca3, split it apart and
|
|
// provide ca3 in the .ca property.
|
|
const agent6Chain = keys.agent6.cert.split(/(?=-----BEGIN CERTIFICATE-----)/);
|
|
const agent6End = agent6Chain[0];
|
|
const agent6Middle = agent6Chain[1];
|
|
connect({
|
|
client: {
|
|
checkServerIdentity: (servername, cert) => { },
|
|
ca: keys.agent6.ca,
|
|
},
|
|
server: {
|
|
cert: agent6End,
|
|
key: keys.agent6.key,
|
|
ca: agent6Middle,
|
|
},
|
|
}, function(err, pair, cleanup) {
|
|
assert.ifError(err);
|
|
|
|
const peer = pair.client.conn.getPeerCertificate();
|
|
debug('peer:\n', peer);
|
|
assert.strictEqual(peer.serialNumber, 'C4CD893EF9A75DCC');
|
|
|
|
const next = pair.client.conn.getPeerCertificate(true).issuerCertificate;
|
|
const root = next.issuerCertificate;
|
|
delete next.issuerCertificate;
|
|
debug('next:\n', next);
|
|
assert.strictEqual(next.serialNumber, '9A84ABCFB8A72ABF');
|
|
|
|
debug('root:\n', root);
|
|
assert.strictEqual(root.serialNumber, '8DF21C01468AF393');
|
|
|
|
return cleanup();
|
|
});
|