Skip to content

Commit

Permalink
test: refactor test-tls-enable-trace-cli.js
Browse files Browse the repository at this point in the history
PR-URL: #27553
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig authored and targos committed May 9, 2019
1 parent b6e540a commit 815a957
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/parallel/test-tls-enable-trace-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ const child = fork(__filename, ['test'], {
execArgv: ['--trace-tls']
});

let stdout = '';
let stderr = '';
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
child.stdout.on('data', (data) => stdout += data);
child.stderr.on('data', (data) => stderr += data);
child.on('close', common.mustCall(() => {
child.on('close', common.mustCall((code, signal) => {
// For debugging and observation of actual trace output.
console.log(stderr);

assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
assert.strictEqual(stdout.trim(), '');
assert(/Warning: Enabling --trace-tls can expose sensitive/.test(stderr));
assert(/Received Record/.test(stderr));
assert(/ClientHello/.test(stderr));
}));

// For debugging and observation of actual trace output.
child.stderr.pipe(process.stderr);
child.stdout.pipe(process.stdout);

child.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));

function test() {
const {
connect, keys
Expand All @@ -54,6 +55,13 @@ function test() {
key: keys.agent6.key
},
}, common.mustCall((err, pair, cleanup) => {
if (err) {
console.error(err);
console.error(err.opensslErrorStack);
console.error(err.reason);
assert(err);
}

return cleanup();
}));
}

0 comments on commit 815a957

Please sign in to comment.