test: fix pummel/test-tls-session-timeout
The test does not work with TLS 1.3 nor should it. Force TLS version 1.2. While at it, some refactoring: * refresh the tmp directory in case it doesn't exist! * add an assert.strictEqual() check on the client return `code` value which must be zero * use arrow functions for callbacks * add trailing commas for multiline arrays/objects Fixes: https://github.com/nodejs/node/issues/26839 PR-URL: https://github.com/nodejs/node/pull/26865 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
6e9551e1b1
commit
cc89e68e72
@ -29,6 +29,7 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
tmpdir.refresh();
|
||||||
|
|
||||||
doTest();
|
doTest();
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ function doTest() {
|
|||||||
key: key,
|
key: key,
|
||||||
cert: cert,
|
cert: cert,
|
||||||
ca: [cert],
|
ca: [cert],
|
||||||
sessionTimeout: SESSION_TIMEOUT
|
sessionTimeout: SESSION_TIMEOUT,
|
||||||
|
maxVersion: 'TLSv1.2',
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to store a sample session ticket in the fixtures directory because
|
// We need to store a sample session ticket in the fixtures directory because
|
||||||
@ -79,17 +81,17 @@ function doTest() {
|
|||||||
's_client',
|
's_client',
|
||||||
'-connect', `localhost:${common.PORT}`,
|
'-connect', `localhost:${common.PORT}`,
|
||||||
'-sess_in', sessionFileName,
|
'-sess_in', sessionFileName,
|
||||||
'-sess_out', sessionFileName
|
'-sess_out', sessionFileName,
|
||||||
];
|
];
|
||||||
const client = spawn(common.opensslCli, flags, {
|
const client = spawn(common.opensslCli, flags, {
|
||||||
stdio: ['ignore', 'pipe', 'ignore']
|
stdio: ['ignore', 'pipe', 'ignore']
|
||||||
});
|
});
|
||||||
|
|
||||||
let clientOutput = '';
|
let clientOutput = '';
|
||||||
client.stdout.on('data', function(data) {
|
client.stdout.on('data', (data) => {
|
||||||
clientOutput += data.toString();
|
clientOutput += data.toString();
|
||||||
});
|
});
|
||||||
client.on('exit', function(code) {
|
client.on('exit', (code) => {
|
||||||
let connectionType;
|
let connectionType;
|
||||||
const grepConnectionType = (line) => {
|
const grepConnectionType = (line) => {
|
||||||
const matches = line.match(/(New|Reused), /);
|
const matches = line.match(/(New|Reused), /);
|
||||||
@ -102,25 +104,26 @@ function doTest() {
|
|||||||
if (!lines.some(grepConnectionType)) {
|
if (!lines.some(grepConnectionType)) {
|
||||||
throw new Error('unexpected output from openssl client');
|
throw new Error('unexpected output from openssl client');
|
||||||
}
|
}
|
||||||
|
assert.strictEqual(code, 0);
|
||||||
cb(connectionType);
|
cb(connectionType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = tls.createServer(options, function(cleartext) {
|
const server = tls.createServer(options, (cleartext) => {
|
||||||
cleartext.on('error', function(er) {
|
cleartext.on('error', (er) => {
|
||||||
if (er.code !== 'ECONNRESET')
|
if (er.code !== 'ECONNRESET')
|
||||||
throw er;
|
throw er;
|
||||||
});
|
});
|
||||||
cleartext.end();
|
cleartext.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
server.listen(common.PORT, () => {
|
||||||
Client(function(connectionType) {
|
Client((connectionType) => {
|
||||||
assert.strictEqual(connectionType, 'New');
|
assert.strictEqual(connectionType, 'New');
|
||||||
Client(function(connectionType) {
|
Client((connectionType) => {
|
||||||
assert.strictEqual(connectionType, 'Reused');
|
assert.strictEqual(connectionType, 'Reused');
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
Client(function(connectionType) {
|
Client((connectionType) => {
|
||||||
assert.strictEqual(connectionType, 'New');
|
assert.strictEqual(connectionType, 'New');
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user