MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-tls-min-max-version.js:29–96  ·  view source on GitHub ↗
(cmin, cmax, cprot, smin, smax, sprot, proto, cerr, serr)

Source from the content-addressed store, hash-verified

27
28
29function test(cmin, cmax, cprot, smin, smax, sprot, proto, cerr, serr) {
30 assert(proto || cerr || serr, 'test missing any expectations');
31
32 let ciphers;
33 if (hasOpenSSL3 && (proto === 'TLSv1' || proto === 'TLSv1.1' ||
34 proto === 'TLSv1_1_method' || proto === 'TLSv1_method' ||
35 sprot === 'TLSv1_1_method' || sprot === 'TLSv1_method')) {
36 if (serr !== 'ERR_SSL_UNSUPPORTED_PROTOCOL')
37 ciphers = 'ALL@SECLEVEL=0';
38 }
39 if (hasOpenSSL(3, 1) && cerr === 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION') {
40 ciphers = 'DEFAULT@SECLEVEL=0';
41 }
42 // Report where test was called from. Strip leading garbage from
43 // at Object.<anonymous> (file:line)
44 // from the stack location, we only want the file:line part.
45 const where = inspect(new Error()).split('\n')[2].replace(/[^(]*/, '');
46 connect({
47 client: {
48 checkServerIdentity: (servername, cert) => { },
49 ca: `${keys.agent1.cert}\n${keys.agent6.ca}`,
50 minVersion: cmin,
51 maxVersion: cmax,
52 secureProtocol: cprot,
53 ciphers: ciphers
54 },
55 server: {
56 cert: keys.agent6.cert,
57 key: keys.agent6.key,
58 minVersion: smin,
59 maxVersion: smax,
60 secureProtocol: sprot,
61 ciphers: ciphers
62 },
63 }, common.mustCall((err, pair, cleanup) => {
64 function u(_) { return _ === undefined ? 'U' : _; }
65 console.log('test:', u(cmin), u(cmax), u(cprot), u(smin), u(smax), u(sprot),
66 u(ciphers), 'expect', u(proto), u(cerr), u(serr));
67 console.log(' ', where);
68 if (!proto) {
69 console.log('client', pair.client.err ? pair.client.err.code : undefined);
70 console.log('server', pair.server.err ? pair.server.err.code : undefined);
71 if (cerr) {
72 assert(pair.client.err);
73 // Accept these codes as aliases, the one reported depends on the
74 // OpenSSL version.
75 if (cerr === 'ERR_SSL_UNSUPPORTED_PROTOCOL' &&
76 pair.client.err.code === 'ERR_SSL_VERSION_TOO_LOW')
77 cerr = 'ERR_SSL_VERSION_TOO_LOW';
78 assert.strictEqual(pair.client.err.code, cerr);
79 }
80 if (serr) {
81 assert(pair.server.err);
82 assert.strictEqual(pair.server.err.code, serr);
83 }
84 return cleanup();
85 }
86

Callers 1

Calls 8

hasOpenSSLFunction · 0.85
inspectFunction · 0.70
connectFunction · 0.70
uFunction · 0.70
cleanupFunction · 0.70
assertFunction · 0.50
splitMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…