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

Function Client

test/sequential/test-tls-session-timeout.js:72–124  ·  view source on GitHub ↗
(port, sessIn, sessOut, expectedType, cb)

Source from the content-addressed store, hash-verified

70 const sessionFileName = tmpdir.resolve('tls-session-ticket.txt');
71 // Expects a callback -- cb()
72 function Client(port, sessIn, sessOut, expectedType, cb) {
73 const flags = [
74 's_client',
75 '-connect', `localhost:${port}`,
76 '-CAfile', fixtures.path('keys', 'rsa_cert.crt'),
77 '-servername', 'localhost',
78 ];
79 if (sessIn) {
80 flags.push('-sess_in', sessIn);
81 }
82 if (sessOut) {
83 flags.push('-sess_out', sessOut);
84 }
85 const client = spawn(opensslCli, flags, {
86 stdio: ['ignore', 'pipe', 'inherit'],
87 });
88
89 let clientOutput = '';
90 client.stdout.on('data', (data) => {
91 clientOutput += data.toString();
92 });
93 client.on('exit', common.mustCall((code) => {
94 let connectionType;
95 // Log the output for debugging purposes. Don't remove them or otherwise
96 // the CI output is useless when this test flakes.
97 console.log(' ----- [COMMAND] ---');
98 console.log(`${opensslCli}, ${flags.join(' ')}`);
99 console.log(' ----- [STDOUT] ---');
100 console.log(clientOutput);
101 console.log(' ----- [SESSION FILE] ---');
102 try {
103 const stat = fs.statSync(sessionFileName);
104 console.log(`Session file size: ${stat.size} bytes`);
105 } catch (err) {
106 console.log('Error reading session file:', err);
107 }
108
109 const grepConnectionType = (line) => {
110 const matches = line.match(/(New|Reused), /);
111 if (matches) {
112 connectionType = matches[1];
113 return true;
114 }
115 };
116 const lines = clientOutput.split('\n');
117 if (!lines.some(grepConnectionType)) {
118 throw new Error('unexpected output from openssl client');
119 }
120 assert.strictEqual(code, 0);
121 assert.strictEqual(connectionType, expectedType);
122 cb(connectionType);
123 }));
124 }
125
126 const server = tls.createServer(options, (cleartext) => {
127 cleartext.on('error', (er) => {

Callers 1

doTestFunction · 0.70

Calls 11

someMethod · 0.80
cbFunction · 0.70
spawnFunction · 0.50
pathMethod · 0.45
pushMethod · 0.45
onMethod · 0.45
toStringMethod · 0.45
logMethod · 0.45
joinMethod · 0.45
statSyncMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…